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@11:4e2eb64031a0, 2019-04-13 (annotated)
- Committer:
- el17mcd
- Date:
- Sat Apr 13 16:31:43 2019 +0000
- Revision:
- 11:4e2eb64031a0
- Parent:
- 10:d4fb12e9e7cd
- Child:
- 12:9e6d5d0a0c82
!Can take left tank's turn including movement and firing turret. This transitions into "projectile phase" which ends when the projectile goes out of bounds (off screen). Objects instantiated inside game engine to tidy main.cpp.
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 | 7:a3ccabdebe2e | 15 | #include "TankL.h" |
| el17mcd | 7:a3ccabdebe2e | 16 | #include "TanksEngine.h" |
| el17mcd | 7:a3ccabdebe2e | 17 | #include "Projectile.h" |
| el17mcd | 8:d4e419dad90f | 18 | #define PI 3.14159265 |
| el17mcd | 8:d4e419dad90f | 19 | #define DEG2PI 0.0174532925 |
| el17mcd | 2:8382613c86a0 | 20 | |
| el17mcd | 10:d4fb12e9e7cd | 21 | #include <cmath> |
| el17mcd | 10:d4fb12e9e7cd | 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 | 7:a3ccabdebe2e | 31 | |
| el17mcd | 2:8382613c86a0 | 32 | void welcome() |
| el17mcd | 2:8382613c86a0 | 33 | { |
| el17mcd | 2:8382613c86a0 | 34 | lcd.clear(); |
| el17mcd | 2:8382613c86a0 | 35 | lcd.printString(" ELEC 2645",0,0); |
| el17mcd | 2:8382613c86a0 | 36 | lcd.printString(" Game ",0,1); |
| el17mcd | 2:8382613c86a0 | 37 | lcd.printString(" Project",0,2); |
| el17mcd | 2:8382613c86a0 | 38 | lcd.printString("Max C. Delacoe",0,4); |
| el17mcd | 2:8382613c86a0 | 39 | lcd.printString(" 2011 58344",0,5); |
| el17mcd | 2:8382613c86a0 | 40 | lcd.refresh(); |
| el17mcd | 2:8382613c86a0 | 41 | wait(0.2); |
| el17mcd | 2:8382613c86a0 | 42 | } |
| el17mcd | 2:8382613c86a0 | 43 | |
| el17mcd | 2:8382613c86a0 | 44 | int main() |
| el17mcd | 2:8382613c86a0 | 45 | { |
| el17mcd | 2:8382613c86a0 | 46 | lcd.init(); |
| el17mcd | 11:4e2eb64031a0 | 47 | pad.init(); |
| el17mcd | 11:4e2eb64031a0 | 48 | engine.initgame(); |
| el17mcd | 11:4e2eb64031a0 | 49 | int fps = 60; |
| el17mcd | 11:4e2eb64031a0 | 50 | float frame_period_ms = 1000/fps; |
| el17mcd | 10:d4fb12e9e7cd | 51 | |
| el17mcd | 3:087b28bf8b96 | 52 | // welcome(); // display welcome message |
| el17mcd | 2:8382613c86a0 | 53 | |
| el17mcd | 5:8a2e96f7fb4d | 54 | while(1) { // infinite loop |
| el17mcd | 11:4e2eb64031a0 | 55 | |
| el17mcd | 11:4e2eb64031a0 | 56 | lcd.clear(); |
| el17mcd | 11:4e2eb64031a0 | 57 | if (engine.get_turn() == 1) { |
| el17mcd | 11:4e2eb64031a0 | 58 | engine.left_tank_turn(pad, lcd); |
| el17mcd | 11:4e2eb64031a0 | 59 | } else if (engine.get_turn() == 2) { |
| el17mcd | 11:4e2eb64031a0 | 60 | engine.projectile_phase(lcd); |
| el17mcd | 11:4e2eb64031a0 | 61 | } else { int turn = 3; }// means nothing |
| el17mcd | 8:d4e419dad90f | 62 | lcd.refresh(); |
| el17mcd | 10:d4fb12e9e7cd | 63 | wait_ms(16.666); |
| el17mcd | 11:4e2eb64031a0 | 64 | |
| el17mcd | 10:d4fb12e9e7cd | 65 | |
| el17mcd | 8:d4e419dad90f | 66 | } |
| el17mcd | 11:4e2eb64031a0 | 67 | /* |
| el17mcd | 8:d4e419dad90f | 68 | lcd.clear(); |
| el17mcd | 8:d4e419dad90f | 69 | lcd.printString("DONE",0,1); |
| el17mcd | 8:d4e419dad90f | 70 | lcd.refresh(); |
| el17mcd | 11:4e2eb64031a0 | 71 | wait(10);*/ |
| el17mcd | 8:d4e419dad90f | 72 | } |