Include level in sequence generation to resolve #2.

pull/14/head
Dennis Bücker 1 year ago
parent afecc92ea2
commit 5b9acf8475
  1. 10
      src/ShowColorSequence.cpp
  2. 4
      src/SimonDisplay.cpp
  3. 76
      src/SimonSays.cpp
  4. 1
      src/SimonSays.h

@ -36,12 +36,18 @@ void ShowColorSequence::update(SimonSays & simonSays)
simonSays.goToNextPhase();
return;
}
ticksTillNextColor = 25;//100; //TODO: Set this by selected level
ticksTillNextColor = simonSays.currentSpeed;
lastDisplayWasColor = true;
}
else {
simonSays.simonDisplay.displayOneColor(CRGB::Black);
ticksTillNextColor = 10;//25;
if (simonSays.currentSpeed>50)
{
ticksTillNextColor = 25;
}
else {
ticksTillNextColor = 13;
}
lastDisplayWasColor = false;
}

@ -173,10 +173,6 @@ void TwoColorSelection::update(SimonDisplay &simonDisplay)
}
}
}
for (int i = 0; i<simonDisplay.numberOfColors; i++){
Serial.print(simonDisplay.colorsToDisplay[i]);
}
Serial.println();
}
void ThreeColorSelection::update(SimonDisplay &simonDisplay)

@ -16,8 +16,9 @@ SimonSays::SimonSays(SimonDisplay & _simonDisplay):
},
currentState{0},
currentSequence{999,999,999,999,999,999,999,999,999,999}, // dummy sequence of 10 entries
currentSequenceLength{0},
currentSequenceLength{1},
currentLevel{0},
currentSpeed{100},
simonDisplay(_simonDisplay)
{
@ -55,8 +56,73 @@ void SimonSays::goToNextPhase() {
void SimonSays::generateNewSequence() {
// Values will be generated by Level property
currentSequenceLength = 8;
int numberOfColors = 6;
/*
Pia will have to complete only 10 Levels
lvl / no of colors / number of elements / speed
0-1 / 2 / 3,4 / 100, 80
2-3 / 3 / 4,5 / 90, 70
4-5 / 4 / 5,6 / 80, 60
6-7 / 5 / 6,7 / 70, 50
8-9 / 6 / 7,8 / 60, 40
*/
int numberOfColors;
switch(currentLevel) {
case 0 :
numberOfColors=2;
currentSequenceLength = 3;
currentSpeed = 100;
break;
case 1 :
numberOfColors = 2;
currentSequenceLength = 4;
currentSpeed = 80;
break;
case 2:
numberOfColors = 3;
currentSequenceLength = 4;
currentSpeed = 90;
break;
case 3:
numberOfColors = 3;
currentSequenceLength = 5;
currentSpeed = 70;
break;
case 4:
numberOfColors = 4;
currentSequenceLength = 5;
currentSpeed = 80;
break;
case 5:
numberOfColors = 4;
currentSequenceLength = 6;
currentSpeed = 60;
break;
case 6:
numberOfColors = 5;
currentSequenceLength = 6;
currentSpeed = 70;
break;
case 7:
numberOfColors = 5;
currentSequenceLength = 7;
currentSpeed = 50;
break;
case 8:
numberOfColors = 6;
currentSequenceLength = 7;
currentSpeed = 60;
break;
case 9:
numberOfColors = 6;
currentSequenceLength = 8;
currentSpeed = 40;
break;
default:
numberOfColors = 1;
currentSequenceLength = 1;
currentSpeed = 100;
break;
}
Serial.print("Generated sequence ");
for (int i = 0; i < currentSequenceLength; i++)
@ -67,7 +133,9 @@ void SimonSays::generateNewSequence() {
}
Serial.print(" with ");
Serial.print(currentSequenceLength);
Serial.println(" members.");
Serial.print(" members for level ");
Serial.print(currentLevel);
Serial.println(".");
}
void SimonSays::resetGameAfterLoose() {

@ -71,6 +71,7 @@ public:
int currentSequence[10];
int currentSequenceLength;
int currentLevel;
int currentSpeed;
// Display device logic for LEDs etc
SimonDisplay &simonDisplay;

Loading…
Cancel
Save