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.
main.cpp@12:1f1907ebebeb, 2020-05-27 (annotated)
- Committer:
- MatisRequis
- Date:
- Wed May 27 05:53:03 2020 +0000
- Revision:
- 12:1f1907ebebeb
- Parent:
- 10:2ae9d4145410
Final Submission. I have read and agreed with Statement of Academic Integrity
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eencae | 0:b7f1f47bb26a | 1 | /* |
eencae | 0:b7f1f47bb26a | 2 | ELEC2645 Embedded Systems Project |
eencae | 0:b7f1f47bb26a | 3 | School of Electronic & Electrical Engineering |
eencae | 0:b7f1f47bb26a | 4 | University of Leeds |
eencae | 0:b7f1f47bb26a | 5 | 2019/20 |
eencae | 0:b7f1f47bb26a | 6 | |
MatisRequis | 1:03d1c29c2f8a | 7 | Name:Matis Requis |
MatisRequis | 1:03d1c29c2f8a | 8 | Username:el18mrjr |
MatisRequis | 1:03d1c29c2f8a | 9 | Student ID Number:201241242 |
MatisRequis | 1:03d1c29c2f8a | 10 | Date:20/04/20 |
eencae | 0:b7f1f47bb26a | 11 | */ |
eencae | 0:b7f1f47bb26a | 12 | |
eencae | 0:b7f1f47bb26a | 13 | // includes |
eencae | 0:b7f1f47bb26a | 14 | #include "mbed.h" |
eencae | 0:b7f1f47bb26a | 15 | #include "Gamepad.h" |
eencae | 0:b7f1f47bb26a | 16 | #include "N5110.h" |
MatisRequis | 2:d59a92e65bd9 | 17 | #include "TempestEngine.h" |
eencae | 0:b7f1f47bb26a | 18 | |
eencae | 0:b7f1f47bb26a | 19 | |
eencae | 0:b7f1f47bb26a | 20 | // objects |
eencae | 0:b7f1f47bb26a | 21 | Gamepad pad; |
eencae | 0:b7f1f47bb26a | 22 | N5110 lcd; |
MatisRequis | 2:d59a92e65bd9 | 23 | TempestEngine tempest; |
MatisRequis | 2:d59a92e65bd9 | 24 | |
MatisRequis | 10:2ae9d4145410 | 25 | //Objects |
MatisRequis | 2:d59a92e65bd9 | 26 | void init(); |
MatisRequis | 2:d59a92e65bd9 | 27 | void render(); |
MatisRequis | 10:2ae9d4145410 | 28 | void welcome(); |
MatisRequis | 2:d59a92e65bd9 | 29 | |
eencae | 0:b7f1f47bb26a | 30 | |
eencae | 0:b7f1f47bb26a | 31 | int main() |
eencae | 0:b7f1f47bb26a | 32 | { |
MatisRequis | 10:2ae9d4145410 | 33 | while(1) { |
MatisRequis | 10:2ae9d4145410 | 34 | int fps = 6; |
MatisRequis | 10:2ae9d4145410 | 35 | //initialise and show welcome menu |
MatisRequis | 10:2ae9d4145410 | 36 | init(); |
MatisRequis | 10:2ae9d4145410 | 37 | welcome(); |
MatisRequis | 10:2ae9d4145410 | 38 | render(); |
MatisRequis | 10:2ae9d4145410 | 39 | wait(1.0f/fps); |
MatisRequis | 2:d59a92e65bd9 | 40 | |
MatisRequis | 10:2ae9d4145410 | 41 | while (1) { |
MatisRequis | 10:2ae9d4145410 | 42 | tempest.read_input(pad); |
MatisRequis | 10:2ae9d4145410 | 43 | tempest.update(); |
MatisRequis | 10:2ae9d4145410 | 44 | render(); |
MatisRequis | 10:2ae9d4145410 | 45 | wait(1.0f/fps); |
MatisRequis | 10:2ae9d4145410 | 46 | |
MatisRequis | 10:2ae9d4145410 | 47 | if (tempest.game_over() == 1) { |
MatisRequis | 10:2ae9d4145410 | 48 | lcd.clear(); |
MatisRequis | 10:2ae9d4145410 | 49 | lcd.printString(" Game Over! ",0,1); |
MatisRequis | 10:2ae9d4145410 | 50 | lcd.printString(" Press Reset ",0,4); |
MatisRequis | 10:2ae9d4145410 | 51 | lcd.refresh(); |
MatisRequis | 10:2ae9d4145410 | 52 | wait(1); |
MatisRequis | 10:2ae9d4145410 | 53 | while ( pad.A_pressed() == false) { |
MatisRequis | 10:2ae9d4145410 | 54 | wait(0.1); |
MatisRequis | 10:2ae9d4145410 | 55 | } |
MatisRequis | 10:2ae9d4145410 | 56 | break; |
MatisRequis | 10:2ae9d4145410 | 57 | } |
MatisRequis | 10:2ae9d4145410 | 58 | } |
MatisRequis | 4:8e3ba8d6d915 | 59 | } |
eencae | 0:b7f1f47bb26a | 60 | } |
eencae | 0:b7f1f47bb26a | 61 | |
MatisRequis | 10:2ae9d4145410 | 62 | //initialises everything needed |
MatisRequis | 2:d59a92e65bd9 | 63 | void init() { |
MatisRequis | 2:d59a92e65bd9 | 64 | lcd.init(); |
MatisRequis | 2:d59a92e65bd9 | 65 | pad.init(); |
MatisRequis | 4:8e3ba8d6d915 | 66 | tempest.init(); |
MatisRequis | 4:8e3ba8d6d915 | 67 | |
MatisRequis | 2:d59a92e65bd9 | 68 | } |
MatisRequis | 2:d59a92e65bd9 | 69 | |
MatisRequis | 10:2ae9d4145410 | 70 | //game loop |
MatisRequis | 2:d59a92e65bd9 | 71 | void render() { |
MatisRequis | 2:d59a92e65bd9 | 72 | lcd.clear(); |
MatisRequis | 2:d59a92e65bd9 | 73 | tempest.draw(lcd); |
MatisRequis | 2:d59a92e65bd9 | 74 | lcd.refresh(); |
MatisRequis | 4:8e3ba8d6d915 | 75 | } |
MatisRequis | 10:2ae9d4145410 | 76 | |
MatisRequis | 10:2ae9d4145410 | 77 | //welcome screen |
MatisRequis | 10:2ae9d4145410 | 78 | void welcome() { |
MatisRequis | 10:2ae9d4145410 | 79 | |
MatisRequis | 10:2ae9d4145410 | 80 | lcd.printString(" Tempest! ",0,1); |
MatisRequis | 10:2ae9d4145410 | 81 | lcd.printString(" Press Start ",0,4); |
MatisRequis | 10:2ae9d4145410 | 82 | lcd.refresh(); |
MatisRequis | 10:2ae9d4145410 | 83 | |
MatisRequis | 10:2ae9d4145410 | 84 | while ( pad.start_pressed() == false) { |
MatisRequis | 10:2ae9d4145410 | 85 | wait(0.1); |
MatisRequis | 10:2ae9d4145410 | 86 | } |
MatisRequis | 10:2ae9d4145410 | 87 | } |