![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
main.cpp
- Committer:
- adambakerwa
- Date:
- 2019-04-02
- Revision:
- 18:0a0976faedfb
- Parent:
- 17:ecbafe932c19
- Child:
- 19:48d49a42037c
File content as of revision 18:0a0976faedfb:
#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 int d = 0 ; // direction of moving plats int d2 = 0; 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); while(1) { if (timer_flag == true) { timer_flag = 0; // if it has, clear the flag lcd.clear(); float speed = runner.getSpeed(pad); move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen pos = lev.whatLevel(lcd, move.l); move = runner.buttonPress(move, lcd, pad); move = runner.jump(move, lcd); move = runner.wallJumpL(move, lcd, speed); move = runner.wallJumpR(move, lcd, speed); move = runner.runLeft(move, lcd, speed); move = runner.runRight(move, lcd, speed); move = runner.cancelSprint(move, lcd, speed); move = runner.fall(move, lcd); move = runner.runnerState(move, lcd, speed); //what state runner is in (must come after next level //runner.whatLevel(move, lcd); // call level(why again)?? d = runner.onPlatformCheck(move, pos); d2 = runner.onPlatform2Check(move, pos); move = runner.onPlatform(lcd, move, d, d2); char buffer[14]; sprintf(buffer,"%i %i %i %i %i" ,pos.x, pos.y, pos.d, pos.c, pos.l); lcd.printString(buffer,0,0); char buffer1[14]; sprintf(buffer1,"%i %i %i",move.x, move.y, d); lcd.printString(buffer1,0,1); //sleep(); //sleep untill next refresh lcd.refresh(); } else { sleep(); } } } void timer_isr() { timer_flag = 1; // set flag in ISR } //rtos