fixes to chaingame
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// extern c_button button3;
|
||||
|
||||
uint8_t patternIndex = 0;
|
||||
uint8_t nextPatternIndex = 1;
|
||||
//uint8_t nextPatternIndex = 1;
|
||||
bool patternFlag = false;
|
||||
bool firstpattern = false;
|
||||
e_ledcolor cheatbutton = NONE;
|
||||
@@ -41,20 +41,41 @@ void nextPattern(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ResetChainGame(void)
|
||||
{
|
||||
patternIndex = 0;
|
||||
patternFlag = false;
|
||||
firstpattern = false;
|
||||
cheatbutton = NONE;
|
||||
cheatButtonFlag = false;
|
||||
}
|
||||
|
||||
void HandleChainGame(void)
|
||||
{
|
||||
if (buttonIsPressed(ledpattern[patternIndex]))
|
||||
if (buttonIsPressed(ledpattern[patternIndex]) && !cheatButtonFlag)
|
||||
{
|
||||
turnOnLed(ledpattern[patternIndex]);
|
||||
patternFlag = true;
|
||||
cheatbutton = NONE;
|
||||
}
|
||||
else if (buttonIsPressed(cheatbutton))
|
||||
else if (buttonIsPressed(cheatbutton) && !patternFlag && !cheatButtonFlag)
|
||||
{
|
||||
turnOnLed(cheatbutton);
|
||||
cheatButtonFlag = true;
|
||||
}
|
||||
else if (!anybutton())
|
||||
|
||||
if (!buttonIsPressed(ledpattern[patternIndex]))
|
||||
{
|
||||
turnOffLed(ledpattern[patternIndex]);
|
||||
}
|
||||
|
||||
if (!buttonIsPressed(cheatbutton) && cheatButtonFlag)
|
||||
{
|
||||
turnOffLed(cheatbutton);
|
||||
cheatButtonFlag = false;
|
||||
cheatbutton = NONE;
|
||||
}
|
||||
|
||||
if (!anybutton())
|
||||
{
|
||||
turnOffAllLed();
|
||||
if (patternFlag)
|
||||
@@ -62,76 +83,19 @@ void HandleChainGame(void)
|
||||
patternFlag = false;
|
||||
nextPattern();
|
||||
}
|
||||
if(cheatButtonFlag)
|
||||
{
|
||||
cheatButtonFlag = false;
|
||||
cheatbutton = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
if(buttonIsPressed(YELLOW2))
|
||||
|
||||
//check cheatbuttons
|
||||
if (buttonIsPressed(YELLOW2) && (cheatbutton == NONE))
|
||||
{
|
||||
cheatbutton = YELLOW;
|
||||
}
|
||||
else if(buttonIsPressed(RED2))
|
||||
}
|
||||
else if (buttonIsPressed(RED2) && (cheatbutton == NONE))
|
||||
{
|
||||
cheatbutton = RED;
|
||||
}
|
||||
else if(buttonIsPressed(GREEN2))
|
||||
}
|
||||
else if (buttonIsPressed(GREEN2) && (cheatbutton == NONE))
|
||||
{
|
||||
cheatbutton = GREEN;
|
||||
}
|
||||
|
||||
// if (buttonIsPressed(YELLOW) | buttonIsPressed(RED) | buttonIsPressed(GREEN))
|
||||
// {
|
||||
// if (!patternFlag)
|
||||
// {
|
||||
// //button detected, increase pattern
|
||||
// if (!firstpattern)
|
||||
// {
|
||||
// firstpattern = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nextPattern();
|
||||
// }
|
||||
|
||||
// patternFlag = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (buttonIsPressed(RED))
|
||||
// {
|
||||
// if (!patternFlag)
|
||||
// {
|
||||
// if (!firstpattern)
|
||||
// {
|
||||
// firstpattern = true;
|
||||
// nextPattern();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //second input, skip a pattern
|
||||
// nextPattern();
|
||||
// nextPattern();
|
||||
// }
|
||||
// patternFlag = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (anybutton() && patternFlag)
|
||||
// {
|
||||
// //write pattern to the LEDs
|
||||
// digitalWrite(LED1, ledpattern[patternIndex][0]);
|
||||
// digitalWrite(LED2, ledpattern[patternIndex][1]);
|
||||
// digitalWrite(LED3, ledpattern[patternIndex][2]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //leds off
|
||||
// digitalWrite(LED1, 0);
|
||||
// digitalWrite(LED2, 0);
|
||||
// digitalWrite(LED3, 0);
|
||||
// patternFlag = false;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user