harry rance
/
Revised_Space_Invaders
Harry Rance 200925395 Embedded Systems Project
Diff: main.cpp
- Revision:
- 0:c9bf674fe0c7
- Child:
- 1:95d7dd44bb0d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 11 17:54:59 2017 +0000 @@ -0,0 +1,61 @@ +////////// pre-processor directives ////////// +#include "mbed.h" +#include "Gamepad.h" +#include "N5110.h" +#include "GameEngine.h" + +#define SHIELD_X 0 +#define SHIELD_Y 0 +#define US_X 0 +#define AA_X 2 +#define SPEED 1 + +////////// structs ////////// +struct UserInput { + Direction d; + float mag; +}; + +////////// objects ////////// +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +Gamepad pad; +GameEngine engine; + +////////// prototypes ////////// +void init(); +void render(); +void update_game(UserInput input); + +////////// functions ////////// +int main() +{ + int fps = 30; + + init(); + render(); + wait(1.0f/fps); + + while(1){ + engine.read_input(pad); + engine.update(pad); + render(); + wait(1.0f/fps); + } +} + +void render() +{ + lcd.clear(); + engine.draw(lcd); + lcd.refresh(); +} + +void init() +{ + lcd.init(); + pad.init(); + + engine.initialise(SHIELD_X, SHIELD_Y, US_X, AA_X, SPEED); + +} +