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@8:b3738229ba85, 2019-05-04 (annotated)
- Committer:
- batJoro
- Date:
- Sat May 04 22:46:31 2019 +0000
- Revision:
- 8:b3738229ba85
- Parent:
- 7:9e9424f5ec4b
- Child:
- 9:dc13042b09f5
engine3
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| batJoro | 1:3183193cf44e | 1 | |
| batJoro | 0:a0dedca5e89f | 2 | |
| batJoro | 0:a0dedca5e89f | 3 | /* |
| batJoro | 0:a0dedca5e89f | 4 | ELEC2645 Embedded Systems Project |
| batJoro | 0:a0dedca5e89f | 5 | School of Electronic & Electrical Engineering University of Leeds |
| batJoro | 0:a0dedca5e89f | 6 | |
| batJoro | 0:a0dedca5e89f | 7 | Name: Dobri Tsvetkov |
| batJoro | 0:a0dedca5e89f | 8 | Username: el17dtt |
| batJoro | 0:a0dedca5e89f | 9 | Student ID Number: 201154059 |
| batJoro | 0:a0dedca5e89f | 10 | Date: 12.03.2019 |
| batJoro | 0:a0dedca5e89f | 11 | */ |
| batJoro | 0:a0dedca5e89f | 12 | |
| batJoro | 3:f686f6d7bdff | 13 | |
| batJoro | 5:5e92567d0a44 | 14 | #include "mbed.h" |
| batJoro | 5:5e92567d0a44 | 15 | #include "Gamepad.h" |
| batJoro | 5:5e92567d0a44 | 16 | #include "N5110.h" |
| batJoro | 5:5e92567d0a44 | 17 | #include "menu.h" |
| batJoro | 6:4c55dd4b6d42 | 18 | #include "engine.h" |
| batJoro | 6:4c55dd4b6d42 | 19 | |
| batJoro | 6:4c55dd4b6d42 | 20 | |
| batJoro | 5:5e92567d0a44 | 21 | |
| batJoro | 3:f686f6d7bdff | 22 | /////////////// structs ///////////////// |
| batJoro | 3:f686f6d7bdff | 23 | |
| batJoro | 3:f686f6d7bdff | 24 | |
| batJoro | 3:f686f6d7bdff | 25 | /////////////// objects /////////////// |
| batJoro | 3:f686f6d7bdff | 26 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
| batJoro | 1:3183193cf44e | 27 | Gamepad gamepad; |
| batJoro | 8:b3738229ba85 | 28 | Engine engine; |
| batJoro | 1:3183193cf44e | 29 | |
| batJoro | 3:f686f6d7bdff | 30 | ///////////// prototypes /////////////// |
| batJoro | 4:2deeeeb6c1e1 | 31 | void init(); |
| batJoro | 4:2deeeeb6c1e1 | 32 | void welcome(); |
| batJoro | 6:4c55dd4b6d42 | 33 | void render(); |
| batJoro | 3:f686f6d7bdff | 34 | |
| batJoro | 3:f686f6d7bdff | 35 | ///////////// functions //////////////// |
| batJoro | 0:a0dedca5e89f | 36 | int main() { |
| batJoro | 0:a0dedca5e89f | 37 | |
| batJoro | 8:b3738229ba85 | 38 | int fps = 8; // frames per second |
| batJoro | 8:b3738229ba85 | 39 | |
| batJoro | 4:2deeeeb6c1e1 | 40 | init(); |
| batJoro | 1:3183193cf44e | 41 | |
| batJoro | 6:4c55dd4b6d42 | 42 | welcome(); |
| batJoro | 6:4c55dd4b6d42 | 43 | |
| batJoro | 6:4c55dd4b6d42 | 44 | // game loop - read input, update the game state and render the display |
| batJoro | 6:4c55dd4b6d42 | 45 | while(1) { |
| batJoro | 8:b3738229ba85 | 46 | // engine.read_input(gamepad); |
| batJoro | 8:b3738229ba85 | 47 | engine.update(gamepad, lcd); |
| batJoro | 6:4c55dd4b6d42 | 48 | render(); |
| batJoro | 8:b3738229ba85 | 49 | wait(1.0f/fps); |
| batJoro | 4:2deeeeb6c1e1 | 50 | } |
| batJoro | 4:2deeeeb6c1e1 | 51 | } |
| batJoro | 3:f686f6d7bdff | 52 | |
| batJoro | 8:b3738229ba85 | 53 | |
| batJoro | 4:2deeeeb6c1e1 | 54 | // initialies all classes and libraries |
| batJoro | 4:2deeeeb6c1e1 | 55 | void init() |
| batJoro | 4:2deeeeb6c1e1 | 56 | { |
| batJoro | 6:4c55dd4b6d42 | 57 | |
| batJoro | 8:b3738229ba85 | 58 | // need to initialise LCD and Gamepad and Engine |
| batJoro | 4:2deeeeb6c1e1 | 59 | lcd.init(); |
| batJoro | 4:2deeeeb6c1e1 | 60 | gamepad.init(); |
| batJoro | 8:b3738229ba85 | 61 | |
| batJoro | 8:b3738229ba85 | 62 | // init the engine and start the game at 0 speed |
| batJoro | 8:b3738229ba85 | 63 | engine.init(48 , 84, 0); |
| batJoro | 8:b3738229ba85 | 64 | |
| batJoro | 4:2deeeeb6c1e1 | 65 | gamepad.leds_on(); |
| batJoro | 4:2deeeeb6c1e1 | 66 | lcd.setContrast(0.4); |
| batJoro | 4:2deeeeb6c1e1 | 67 | } |
| batJoro | 6:4c55dd4b6d42 | 68 | // function to call the intro method of the menu class |
| batJoro | 4:2deeeeb6c1e1 | 69 | void welcome() { |
| batJoro | 4:2deeeeb6c1e1 | 70 | |
| batJoro | 4:2deeeeb6c1e1 | 71 | Menu menu; |
| batJoro | 8:b3738229ba85 | 72 | //menu.intro(lcd, gamepad); |
| batJoro | 8:b3738229ba85 | 73 | while (menu.startMainMenu(lcd, gamepad) == 1) { |
| batJoro | 8:b3738229ba85 | 74 | //menu.displayControls(lcd, gamepad); |
| batJoro | 8:b3738229ba85 | 75 | }; |
| batJoro | 6:4c55dd4b6d42 | 76 | } |
| batJoro | 6:4c55dd4b6d42 | 77 | // this function draws each frame on the LCD |
| batJoro | 6:4c55dd4b6d42 | 78 | void render() { |
| batJoro | 6:4c55dd4b6d42 | 79 | |
| batJoro | 6:4c55dd4b6d42 | 80 | lcd.clear(); |
| batJoro | 8:b3738229ba85 | 81 | //engine.draw(lcd); |
| batJoro | 6:4c55dd4b6d42 | 82 | lcd.refresh(); |
| batJoro | 0:a0dedca5e89f | 83 | } |