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: mbed
Diff: DodgeEngine/DodgeEngine.cpp
- Revision:
- 4:fe668b8cbd3e
- Parent:
- 2:d14bccec9948
--- a/DodgeEngine/DodgeEngine.cpp Wed May 27 10:27:15 2020 +0000
+++ b/DodgeEngine/DodgeEngine.cpp Wed May 27 13:49:48 2020 +0000
@@ -1,78 +0,0 @@
-#include "DodgeEngine.h"
-
-DodgeEngine::DodgeEngine(){
-//initialise score and boat position
- player_score = 0;
- y_boat = 24;
- x_boat = 76;
-
-}
-DodgeEngine::~DodgeEngine(){}
-
-//function which holds the games logic
-void DodgeEngine::logic(N5110 &lcd, Gamepad &pad)
-{
- draw_screen(lcd);
- player_movements(lcd, pad);
- boat_logic(lcd, pad);
-}
-//Function for the boats logic
-void DodgeEngine::boat_logic(N5110 &lcd, Gamepad &pad)
-{
-
- o1.set_y_boat(y_boat);
- o1.set_x_boat(x_boat);
- o1.sprite(lcd);
- boat_respawn(pad); //respawns the boat when it hits the other side of the screen
-}
-
-
-void DodgeEngine::draw_screen(N5110 &lcd)
-{
- lcd.clear();
- lcd.drawLine(0,7, 84,7,1); //Top edge of display
- lcd.drawLine(0,47, 83,47,1); //Bottom edge of display
- lcd.printString("Dodge the boat",1,0);
-}
-void DodgeEngine::player_movements(N5110 &lcd, Gamepad &pad)
-{
- swimmer.sprite(lcd);
- swimmer.get_x1();
- swimmer.get_y1();
- swimmer.movement(pad);
-
-}
-
-void DodgeEngine::boat_respawn(Gamepad &pad)
-{
- x_boat += -2; //boat speed
-
-//If statement which respawns boat (moves boat back to start of the screen)
- if(x_boat < 0) {
- x_boat = 76;
- player_score += 1;
- //y_boat gets a random position to move the boat back to
- y_boat = ((rand()%(48))+8);
- }
-}
-
-bool DodgeEngine::state(N5110 &lcd)
-{
- //checks if collision has occured and ends the game loop if it has
- if(cd.Collision(lcd, x_boat, y_boat)== 1) {
- return true;}
- else{return false;
- }
- }
-//Game over screen
-void DodgeEngine::game_over(N5110 &lcd, Gamepad &pad)
-{
-
- lcd.clear();
- lcd.printString("SMASH",30,1);
- lcd.printString("Score: ", 0,3);
- char score_buffer[14];
- sprintf(score_buffer,"%2d",player_score);
- lcd.printString(score_buffer,42,3);
- lcd.refresh();
-}
\ No newline at end of file