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.
Diff: main.cpp
- Revision:
- 4:0e01cbb95434
- Parent:
- 3:fe856d0890ee
- Child:
- 5:12c179da4788
diff -r fe856d0890ee -r 0e01cbb95434 main.cpp --- a/main.cpp Sat Mar 23 11:17:33 2019 +0000 +++ b/main.cpp Sat Mar 23 12:07:33 2019 +0000 @@ -26,6 +26,8 @@ #include "PlayerControl.h" #include "Ball.h" +const int fps = 10; //sets the fps of the game doesn't change + /////////////// objects /////////////// N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // K64F - pwr from 3V3 Gamepad pad; // Gamepad buttons @@ -40,21 +42,9 @@ ///////////// functions //////////////// int main() { - int fps = 10; init(); welcome(); // waiting for the user to start - while(1) - { - render(); - wait(1.0f/fps); - if (ball.endCondition(pad)) - { - break; - } - } - lcd.clear(); - lcd.printString("You Lose",20,3); - lcd.refresh(); + render(); } void init() @@ -88,13 +78,18 @@ } void render() { - lcd.clear(); // initialise the LCD - cont.drawPlayer(lcd); - cont.controlPlayer(pad); - cont.get_padPos(pad); - ball.drawBall(lcd); - ball.get_ballPos(pad); - ball.moveBall(); - ball.hitPad(pad); - lcd.refresh(); + while(1) + { + lcd.clear(); // initialise the LCD + cont.drawPlayer(lcd); + cont.controlPlayer(pad); + cont.get_padPos(pad); + ball.drawBall(lcd); + ball.get_ballPos(pad); + ball.moveBall(); + ball.hitPad(pad); + lcd.refresh(); + ball.endCondition(pad, lcd); + wait(1.0f/fps); + } } \ No newline at end of file