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 23:cc44e26c08fa 1 #ifndef WEAPONS_TEST_H
evanso 23:cc44e26c08fa 2 #define WEAPONS_TEST_H
evanso 23:cc44e26c08fa 3
evanso 23:cc44e26c08fa 4 /** Weapons Test
evanso 27:8bb2bd97c319 5 * @brief Checks that the weapons draws
evanso 27:8bb2bd97c319 6 * @author Benjamin Evans, University of Leeds
evanso 27:8bb2bd97c319 7 * @date May 2020
evanso 27:8bb2bd97c319 8 * @return true if test are passed
evanso 27:8bb2bd97c319 9 */
evanso 27:8bb2bd97c319 10 bool weapons_draw_test(int expected_pixel_status,bool direction,
evanso 82:3211b31e9421 11 int bullet_movement, int expected_postion_x, int expected_postion_y) {
evanso 85:87bc28b151d8 12 // Objects required for test
evanso 23:cc44e26c08fa 13 Weapons bullet;
evanso 23:cc44e26c08fa 14 Spaceship spaceship;
evanso 23:cc44e26c08fa 15 N5110 lcd;
evanso 23:cc44e26c08fa 16
evanso 85:87bc28b151d8 17 // Initialise objects for test
evanso 23:cc44e26c08fa 18 spaceship.init();
evanso 23:cc44e26c08fa 19 lcd.init();
evanso 37:a05eac7fcb4c 20 bullet.init(spaceship.get_pos(), direction, true);
evanso 23:cc44e26c08fa 21
evanso 23:cc44e26c08fa 22 printf("draw_bullet = %d,%d : ", expected_postion_x, expected_postion_y);
evanso 23:cc44e26c08fa 23
evanso 85:87bc28b151d8 24 // Draws bullet in different positions
evanso 82:3211b31e9421 25 for(int i = 0;i <= bullet_movement; i++) {
evanso 23:cc44e26c08fa 26 bullet.draw_bullet(lcd);
evanso 23:cc44e26c08fa 27 }
evanso 23:cc44e26c08fa 28
evanso 23:cc44e26c08fa 29 // Reads pixel where bullet is expected to be drawn
evanso 27:8bb2bd97c319 30 int actual_pixel_status = lcd.getPixel(expected_postion_x,
evanso 27:8bb2bd97c319 31 expected_postion_y);
evanso 23:cc44e26c08fa 32
evanso 85:87bc28b151d8 33 // Checks if pixel is drawn and therefor testing it hasn’t gone of screen
evanso 23:cc44e26c08fa 34 if (actual_pixel_status) {
evanso 23:cc44e26c08fa 35 printf ( "Passed!\n");
evanso 23:cc44e26c08fa 36 return true;
evanso 23:cc44e26c08fa 37 } else {
evanso 27:8bb2bd97c319 38 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
evanso 27:8bb2bd97c319 39 expected_pixel_status);
evanso 23:cc44e26c08fa 40 return false;
evanso 23:cc44e26c08fa 41 }
evanso 23:cc44e26c08fa 42 }
evanso 23:cc44e26c08fa 43
evanso 85:87bc28b151d8 44 #endif