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:
- 21:32429d8e90ff
- Parent:
- 19:913d123554ee
- Child:
- 22:f1811602a817
--- a/main.cpp Sat May 09 10:53:46 2020 +0000 +++ b/main.cpp Tue May 12 15:12:59 2020 +0000 @@ -24,28 +24,27 @@ N5110 lcd; Menu menu(lcd,pad); - - //functions void initialise(); void game(); - //variables bool game_check = false; -bool game_playing = false; int pause_return_value = 0; int game_return_value = 2; string game_speed; -float extra_speed = 0.5; +float extra_speed = 0.05; int main() { initialise(); + //creates the inital screen menu.first_screen(); + //infinite game and menu loop while(1) { //menu menu.menu_screen(); + //checks the game speed setting game_speed = menu.get_game_speed(); if (game_speed == "fast"){ extra_speed = 0.0f; @@ -68,20 +67,22 @@ void game() { - + //creates class objects Objects objects; Functions functions; + + //runs the game engine while(game_check == false) { lcd.clear(); - objects.draw_shots(lcd,pad, true);// draws the shot + //creates the balls and clears the shots functions.ball_creater_linear(lcd, objects, pad); functions.ball_creater_parabolic(lcd,objects,pad); + objects.draw_shots(lcd,pad, true);//again draws the shots so they would be visible on the screen functions.collision_checker(lcd,objects);//cheks for the collisions - objects.draw_base(lcd);//draws the base of the game objects.cannon_position(pad);//changes the cannon postion objects.draw_cannon(lcd);//draws the cannon @@ -89,18 +90,20 @@ lcd.refresh(); wait(0.1 + extra_speed); + //added this so the cannon moves faster than the balls lcd.clear(); - //added this so the cannon moves faster than the balls objects.cannon_position(pad);//eveluates the cannon position objects.draw_cannon(lcd);//draws the cannon lcd.refresh(); wait(0.005); + //if a pressed display pause screen pause_return_value = menu.pause_screen(); if(pause_return_value == 1) { break; } } + if(pause_return_value == 0) { //prints the the score and game over game_return_value = menu.game_over_screen(functions.get_score());