Fix score display

This commit is contained in:
Gabriel Augendre 2021-04-29 20:25:18 +02:00
parent 187bfe12ac
commit 314622ea0b

View file

@ -8,6 +8,7 @@ LiquidCrystal lcd(9, 8, 4, 5, 6, 7);
byte sequence[MAX_GAME] = {}; byte sequence[MAX_GAME] = {};
int8_t currentPosition = -1; int8_t currentPosition = -1;
bool win = true; bool win = true;
bool over = false;
void setup() { void setup() {
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
@ -24,6 +25,9 @@ void setup() {
void loop() { void loop() {
if (currentPosition + 1 >= MAX_GAME) { if (currentPosition + 1 >= MAX_GAME) {
over = true;
}
if (over) {
endGame(lcd, win, currentPosition); endGame(lcd, win, currentPosition);
return; return;
} }
@ -35,7 +39,7 @@ void loop() {
playSequence(sequence, currentPosition); playSequence(sequence, currentPosition);
if (!userSequence(sequence, currentPosition)) { if (!userSequence(sequence, currentPosition)) {
win = false; win = false;
currentPosition = MAX_GAME; over = true;
} }
delay(2000); delay(2000);