Ben Evans University Second Year Project. Game Called Defender.
Hello, soldier, you have been specially selected as the defender of planet earth.
Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.
But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.
As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.
Diff: GameEngine/GameEngine.cpp
- Revision:
- 77:2ee9d1f9e282
- Parent:
- 76:6daba3002424
- Child:
- 79:66bcf8fa2d2d
--- a/GameEngine/GameEngine.cpp Sun May 24 18:38:50 2020 +0000 +++ b/GameEngine/GameEngine.cpp Sun May 24 19:20:23 2020 +0000 @@ -25,6 +25,7 @@ accelerometer.init(); saved.init(); setting.init(); + h_score.init(); //set first screen to main menu current_menu_part_= menu.get_current_menu_part(); @@ -226,9 +227,11 @@ //draws score/highscore part of screen char buffer[11]; sprintf(buffer,"Score = %d",points_); - lcd.printString(buffer,9,3); + lcd.printString(buffer,9,2); + h_score.set_error(false); - if(calculate_new_score()){ + //Prints new high score if a high score and no error + if(calculate_new_score()&& !h_score.get_error()){ lcd.printString("NEW HIGH SCORE",0,4); if(music_fx_ == music_on){ @@ -375,7 +378,31 @@ // Menu High score ------------------------------------------------------------- void GameEngine::run_highscore(){ + lcd.clear(); + lcd.printString("High Scores",9,0); + lcd.printString("Back(B)",21,5); + //sets error to false as may of become true from privuous error + h_score.set_error(false); + + //draws score/highscore part of screen + char buffer[11]; + sprintf(buffer,"Score = %d",h_score.read_high_score(sd)); + lcd.printString(buffer,9,3); + + // If error reading high score just say no high score or sd card + if (h_score.get_error()){ + h_score.no_high_scores(lcd); + wait(3); + current_menu_part_ = main_menu; + } + + //go back to main menu when b pressed + if (pad.B_pressed()){ + current_menu_part_ = main_menu; + } + + lcd.refresh(); } bool GameEngine::calculate_new_score(){ @@ -385,6 +412,7 @@ int saved_high_score = h_score.read_high_score(sd); if (points_ > saved_high_score){ new_high_score = true; + h_score.save_new_high_score(sd, lcd, points_); } return new_high_score; } @@ -468,7 +496,7 @@ // Stores bullet object in vector bullet_vector.push_back(new_bullet); } - bullet_timer_ = 5; + bullet_timer_ = 10; } bullet_timer_--; }