![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 24:f5dd1f3db693
- Parent:
- 23:4b1abf659467
- Child:
- 25:230e4163cb6b
--- a/main.cpp Wed Apr 17 13:35:39 2019 +0000 +++ b/main.cpp Sun Apr 21 18:17:20 2019 +0000 @@ -22,28 +22,19 @@ { int fps = 6; //6 - int d = 0 ; // direction of moving plats - int l = 0; //length - int r = 0; - int d2 = 0; - int l2 = 0; - int r2 = 0; - int d3 = 0; - int d4 = 0; - int g = 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); + int gameover = 0; while(1) { @@ -52,67 +43,12 @@ 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, d3, d4); - - 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, d3, d4); //what state runner is in (must come after next level + move = runner.nextLevel(move); + pos = lev.whatLevel(lcd, move.l); + move = runner.blockhead(move, pos, lcd, pad); + gameover = runner.gameover(move, pos, lcd); - //runner.whatLevel(move, lcd); // call level(why again)?? - d = runner.onHozCheck(move, pos); - - r = runner.byHozCheckRight(move, pos); - - l = runner.byHozCheckLeft(move, pos); - - d2 = runner.onHoz2Check(move, pos); - - r2 = runner.byHoz2CheckRight(move, pos); - - l2 = runner.byHoz2CheckLeft(move, pos); - - d3 = runner.onVerCheck(move, pos); - - d4 = runner.onVer2Check(move, pos); - - g = runner.crushedByVer(move, pos); - - g = g + runner.crushedByVer2(move, pos); - - g = g + runner.spikeHit(lcd, pos); - - - - move = runner.onPlatform(lcd, move, d, r, l, d2, r2, l2, d3, d4); - - - char buffer[14]; - sprintf(buffer,"%i", g); - 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); - */ - lcd.refresh(); } else { @@ -132,5 +68,9 @@ //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)