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 65:daa792a09e1f 1 #ifndef MENU_TEST_H
evanso 65:daa792a09e1f 2 #define MENU_TEST_H
evanso 65:daa792a09e1f 3
evanso 65:daa792a09e1f 4 /** Menu Test
evanso 85:87bc28b151d8 5 * @brief Test the different Menu functions
evanso 65:daa792a09e1f 6 * @author Benjamin Evans, University of Leeds
evanso 65:daa792a09e1f 7 * @date May 2020
evanso 65:daa792a09e1f 8 * @return true if test are passed
evanso 65:daa792a09e1f 9 */
evanso 82:3211b31e9421 10 bool menu_select_part_test(MenuParts expected_menu_part, bool pressed) {
evanso 85:87bc28b151d8 11 // Objects required for test
evanso 65:daa792a09e1f 12 Menu menu;
evanso 65:daa792a09e1f 13
evanso 65:daa792a09e1f 14 // Initialise the menu
evanso 65:daa792a09e1f 15 menu.init();
evanso 65:daa792a09e1f 16
evanso 85:87bc28b151d8 17 if (pressed) {
evanso 65:daa792a09e1f 18 printf("Expected menu part play : ");
evanso 65:daa792a09e1f 19 }else{
evanso 65:daa792a09e1f 20 printf("Expected menu part main menu : ");
evanso 65:daa792a09e1f 21 }
evanso 65:daa792a09e1f 22
evanso 65:daa792a09e1f 23 // Calls menu select function with pressed and not pressed
evanso 65:daa792a09e1f 24 menu.select_part(pressed);
evanso 65:daa792a09e1f 25
evanso 65:daa792a09e1f 26
evanso 65:daa792a09e1f 27 // Gets the current menu part and checks if it is the expected menu part
evanso 65:daa792a09e1f 28 if ( menu.get_current_menu_part() == expected_menu_part) {
evanso 65:daa792a09e1f 29 printf ( "Passed!\n");
evanso 65:daa792a09e1f 30 return true;
evanso 65:daa792a09e1f 31 } else {
evanso 65:daa792a09e1f 32 printf ( "Failed!\n");
evanso 65:daa792a09e1f 33 return false;
evanso 65:daa792a09e1f 34 }
evanso 65:daa792a09e1f 35 }
evanso 65:daa792a09e1f 36
evanso 82:3211b31e9421 37 bool menu_scroll_test(Direction d_,MenuParts expected_menu_part) {
evanso 85:87bc28b151d8 38 // Objects required for test
evanso 65:daa792a09e1f 39 Menu menu;
evanso 65:daa792a09e1f 40
evanso 65:daa792a09e1f 41 // Initialise the menu
evanso 65:daa792a09e1f 42 menu.init();
evanso 65:daa792a09e1f 43
evanso 65:daa792a09e1f 44 printf("Expected menu part %d : ",expected_menu_part);
evanso 65:daa792a09e1f 45
evanso 65:daa792a09e1f 46 menu.menu_scroll(d_);
evanso 65:daa792a09e1f 47
evanso 65:daa792a09e1f 48 // Calls menu select function to so we can then get the displayed menu part
evanso 65:daa792a09e1f 49 menu.select_part(true);
evanso 65:daa792a09e1f 50
evanso 65:daa792a09e1f 51 MenuParts actual_menu_part = menu.get_current_menu_part();
evanso 65:daa792a09e1f 52
evanso 65:daa792a09e1f 53 // Gets the current menu part and checks if it is the expected menu part
evanso 65:daa792a09e1f 54 if ( actual_menu_part == expected_menu_part) {
evanso 65:daa792a09e1f 55 printf ( "Passed!\n");
evanso 65:daa792a09e1f 56 return true;
evanso 65:daa792a09e1f 57 } else {
evanso 65:daa792a09e1f 58 printf ( "Failed! %d (expecting %d,)\n", actual_menu_part,
evanso 65:daa792a09e1f 59 expected_menu_part);
evanso 65:daa792a09e1f 60 return false;
evanso 65:daa792a09e1f 61 }
evanso 65:daa792a09e1f 62 }
evanso 65:daa792a09e1f 63
evanso 70:8c4572d17441 64 bool menu_draw_part_test(int expected_pixel_status,
evanso 82:3211b31e9421 65 int expected_postion_x, int expected_postion_y) {
evanso 85:87bc28b151d8 66 // Objects required for test
evanso 70:8c4572d17441 67 Menu menu;
evanso 70:8c4572d17441 68 N5110 lcd;
evanso 70:8c4572d17441 69
evanso 70:8c4572d17441 70 // Initialise the Menu
evanso 70:8c4572d17441 71 menu.init();
evanso 70:8c4572d17441 72 lcd.init();
evanso 70:8c4572d17441 73
evanso 70:8c4572d17441 74 printf("menu_draw_part x,y = %d,%d : ",expected_postion_x,
evanso 70:8c4572d17441 75 expected_postion_y );
evanso 70:8c4572d17441 76
evanso 70:8c4572d17441 77 menu.draw_part(lcd);
evanso 70:8c4572d17441 78
evanso 70:8c4572d17441 79 // Reads pixel where hud is expected to be drawn
evanso 70:8c4572d17441 80 int actual_pixel_status = lcd.getPixel(expected_postion_x,
evanso 70:8c4572d17441 81 expected_postion_y);
evanso 70:8c4572d17441 82
evanso 85:87bc28b151d8 83 // Checks if pixel is drawn and therefor testing it hasn’t gone of screen
evanso 70:8c4572d17441 84 if (actual_pixel_status == expected_pixel_status) {
evanso 70:8c4572d17441 85 printf ( "Passed!\n");
evanso 70:8c4572d17441 86 return true;
evanso 70:8c4572d17441 87 } else {
evanso 70:8c4572d17441 88 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
evanso 70:8c4572d17441 89 expected_pixel_status);
evanso 70:8c4572d17441 90 return false;
evanso 70:8c4572d17441 91 }
evanso 70:8c4572d17441 92 }
evanso 70:8c4572d17441 93
evanso 85:87bc28b151d8 94 #endif