ELEC2645 (2019/20)
/
ELEC2645_Project_el18jb
test 1 doc
Diff: main.cpp
- Revision:
- 3:e4e1cbf750b6
- Parent:
- 2:f22cb01c43bc
- Child:
- 4:cf5088ace087
--- a/main.cpp Fri Apr 10 19:07:13 2020 +0000 +++ b/main.cpp Mon May 18 16:06:27 2020 +0000 @@ -1,4 +1,4 @@ -/* +/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds @@ -7,7 +7,6 @@ Name: Joe Barhouch Username: el18jb Student ID Number: 201291584 -Date: */ // includes @@ -15,27 +14,59 @@ #include "Gamepad.h" #include "N5110.h" #include "Bitmap.h" - +#include "Player.h" +#include "Engine.h" // objects Gamepad pad; N5110 lcd; +Player player; +Engine engine; +// input +struct UserInput { + Direction d; + float mag; +}; + + + +// function prototypes void init(); +void display(); -int main(){ +int main() +{ + init(); - lcd.setContrast(0.5); - - while(1){ - lcd.clear(); - lcd.refresh(); + + int fps = 10; // frames per second + display(); // first draw the initial frame + wait(1.0f/fps); // and wait for one frame period + + // game loop - read input, update the game state and render the display + while (1) { + lcd.setContrast( pad.read_pot1()); + engine.read_input(pad); + engine.update(pad); + display(); + wait(1.0f/fps); } } -void init(){ +void init() +{ lcd.init(); pad.init(); - } + engine.init(); +} +void display() +{ + lcd.clear(); + engine.draw(lcd); + lcd.refresh(); +} + +