Adam Baker 201166301
Dependencies: mbed Gamepad N5110
main.cpp
- Committer:
- adambakerwa
- Date:
- 2019-04-08
- Revision:
- 20:54724f686c14
- Parent:
- 19:48d49a42037c
- Child:
- 21:f82573f3e40e
File content as of revision 20:54724f686c14:
#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 l = 0; int r = 0; int d2 = 0; int l2 = 0; int r2 = 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.onVerCheck(move, pos); r = runner.byVerCheckRight(move, pos); l = runner.byVerCheckLeft(move, pos); d2 = runner.onVer2Check(move, pos); r2 = runner.byVer2CheckRight(move, pos); l2 = runner.byVer2CheckLeft(move, pos); move = runner.onPlatform(lcd, move, d, r, l, d2, r2, l2); 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 %i %i",pos.vx, pos. vy, pos.vd, pos.vc, pos.vl); 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