Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@15:fa5282fcd134, 2019-04-19 (annotated)
- Committer:
- el17mcd
- Date:
- Fri Apr 19 15:58:51 2019 +0000
- Revision:
- 15:fa5282fcd134
- Parent:
- 14:fe2e16cdf219
- Child:
- 16:a2c945279b79
! New Menus class that holds the menus for the game. Settings menu to toggle sound, change contrast and number of lives players start with.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17mcd | 2:8382613c86a0 | 1 | /* |
| el17mcd | 2:8382613c86a0 | 2 | ELEC2645 Embedded Systems Project |
| el17mcd | 2:8382613c86a0 | 3 | School of Electronic & Electrical Engineering |
| el17mcd | 2:8382613c86a0 | 4 | University of Leeds |
| el17mcd | 2:8382613c86a0 | 5 | Name: Maxim C. Delacoe |
| el17mcd | 2:8382613c86a0 | 6 | Username: EL 17 MCD |
| el17mcd | 2:8382613c86a0 | 7 | Student ID Number: 2011 58344 |
| el17mcd | 2:8382613c86a0 | 8 | Date: 19/03/2019 |
| el17mcd | 2:8382613c86a0 | 9 | */ |
| el17mcd | 2:8382613c86a0 | 10 | ///////// pre-processor directives //////// |
| el17mcd | 2:8382613c86a0 | 11 | #include "mbed.h" |
| el17mcd | 2:8382613c86a0 | 12 | #include "Gamepad.h" |
| el17mcd | 2:8382613c86a0 | 13 | #include "N5110.h" |
| el17mcd | 2:8382613c86a0 | 14 | #include "Bitmap.h" |
| el17mcd | 12:9e6d5d0a0c82 | 15 | #include "Tank.h" |
| el17mcd | 7:a3ccabdebe2e | 16 | #include "TanksEngine.h" |
| el17mcd | 7:a3ccabdebe2e | 17 | #include "Projectile.h" |
| el17mcd | 12:9e6d5d0a0c82 | 18 | #include "Graphics.h" |
| el17mcd | 15:fa5282fcd134 | 19 | #include "Menus.h" |
| el17mcd | 8:d4e419dad90f | 20 | #define PI 3.14159265 |
| el17mcd | 8:d4e419dad90f | 21 | #define DEG2PI 0.0174532925 |
| el17mcd | 2:8382613c86a0 | 22 | |
| el17mcd | 7:a3ccabdebe2e | 23 | #ifdef WITH_TESTING |
| el17mcd | 2:8382613c86a0 | 24 | |
| el17mcd | 7:a3ccabdebe2e | 25 | #endif |
| el17mcd | 7:a3ccabdebe2e | 26 | |
| el17mcd | 7:a3ccabdebe2e | 27 | /////////////// objects /////////////// |
| el17mcd | 7:a3ccabdebe2e | 28 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
| el17mcd | 7:a3ccabdebe2e | 29 | TanksEngine engine; |
| el17mcd | 11:4e2eb64031a0 | 30 | Gamepad pad; |
| el17mcd | 12:9e6d5d0a0c82 | 31 | Graphics graphics; |
| el17mcd | 15:fa5282fcd134 | 32 | Menus menus; |
| el17mcd | 2:8382613c86a0 | 33 | |
| el17mcd | 2:8382613c86a0 | 34 | int main() |
| el17mcd | 2:8382613c86a0 | 35 | { |
| el17mcd | 2:8382613c86a0 | 36 | lcd.init(); |
| el17mcd | 11:4e2eb64031a0 | 37 | pad.init(); |
| el17mcd | 11:4e2eb64031a0 | 38 | int fps = 60; |
| el17mcd | 11:4e2eb64031a0 | 39 | float frame_period_ms = 1000/fps; |
| el17mcd | 15:fa5282fcd134 | 40 | |
| el17mcd | 5:8a2e96f7fb4d | 41 | while(1) { // infinite loop |
| el17mcd | 11:4e2eb64031a0 | 42 | |
| el17mcd | 15:fa5282fcd134 | 43 | menus.start_up_screen(graphics, lcd, pad); |
| el17mcd | 15:fa5282fcd134 | 44 | menus.main_menu(graphics, lcd, pad); |
| el17mcd | 15:fa5282fcd134 | 45 | engine.initgame(menus); |
| el17mcd | 15:fa5282fcd134 | 46 | engine.game_loop(graphics, lcd, pad); |
| el17mcd | 15:fa5282fcd134 | 47 | |
| el17mcd | 15:fa5282fcd134 | 48 | /* lcd.clear(); |
| el17mcd | 13:feadff02d3f7 | 49 | engine.read_input(pad); |
| el17mcd | 15:fa5282fcd134 | 50 | graphics.draw_parkinson_map(31, 17, lcd); |
| el17mcd | 11:4e2eb64031a0 | 51 | if (engine.get_turn() == 1) { |
| el17mcd | 13:feadff02d3f7 | 52 | engine.left_tank_turn(graphics, pad); |
| el17mcd | 12:9e6d5d0a0c82 | 53 | } else if (engine.get_turn() == 2 || engine.get_turn() == 4) { |
| el17mcd | 15:fa5282fcd134 | 54 | engine.projectile_phase(lcd, pad); |
| el17mcd | 12:9e6d5d0a0c82 | 55 | } else if (engine.get_turn() == 3) { |
| el17mcd | 13:feadff02d3f7 | 56 | engine.right_tank_turn(graphics, pad); } |
| el17mcd | 15:fa5282fcd134 | 57 | engine.end(); |
| el17mcd | 12:9e6d5d0a0c82 | 58 | if (engine.get_turn() == 5) { |
| el17mcd | 12:9e6d5d0a0c82 | 59 | while (1) { |
| el17mcd | 12:9e6d5d0a0c82 | 60 | lcd.clear(); |
| el17mcd | 12:9e6d5d0a0c82 | 61 | engine.render(graphics, lcd); |
| el17mcd | 12:9e6d5d0a0c82 | 62 | lcd.refresh(); |
| el17mcd | 12:9e6d5d0a0c82 | 63 | } |
| el17mcd | 13:feadff02d3f7 | 64 | } |
| el17mcd | 12:9e6d5d0a0c82 | 65 | engine.render(graphics, lcd); |
| el17mcd | 8:d4e419dad90f | 66 | lcd.refresh(); |
| el17mcd | 15:fa5282fcd134 | 67 | wait_ms(frame_period_ms); */ |
| el17mcd | 8:d4e419dad90f | 68 | } |
| el17mcd | 8:d4e419dad90f | 69 | } |