ELEC2645 (2019/20)
/
ELEC2645_Project_el18jb
test 1 doc
main.cpp
- Committer:
- joebarhouch
- Date:
- 2020-05-26
- Revision:
- 7:530ca713d2b2
- Parent:
- 5:928c2eee4109
- Child:
- 11:b3024ab59fa5
File content as of revision 7:530ca713d2b2:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds 2019/20 Name: Joe Barhouch Username: el18jb Student ID Number: 201291584 */ // includes #include "mbed.h" #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() { init(); int fps = 10; // frames per second display(); // first draw the initial frame wait(1.0f/fps); // and wait for one frame period // game loop while (1) { lcd.setContrast( pad.read_pot1()); //contrast set by pot1 engine.read_input(pad); //reads input from pad engine.update(pad); //update physics and calculations display(); //display on screen wait(1.0f/fps); //wait for fps } } //initialisation void init() { lcd.init(); pad.init(); engine.init(); } //display function by clearing, updating and refreshing void display() { lcd.clear(); engine.draw(lcd); lcd.refresh(); }