Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

https://os.mbed.com/media/uploads/evanso/84bc1a30759fd6a1e3f1fd1fae3e97c2.png

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.

Committer:
evanso
Date:
Wed May 27 02:06:05 2020 +0000
Revision:
87:832ca78426b5
Parent:
85:87bc28b151d8
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 67:a2984682d641 1 #ifndef SAVEDGAMES_TEST_H
evanso 67:a2984682d641 2 #define SAVEDGAMES_TEST_H
evanso 67:a2984682d641 3
evanso 67:a2984682d641 4 /** Saved Games Test
evanso 85:87bc28b151d8 5 * @brief Checks saved screen scrolls and draws properly
evanso 67:a2984682d641 6 * @author Benjamin Evans, University of Leeds
evanso 67:a2984682d641 7 * @date May 2020
evanso 67:a2984682d641 8 * @return true if test are passed
evanso 67:a2984682d641 9 */
evanso 82:3211b31e9421 10 bool saved_games_scroll_test(Direction d_, int expected_display_data_number) {
evanso 67:a2984682d641 11 // Objects reqired for test
evanso 67:a2984682d641 12 SavedGames saved;
evanso 67:a2984682d641 13
evanso 67:a2984682d641 14 // Initialise the menu
evanso 67:a2984682d641 15 saved.init();
evanso 67:a2984682d641 16
evanso 67:a2984682d641 17 printf("Expected display number %d : ",expected_display_data_number);
evanso 67:a2984682d641 18
evanso 67:a2984682d641 19 saved.saved_games_scroll(d_);
evanso 67:a2984682d641 20
evanso 67:a2984682d641 21 int actual_display_data_number = saved.get_display_data_number();
evanso 67:a2984682d641 22
evanso 67:a2984682d641 23 // Gets the current menu part and checks if it is the expected menu part
evanso 67:a2984682d641 24 if (actual_display_data_number == expected_display_data_number) {
evanso 67:a2984682d641 25 printf ( "Passed!\n");
evanso 67:a2984682d641 26 return true;
evanso 67:a2984682d641 27 } else {
evanso 67:a2984682d641 28 printf ( "Failed! %d (expecting %d,)\n", actual_display_data_number,
evanso 67:a2984682d641 29 expected_display_data_number);
evanso 67:a2984682d641 30 return false;
evanso 67:a2984682d641 31 }
evanso 67:a2984682d641 32 }
evanso 67:a2984682d641 33
evanso 67:a2984682d641 34 bool display_saved_games_test(int expected_pixel_status, int expected_postion_x,
evanso 82:3211b31e9421 35 int expected_postion_y) {
evanso 67:a2984682d641 36
evanso 85:87bc28b151d8 37 // Objects required for test
evanso 67:a2984682d641 38 SavedGames saved;
evanso 67:a2984682d641 39 N5110 lcd;
evanso 67:a2984682d641 40
evanso 67:a2984682d641 41 // Initialise save and lcd
evanso 67:a2984682d641 42 saved.init();
evanso 67:a2984682d641 43 lcd.init();
evanso 67:a2984682d641 44
evanso 67:a2984682d641 45 printf("save_game_screen x,y = %d,%d : ",expected_postion_x,
evanso 67:a2984682d641 46 expected_postion_y );
evanso 67:a2984682d641 47
evanso 67:a2984682d641 48 saved.display_saved_games(lcd);
evanso 67:a2984682d641 49
evanso 67:a2984682d641 50 // Reads pixel where hud is expected to be drawn
evanso 67:a2984682d641 51 int actual_pixel_status = lcd.getPixel(expected_postion_x,
evanso 67:a2984682d641 52 expected_postion_y);
evanso 67:a2984682d641 53
evanso 67:a2984682d641 54 // Checks if pixel is drawn and therefor testing it hasnt gone of screen
evanso 67:a2984682d641 55 if (actual_pixel_status == expected_pixel_status) {
evanso 67:a2984682d641 56 printf ( "Passed!\n");
evanso 67:a2984682d641 57 return true;
evanso 67:a2984682d641 58 } else {
evanso 67:a2984682d641 59 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
evanso 67:a2984682d641 60 expected_pixel_status);
evanso 67:a2984682d641 61 return false;
evanso 67:a2984682d641 62 }
evanso 67:a2984682d641 63 }
evanso 67:a2984682d641 64
evanso 67:a2984682d641 65 bool save_game_screen_test(int expected_pixel_status, int expected_postion_x,
evanso 82:3211b31e9421 66 int expected_postion_y) {
evanso 67:a2984682d641 67
evanso 85:87bc28b151d8 68 // Objects required for test
evanso 67:a2984682d641 69 SavedGames saved;
evanso 67:a2984682d641 70 N5110 lcd;
evanso 67:a2984682d641 71
evanso 67:a2984682d641 72 // Initialise save and lcd
evanso 67:a2984682d641 73 saved.init();
evanso 67:a2984682d641 74 lcd.init();
evanso 67:a2984682d641 75
evanso 67:a2984682d641 76 printf("save_game_screen x,y = %d,%d : ",expected_postion_x,
evanso 67:a2984682d641 77 expected_postion_y );
evanso 67:a2984682d641 78
evanso 67:a2984682d641 79 saved.save_game_screen(lcd);
evanso 67:a2984682d641 80
evanso 67:a2984682d641 81 // Reads pixel where hud is expected to be drawn
evanso 67:a2984682d641 82 int actual_pixel_status = lcd.getPixel(expected_postion_x,
evanso 67:a2984682d641 83 expected_postion_y);
evanso 67:a2984682d641 84
evanso 85:87bc28b151d8 85 // Checks if pixel is drawn and therefor testing it hasn’t gone of screen
evanso 67:a2984682d641 86 if (actual_pixel_status == expected_pixel_status) {
evanso 67:a2984682d641 87 printf ( "Passed!\n");
evanso 67:a2984682d641 88 return true;
evanso 67:a2984682d641 89 } else {
evanso 67:a2984682d641 90 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
evanso 67:a2984682d641 91 expected_pixel_status);
evanso 67:a2984682d641 92 return false;
evanso 67:a2984682d641 93 }
evanso 67:a2984682d641 94 }
evanso 67:a2984682d641 95
evanso 67:a2984682d641 96
evanso 85:87bc28b151d8 97 #endif