![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
main.cpp
- Committer:
- adambakerwa
- Date:
- 2019-04-21
- Revision:
- 24:f5dd1f3db693
- Parent:
- 23:4b1abf659467
- Child:
- 25:230e4163cb6b
File content as of revision 24:f5dd1f3db693:
#include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "Runner.h" #include "Levels.h" #include "Animation.h" N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; Runner runner; Animation ani; Levels lev; Ticker ticker; volatile int timer_flag = 0; void timer_isr(); int main() { int fps = 6; //6 pad.init(); lcd.init(); lcd.setContrast(0.55); Move move; Pos pos; move = runner.init(move); pos = lev.init(pos); ticker.attach(&timer_isr,1.0f/fps); int gameover = 0; while(1) { if (timer_flag == true) { timer_flag = 0; // if it has, clear the flag lcd.clear(); move = runner.nextLevel(move); pos = lev.whatLevel(lcd, move.l); move = runner.blockhead(move, pos, lcd, pad); gameover = runner.gameover(move, pos, lcd); lcd.refresh(); } else { sleep(); } } } void timer_isr() { timer_flag = 1; // set flag in ISR } //rtos /** char buffer[14]; sprintf(buffer,"%i", gameover); lcd.printString(buffer,0,0); */ //NEED TO RESET POS CORDS EACH NEW LEVEL TO PREVENT UNNECERSARRY GAME OVER (have fun x)