update and cleanup chaingame
This commit is contained in:
@@ -21,18 +21,20 @@ void c_chaingame::runGame(void)
|
||||
case cg_reset:
|
||||
{
|
||||
// clear all vars
|
||||
turnOffAllLed();
|
||||
turnOnAllLed();
|
||||
cheatbutton = 0;
|
||||
playNextTimer = 0;
|
||||
patternIndex = 0;
|
||||
state = cg_idle;
|
||||
}
|
||||
break;
|
||||
case cg_idle:
|
||||
{
|
||||
// wait for button
|
||||
updateCheatButton();
|
||||
turnOffAllLed();
|
||||
// -> cg_play
|
||||
// wait for button
|
||||
|
||||
if (buttonIsPressed(ledpattern[patternIndex]))
|
||||
if (buttonIsPressed(ledpattern[patternIndex]) && (cheatbutton == 0))
|
||||
{
|
||||
state = cg_play;
|
||||
}
|
||||
@@ -121,7 +123,6 @@ void c_chaingame::runGame(void)
|
||||
state = cg_reset;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void c_chaingame::updateCheatButton(void)
|
||||
@@ -146,10 +147,10 @@ void c_chaingame::updateCheatButton(void)
|
||||
|
||||
bool c_chaingame::initGame(void)
|
||||
{
|
||||
patternIndex = 0;
|
||||
patternFlag = false;
|
||||
cheatbutton = 0;
|
||||
cheatButtonFlag = false;
|
||||
// patternFlag = false;
|
||||
// cheatbutton = 0;
|
||||
// cheatButtonFlag = false;
|
||||
state = cg_reset;
|
||||
return true;
|
||||
}
|
||||
void c_chaingame::resetGame(void)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "buttons.h"
|
||||
#include "game.h"
|
||||
|
||||
#define PLAYNEXTTIMEOUT 3000 // 3sec * 1000ms
|
||||
#define PLAYNEXTTIMEOUT 1500 // 3sec * 1000ms
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -21,9 +21,9 @@ class c_chaingame : public c_game
|
||||
{
|
||||
private:
|
||||
uint8_t patternIndex;
|
||||
bool patternFlag = false;
|
||||
//bool patternFlag = false;
|
||||
uint16_t cheatbutton = 0;
|
||||
bool cheatButtonFlag = false;
|
||||
//bool cheatButtonFlag = false;
|
||||
uint16_t ledpattern[4] = {1, 3, 1, 2};
|
||||
int patternlength = sizeof(ledpattern) / sizeof(ledpattern[0]);
|
||||
cg_states state = cg_reset;
|
||||
|
||||
Reference in New Issue
Block a user