Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 mbed PowerControl
Diff: main.cpp
- Revision:
- 17:7c926de79e02
- Parent:
- 14:f5760f76fe83
- Child:
- 18:0e8b1cc24706
--- a/main.cpp Tue May 05 11:57:46 2015 +0000 +++ b/main.cpp Tue May 05 13:20:23 2015 +0000 @@ -10,46 +10,41 @@ int main() { - lcd.Initialize(); + lcd.Initialize(); lcd.displayStartScreen(); - while(!isRight()) {} //wait until right button pressed + while(!isRight()) {} //wait until right button pressed - wait(0.5); //just to ignore layover from first button. + wait(0.5); //just to ignore layover from first button press. lcd.displayInstructionScreen(); while(!isRight()) {} //wait until right button pressed. lcd.displayCountdown(); lcd.clear(); - leds = 1; - bool refresh = false; lcd.drawAllPlatforms(); lcd.drawBall(); lcd.refresh(); - gameClock.attach(&clockCounter,0.003); + gameClock.attach(&clockCounter,0.003); //attach the master clock! //MAIN GAME LOOP //multiple runs on a single loop. stop with a bool char buffer[10]; while(true) { - if (isFirstCheck) { - if(clockCount %(gameSpeed) == 0) { - - if (gameLevel > 60) - advancePlatforms(2); - else - advancePlatforms(1); + if (isFirstCheck) { //if first time checking this clock cycle. + if(clockCount %(gameSpeed) == 0) { + //advance platforms + advancePlatforms(1); refresh = true; } if(clockCount%10 == 0) { - //check if moving left will move you into platform. - if (isLeft() && isBallDirClear(1)) { + //ball movement + if (isLeft() && isBallDirClear(1)) { //if josystick left and direction is clear lcd.eraseBall(); lcd.setBallPos(lcd.getBallX()+2,lcd.getBallY()); refresh = true; @@ -60,7 +55,8 @@ refresh = true; } - if(isBallFalling(lcd.getBallY())) { + //if the ball is in free space, animate it falling! + if(isBallFalling(lcd.getBallY())) { lcd.eraseBall(); lcd.setBallPos(lcd.getBallX(),lcd.getBallY() + 1); refresh = true;