![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Matis Requis 201241242
Dependencies: mbed
Tempest Game
Game Screen
The board is made of 12 columns. The Hero stays at the top of the column
Game Controls
To control the hero spaceship point the joystick to the column you want the hero to go to.
Press the A button to shoot a bullet in the column you are currently in.
Diff: main.cpp
- Revision:
- 10:2ae9d4145410
- Parent:
- 4:8e3ba8d6d915
--- a/main.cpp Tue May 26 07:26:13 2020 +0000 +++ b/main.cpp Tue May 26 16:31:22 2020 +0000 @@ -22,28 +22,44 @@ N5110 lcd; TempestEngine tempest; -//prototypes +//Objects void init(); void render(); +void welcome(); int main() { - int fps = 5; - - init(); + while(1) { + int fps = 6; + //initialise and show welcome menu + init(); + welcome(); + render(); + wait(1.0f/fps); - render(); - wait(1.0f/fps); - - while (1) { - tempest.read_input(pad); - tempest.update(); - render(); - wait(1.0f/fps); + while (1) { + tempest.read_input(pad); + tempest.update(); + render(); + wait(1.0f/fps); + + if (tempest.game_over() == 1) { + lcd.clear(); + lcd.printString(" Game Over! ",0,1); + lcd.printString(" Press Reset ",0,4); + lcd.refresh(); + wait(1); + while ( pad.A_pressed() == false) { + wait(0.1); + } + break; + } + } } } +//initialises everything needed void init() { lcd.init(); pad.init(); @@ -51,8 +67,21 @@ } +//game loop void render() { lcd.clear(); tempest.draw(lcd); lcd.refresh(); } + +//welcome screen +void welcome() { + + lcd.printString(" Tempest! ",0,1); + lcd.printString(" Press Start ",0,4); + lcd.refresh(); + + while ( pad.start_pressed() == false) { + wait(0.1); + } +} \ No newline at end of file