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.
main.cpp
- Committer:
- thestudent
- Date:
- 2020-05-09
- Revision:
- 19:913d123554ee
- Parent:
- 18:8f7291885e19
- Child:
- 21:32429d8e90ff
File content as of revision 19:913d123554ee:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds 2019/20 Name:Arturs Kolovskis Username:el18ak Student ID Number: 201253737 Date:08.03.2020 */ // includes #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "Objects.h" #include "Functions.h" #include "Menu.h" // objects Gamepad pad; 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; int main() { initialise(); menu.first_screen(); while(1) { //menu menu.menu_screen(); game_speed = menu.get_game_speed(); if (game_speed == "fast"){ extra_speed = 0.0f; }else{ //decreasesn the speed extra_speed = 0.05f; } //create the game game(); } } void initialise() { pad.init();//initialises the gamepad lcd.init();//initialises the N5110 screen lcd.clear(); } void game() { Objects objects; Functions functions; 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 game_check = functions.cannon_smash(lcd, objects); //checks if the cannon has been hit by a ball lcd.refresh(); wait(0.1 + extra_speed); 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); 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()); if (game_return_value == 2) { game_check = false; } } }