Simple Simon says mbed game which makes random queue, shows it with onboard LEDs and takes user input with push buttons.
Dependencies: PinDetect mbed beep
Diff: Simon.cpp
- Revision:
- 2:0b6e10420ce2
- Parent:
- 1:fb29354d9073
--- a/Simon.cpp Wed Feb 04 09:12:38 2015 +0000 +++ b/Simon.cpp Wed Feb 04 10:35:15 2015 +0000 @@ -10,7 +10,6 @@ Simon::Simon() : queue(turn) { LEDSBlink(); - button_press = false; run = false; button[0].attach_asserted(this, &Simon::keyPressedSt); button[1].attach_asserted(this, &Simon::keyPressedNd); @@ -23,8 +22,9 @@ } } -void Simon::gameStart(int firstTurn) { - turn = firstTurn; +void Simon::gameStart(int first_turn) { + this -> first_turn = first_turn; + turn = first_turn; while(1) { while(run == true) { newQueue(); @@ -67,6 +67,7 @@ bool Simon::userTurn() { LEDSBlink(); i = 0; + button_press = false; while(i < turn){ if (button_press == 1) { if (testQueue() == 0) { @@ -106,5 +107,6 @@ } void Simon:: ReStart() { - run = true; + run = true; + turn = first_turn; } \ No newline at end of file