Final Submission. I have read and agreed with Statement of Academic Integrity.
Dependencies: mbed Gamepad N5110 Joystick
Diff: Game_engine/Game_engine.cpp
- Revision:
- 6:f02ea8ec42b3
- Parent:
- 5:23a85b16ee54
- Child:
- 7:72119ea3b3b1
--- a/Game_engine/Game_engine.cpp Thu May 09 08:33:26 2019 +0000 +++ b/Game_engine/Game_engine.cpp Thu May 09 08:54:39 2019 +0000 @@ -25,13 +25,13 @@ if ( gamepad.check_event(Gamepad::Y_PRESSED) && _direction != 1) { _direction = 0; } - if ( gamepad.check_event(Gamepad::A_PRESSED) && _direction != 0) { + else if ( gamepad.check_event(Gamepad::A_PRESSED) && _direction != 0) { _direction = 1; } - if ( gamepad.check_event(Gamepad::X_PRESSED) && _direction != 3) { + else if ( gamepad.check_event(Gamepad::X_PRESSED) && _direction != 3) { _direction = 2; } - if ( gamepad.check_event(Gamepad::B_PRESSED) && _direction != 2) { + else if ( gamepad.check_event(Gamepad::B_PRESSED) && _direction != 2) { _direction = 3; } } @@ -45,7 +45,8 @@ snake.set_snake_posX (snake.get_snake_posX()- 4); } else if (_direction == 3) { snake.set_snake_posX (snake.get_snake_posX()+ 4); - } + } + wait(0.01); } void GameEngine::food_move() {