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 37:a05eac7fcb4c 1 #ifndef PEOPLE_TEST_H
evanso 37:a05eac7fcb4c 2 #define PEOPLE_TEST_H
evanso 37:a05eac7fcb4c 3
evanso 37:a05eac7fcb4c 4 /** People Test
evanso 37:a05eac7fcb4c 5 * @brief Checks People draw corectly and moves joystick direction
evanso 37:a05eac7fcb4c 6 * @author Benjamin Evans, University of Leeds
evanso 37:a05eac7fcb4c 7 * @date April 2020
evanso 37:a05eac7fcb4c 8 * @return true if test are passed
evanso 37:a05eac7fcb4c 9 */
evanso 37:a05eac7fcb4c 10 bool people_draw_test(Direction d_, int expected_pixel_status, int expected_x){
evanso 85:87bc28b151d8 11 // Objects required for test
evanso 37:a05eac7fcb4c 12 Gamepad pad;
evanso 37:a05eac7fcb4c 13 Map map;
evanso 37:a05eac7fcb4c 14 People people;
evanso 37:a05eac7fcb4c 15 N5110 lcd;
evanso 37:a05eac7fcb4c 16
evanso 37:a05eac7fcb4c 17 // Initialises
evanso 37:a05eac7fcb4c 18 pad.init();
evanso 37:a05eac7fcb4c 19 lcd.init();
evanso 37:a05eac7fcb4c 20 map.init(pad);
evanso 37:a05eac7fcb4c 21 people.init(pad,expected_x),
evanso 37:a05eac7fcb4c 22
evanso 37:a05eac7fcb4c 23 printf(" expected pixel status = %d ",expected_pixel_status);
evanso 37:a05eac7fcb4c 24
evanso 37:a05eac7fcb4c 25 // Draws people
evanso 37:a05eac7fcb4c 26 people.draw_people(lcd, d_, map.get_length_map(), map.get_position_x_map());
evanso 37:a05eac7fcb4c 27
evanso 82:3211b31e9421 28 // Gets the position of person as it's random
evanso 37:a05eac7fcb4c 29 Vector2D people_pos = people.get_pos();
evanso 37:a05eac7fcb4c 30
evanso 37:a05eac7fcb4c 31 // Reads pixel where person is expected to be drawn
evanso 37:a05eac7fcb4c 32 int actual_pixel_status = lcd.getPixel(people_pos.x + 1,
evanso 37:a05eac7fcb4c 33 people_pos.y + 1);
evanso 37:a05eac7fcb4c 34
evanso 85:87bc28b151d8 35 // Checks if pixel is drawn and therefor testing it hasn’t gone of screen
evanso 37:a05eac7fcb4c 36 if (actual_pixel_status == expected_pixel_status) {
evanso 37:a05eac7fcb4c 37 printf ( "Passed!\n");
evanso 37:a05eac7fcb4c 38 return true;
evanso 37:a05eac7fcb4c 39 } else {
evanso 37:a05eac7fcb4c 40 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
evanso 37:a05eac7fcb4c 41 expected_pixel_status);
evanso 37:a05eac7fcb4c 42 return false;
evanso 37:a05eac7fcb4c 43 }
evanso 37:a05eac7fcb4c 44 }
evanso 38:75bd968daa31 45
evanso 38:75bd968daa31 46 bool check_alien_collision_test(bool expected_collision, int expected_x){
evanso 38:75bd968daa31 47
evanso 85:87bc28b151d8 48 // Objects required for test
evanso 38:75bd968daa31 49 Alien alien;
evanso 38:75bd968daa31 50 People people;
evanso 38:75bd968daa31 51 Gamepad pad;
evanso 38:75bd968daa31 52
evanso 38:75bd968daa31 53 // Initialise people x start position
evanso 38:75bd968daa31 54 people.init(pad,expected_x);
evanso 38:75bd968daa31 55
evanso 38:75bd968daa31 56 printf("collision = %s : " ,expected_collision ? "true" : "false");
evanso 38:75bd968daa31 57
evanso 85:87bc28b151d8 58 // Initialise alien to people position
evanso 38:75bd968daa31 59 alien.init(pad,expected_x,43);
evanso 38:75bd968daa31 60
evanso 38:75bd968daa31 61 // Checks collision function
evanso 38:75bd968daa31 62 bool actual_collision = people.check_alien_collision(alien);
evanso 38:75bd968daa31 63
evanso 85:87bc28b151d8 64 // Checks if collision is expected
evanso 38:75bd968daa31 65 if (actual_collision == expected_collision) {
evanso 38:75bd968daa31 66 printf ( "Passed!\n");
evanso 38:75bd968daa31 67 return true;
evanso 38:75bd968daa31 68 } else {
evanso 38:75bd968daa31 69 printf ("Failed! value = %s (expecting %d)\n",
evanso 38:75bd968daa31 70 actual_collision ? "true" : "false",
evanso 38:75bd968daa31 71 expected_collision ? "true" : "false");
evanso 38:75bd968daa31 72 return false;
evanso 38:75bd968daa31 73 }
evanso 38:75bd968daa31 74 }
evanso 85:87bc28b151d8 75 #endif