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.
Map/Map_test.h@13:12276eed13ac, 2020-04-26 (annotated)
- Committer:
- evanso
- Date:
- Sun Apr 26 17:08:10 2020 +0000
- Revision:
- 13:12276eed13ac
- Parent:
- 12:1c0b6796aaca
- Child:
- 14:7419c680656f
Changed spaceship unit test code so it now done properly and doesn't require my input. Changed where objects are defined to reduce the number of arguments that need passing when a function is called. Edited gamepad code to properly add ADC pin.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
evanso | 12:1c0b6796aaca | 1 | #ifndef MAP_TEST_H |
evanso | 12:1c0b6796aaca | 2 | #define MAP_TEST_H |
evanso | 12:1c0b6796aaca | 3 | |
evanso | 13:12276eed13ac | 4 | // Objects reqired for test ---------------------------------------------------- |
evanso | 13:12276eed13ac | 5 | Gamepad pad; |
evanso | 13:12276eed13ac | 6 | N5110 lcd; |
evanso | 13:12276eed13ac | 7 | Spaceship spaceship; |
evanso | 13:12276eed13ac | 8 | Map map; |
evanso | 13:12276eed13ac | 9 | |
evanso | 12:1c0b6796aaca | 10 | /** Map Test |
evanso | 13:12276eed13ac | 11 | @brief Checks map goes to the correct postion when moved |
evanso | 12:1c0b6796aaca | 12 | @author Benjamin Evans, University of Leeds |
evanso | 12:1c0b6796aaca | 13 | @date April 2020 |
evanso | 12:1c0b6796aaca | 14 | @return true if test are passed |
evanso | 12:1c0b6796aaca | 15 | */ |
evanso | 12:1c0b6796aaca | 16 | |
evanso | 12:1c0b6796aaca | 17 | bool map_draw_test(){ |
evanso | 12:1c0b6796aaca | 18 | // Objects reqired for test |
evanso | 12:1c0b6796aaca | 19 | Serial usb(USBTX, USBRX); |
evanso | 12:1c0b6796aaca | 20 | |
evanso | 12:1c0b6796aaca | 21 | // Flag to return if test passed |
evanso | 12:1c0b6796aaca | 22 | bool pass_flag = true; |
evanso | 12:1c0b6796aaca | 23 | |
evanso | 12:1c0b6796aaca | 24 | // Initialise map in start postion of -84, 42 and draw |
evanso | 12:1c0b6796aaca | 25 | lcd.init(); |
evanso | 12:1c0b6796aaca | 26 | map.init(adc); |
evanso | 12:1c0b6796aaca | 27 | map.draw_map(lcd,0); |
evanso | 12:1c0b6796aaca | 28 | |
evanso | 12:1c0b6796aaca | 29 | // Reads start spaceship postion |
evanso | 12:1c0b6796aaca | 30 | int start_x_postion = map.get_position_x_map(); |
evanso | 12:1c0b6796aaca | 31 | usb.printf("start postion x = %d\n", start_x_postion); |
evanso | 12:1c0b6796aaca | 32 | |
evanso | 12:1c0b6796aaca | 33 | // Test drap map function |
evanso | 12:1c0b6796aaca | 34 | map.draw_map(lcd,1); |
evanso | 12:1c0b6796aaca | 35 | |
evanso | 12:1c0b6796aaca | 36 | // Reads end map position |
evanso | 12:1c0b6796aaca | 37 | int end_x_postion_one = map.get_position_x_map(); |
evanso | 12:1c0b6796aaca | 38 | usb.printf("end postion one x = %d\n", end_x_postion_one ); |
evanso | 12:1c0b6796aaca | 39 | |
evanso | 12:1c0b6796aaca | 40 | //TO check if map moves in opsite direction |
evanso | 12:1c0b6796aaca | 41 | map.draw_map(lcd,-1); |
evanso | 12:1c0b6796aaca | 42 | |
evanso | 12:1c0b6796aaca | 43 | // Reads end map position |
evanso | 12:1c0b6796aaca | 44 | int end_x_postion_two = map.get_position_x_map(); |
evanso | 12:1c0b6796aaca | 45 | usb.printf("end postion two x = %d\n", end_x_postion_two ); |
evanso | 12:1c0b6796aaca | 46 | |
evanso | 12:1c0b6796aaca | 47 | // Fail test if start postision is incorrect |
evanso | 12:1c0b6796aaca | 48 | if (end_x_postion_one != -83 || end_x_postion_two != -84) { |
evanso | 12:1c0b6796aaca | 49 | pass_flag = false; |
evanso | 12:1c0b6796aaca | 50 | } |
evanso | 12:1c0b6796aaca | 51 | |
evanso | 12:1c0b6796aaca | 52 | return pass_flag; |
evanso | 12:1c0b6796aaca | 53 | } |
evanso | 12:1c0b6796aaca | 54 | #endif |