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.
Revision 87:832ca78426b5, committed 2020-05-27
- Comitter:
- evanso
- Date:
- Wed May 27 02:06:05 2020 +0000
- Parent:
- 86:eecd168c3a23
- Commit message:
- Final Submission. I have read and agreed with Statement of Academic Integrity.
Changed in this revision
diff -r eecd168c3a23 -r 832ca78426b5 Alien/Alien.cpp --- a/Alien/Alien.cpp Wed May 27 00:32:04 2020 +0000 +++ b/Alien/Alien.cpp Wed May 27 02:06:05 2020 +0000 @@ -56,7 +56,8 @@ // Move alien to top of screen if a collision with person if (alien_collision) { - random_direction_ = 6; + random_direction_ = 6; + random_move_counter_ = 42; alien_collision = false; }else{ @@ -64,6 +65,8 @@ } } + // Stop alien going of map + off_screen_x_y_checker(map_length_, position_x_map_); // Move alien not tracking spaceship move randomly if (!track_flag_) { @@ -75,9 +78,6 @@ random_move_counter_ --; alien_fire_counter_++; } - // Stop alien going of map - off_screen_x_y_checker(map_length_, position_x_map_); - alien_move_counter_++; lcd.drawSprite(position_x_, position_y_, SPRITE_Y_LENGTH, SPRITE_X_LENGTH, (int*)k_alien_sprite);
diff -r eecd168c3a23 -r 832ca78426b5 GameEngine/GameEngine.cpp --- a/GameEngine/GameEngine.cpp Wed May 27 00:32:04 2020 +0000 +++ b/GameEngine/GameEngine.cpp Wed May 27 02:06:05 2020 +0000 @@ -68,6 +68,7 @@ void GameEngine::run_menu() { lcd.setContrast(pad.read_pot1()); lcd.clear(); + pad.reset_buttons(); // Scrolls, draws and selects menu parts read_joystick_direction(); @@ -91,7 +92,8 @@ if (current_menu_part_ == play) { play_init(); } - + + pad.reset_buttons(); lcd.refresh(); } @@ -135,6 +137,7 @@ // Break out of run play loop when lives = 0 or exited flag set if (!spaceship_lives_||exit_flag_) { + // Only draw game over screen if run out of lives if (!spaceship_lives_) { draw_game_over_screen(); } @@ -148,8 +151,7 @@ sleep(); } play_music(); - // Stop double press of A - wait(0.4); + wait(0.3); } void GameEngine::play_select(){
diff -r eecd168c3a23 -r 832ca78426b5 GameEngine/PlayEngine_test.h --- a/GameEngine/PlayEngine_test.h Wed May 27 00:32:04 2020 +0000 +++ b/GameEngine/PlayEngine_test.h Wed May 27 02:06:05 2020 +0000 @@ -77,7 +77,7 @@ bool create_explosion_test(int expected_explosion_num) { // Objects required for test PlayEngine engine; - + GameEngine GameEngine; Vector2D pos = {5,4}; printf("Create_explosion : "); @@ -98,36 +98,6 @@ } } -bool draw_explosions_test(int expected_pixel_status, int expected_postion_x, -int expected_postion_y) { - // Objects required for test - PlayEngine engine; - Gamepad pad; - N5110 lcd; - - printf("Draw_explosion : "); - - // Set explosion position - Vector2D pos = {expected_postion_x,expected_postion_y}; - engine.create_explosion(pos); - - engine.draw_explosions(); - - // Get pixel status - int actual_pixel_status = lcd.getPixel(expected_postion_x+3, - expected_postion_y+3); - - // Checks if pixel is drawn and therefor testing it hasn’t gone of screen - if (actual_pixel_status == expected_pixel_status) { - printf ( "Passed!\n"); - return true; - } else { - printf ( "Failed! value = %d (expecting %d)\n", - actual_pixel_status, expected_pixel_status); - return false; - } -} - bool spawn_people_test(int expected_people_num) { // Objects required for test PlayEngine engine; @@ -153,6 +123,7 @@ bool create_people_test(int expected_people_num) { // Objects required for test PlayEngine engine; + printf("create_people : "); //spawn number of expected aliens @@ -197,6 +168,7 @@ // Objects required for test PlayEngine engine; + printf("reset_map_ : "); // Create object for map functions
diff -r eecd168c3a23 -r 832ca78426b5 HighScore/HighScore.cpp --- a/HighScore/HighScore.cpp Wed May 27 00:32:04 2020 +0000 +++ b/HighScore/HighScore.cpp Wed May 27 02:06:05 2020 +0000 @@ -32,12 +32,12 @@ // Runs test with all different possible inputs if (save_test(4, sd, lcd)) passed_counter++; if (save_test(3, sd, lcd)) passed_counter++; - if (save_test(0, sd, lcd)) passed_counter++; + if (save_test(250, sd, lcd)) passed_counter++; if (save_test(-3, sd, lcd)) passed_counter++; if (save_test(222, sd, lcd)) passed_counter++; if (save_test(9999, sd, lcd)) passed_counter++; if (save_test(-9999, sd, lcd)) passed_counter++; - if (save_test(250, sd, lcd)) passed_counter++; + if (save_test(0, sd, lcd)) passed_counter++; // prints results printf ("\n high_score_save_test %d tests out of 8\n\n\n",
diff -r eecd168c3a23 -r 832ca78426b5 main.cpp --- a/main.cpp Wed May 27 00:32:04 2020 +0000 +++ b/main.cpp Wed May 27 02:06:05 2020 +0000 @@ -92,7 +92,6 @@ run_spawn_aliens_test(); run_create_alien_test(); run_create_explosion_test(); - run_draw_explosions_test(); run_spawn_people_test(); run_reset_map_timer_test(); run_reset_map_test();
diff -r eecd168c3a23 -r 832ca78426b5 test.h --- a/test.h Wed May 27 00:32:04 2020 +0000 +++ b/test.h Wed May 27 02:06:05 2020 +0000 @@ -465,21 +465,6 @@ printf ("\ncreate_explosion_test() %d tests out of 5\n\n\n" ,passed_counter); } -void run_draw_explosions_test() { - printf ("\ndraw_explosions_test() \n\n"); - int passed_counter = 0; - - // Runs test with all different possible inputs - if (draw_explosions_test(1,32,33)) passed_counter++; - if (draw_explosions_test(0,100,20)) passed_counter++; - if (draw_explosions_test(1,1,20)) passed_counter++; - if (draw_explosions_test(1,1,44)) passed_counter++; - if (draw_explosions_test(1,78,1)) passed_counter++; - - // Prints results - printf ("\ncreate_explosion_test() %d tests out of 5\n\n\n" - ,passed_counter); -} void run_spawn_people_test() { printf ("\nspawn_people_test() \n\n");