![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 14:d8ced73dbb83
- Parent:
- 13:35a459a33bbd
- Child:
- 15:c4de6874aa19
--- a/main.cpp Mon Mar 25 11:01:43 2019 +0000 +++ b/main.cpp Sun Mar 31 19:07:25 2019 +0000 @@ -20,7 +20,7 @@ int main() { - int fps = 2; + int fps = 10; pad.init(); lcd.init(); @@ -34,49 +34,51 @@ while(1) { - lcd.clear(); + if (timer_flag == true) { - float speed = runner.getSpeed(pad); + timer_flag = 0; // if it has, clear the flag - move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen + lcd.clear(); - runner.whatLevel(move, lcd); + float speed = runner.getSpeed(pad); + + move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen - move = runner.buttonPress(move, lcd, pad); + runner.whatLevel(move, lcd); - move = runner.jump(move, lcd); + move = runner.buttonPress(move, lcd, pad); - move = runner.wallJumpL(move, lcd, speed); + move = runner.jump(move, lcd); + + move = runner.wallJumpL(move, lcd, speed); - move = runner.wallJumpR(move, lcd, speed); + move = runner.wallJumpR(move, lcd, speed); - move = runner.runLeft(move, lcd, speed); + move = runner.runLeft(move, lcd, speed); - move = runner.runRight(move, lcd, speed); + move = runner.runRight(move, lcd, speed); - move = runner.fall(move, lcd); + move = runner.fall(move, lcd); - move = runner.runnerState(move, lcd, speed); //what state runner is in (must come after next level + move = runner.runnerState(move, lcd, speed); //what state runner is in (must come after next level - runner.whatLevel(move, lcd); // call level + runner.whatLevel(move, lcd); // call level - - char buffer[14]; - sprintf(buffer,"%i",move.cr); - lcd.printString(buffer,0,1); - //sleep(); //sleep untill next refresh + char buffer[14]; + sprintf(buffer,"%i",move.cr); + lcd.printString(buffer,0,1); - if (timer_flag == true) { - timer_flag = 0; // if it has, clear the flag + //sleep(); //sleep untill next refresh lcd.refresh(); + } else { + + sleep(); + } - - sleep(); - } }