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