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.

Revision:
83:35d1e846eab2
Parent:
82:3211b31e9421
Child:
85:87bc28b151d8
--- a/test.h	Mon May 25 18:39:51 2020 +0000
+++ b/test.h	Mon May 25 22:18:11 2020 +0000
@@ -13,6 +13,7 @@
 #include "SavedGames_test.h"
 #include "Settings_test.h"
 #include "HighScore_test.h"
+#include "PlayEngine_test.h"
  
 /** Test
  * @brief Runs all tests for game 
@@ -393,4 +394,147 @@
 }
 
 
+
+
+// Play Engine tests -----------------------------------------------------------
+
+void run_read_accelerometer_direction_test() {
+    printf ("\nread_accelerometer_direction_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (read_accelerometer_direction_test(CENTRE,5,-40 )) passed_counter++;
+    if (read_accelerometer_direction_test(N, 5,-10)) passed_counter++;
+    if (read_accelerometer_direction_test(NE, 20, -10)) passed_counter++;
+    if (read_accelerometer_direction_test(E, 20,-40)) passed_counter++;
+    if (read_accelerometer_direction_test(SE, 20,-60)) passed_counter++;
+    if (read_accelerometer_direction_test(S, 5,-60)) passed_counter++;
+    if (read_accelerometer_direction_test(SW, -20,-60)) passed_counter++;
+    if (read_accelerometer_direction_test(W,  -40, -40)) passed_counter++;
+    if (read_accelerometer_direction_test(NW, -15, -10)) passed_counter++;
+    
+    // Prints results
+    printf ("\nread_accelerometer_direction_test passed %d tests out of 9\n\n\n"
+    ,passed_counter);
+}
+
+void run_spawn_aliens_test() {
+    printf ("\nspawn_aliens_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (spawn_aliens_test(1)) passed_counter++;
+    if (spawn_aliens_test(3)) passed_counter++;
+    if (spawn_aliens_test(5)) passed_counter++;
+    if (spawn_aliens_test(10)) passed_counter++;
+    if (spawn_aliens_test(20)) passed_counter++;
+        
+    // Prints results
+    printf ("\nspawn_aliens_test passed %d tests out of 5\n\n\n"
+    ,passed_counter);
+}
+
+void run_create_alien_test() {
+    printf ("\ncreate_aliens_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (create_alien_test(2)) passed_counter++;
+    if (create_alien_test(4)) passed_counter++;
+    if (create_alien_test(6)) passed_counter++;
+    if (create_alien_test(15)) passed_counter++;
+    if (create_alien_test(30)) passed_counter++;
+        
+    // Prints results
+    printf ("\ncreate_aliens_test() %d tests out of 5\n\n\n"
+    ,passed_counter);
+}
+
+void run_create_explosion_test() {
+    printf ("\ncreate_explosion_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (create_explosion_test(3)) passed_counter++;
+    if (create_explosion_test(6)) passed_counter++;
+    if (create_explosion_test(9)) passed_counter++;
+    if (create_explosion_test(1)) passed_counter++;
+    if (create_explosion_test(22)) passed_counter++;
+        
+    // Prints results
+    printf ("\ncreate_explosion_test() %d tests out of 5\n\n\n"
+    ,passed_counter);
+}
+void run_draw_explosions_test() {
+    printf ("\ndraw_explosions_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (draw_explosions_test(1,32,33)) passed_counter++;
+    if (draw_explosions_test(0,100,20)) passed_counter++;
+    if (draw_explosions_test(1,1,20)) passed_counter++;
+    if (draw_explosions_test(1,1,44)) passed_counter++;
+    if (draw_explosions_test(1,78,1)) passed_counter++;
+        
+    // Prints results
+    printf ("\ncreate_explosion_test() %d tests out of 5\n\n\n"
+    ,passed_counter);
+}
+
+void run_spawn_people_test() {
+    printf ("\nspawn_people_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (spawn_people_test(1)) passed_counter++;
+    if (spawn_people_test(2)) passed_counter++;
+    if (spawn_people_test(3)) passed_counter++;
+    if (spawn_people_test(4)) passed_counter++;
+    if (spawn_people_test(5)) passed_counter++;
+        
+    // Prints results
+    printf ("\nspawn_people_test passed %d tests out of 5\n\n\n"
+    ,passed_counter);
+}
+ 
+void run_people_alien_test() {
+    printf ("\ncreate_people_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (create_people_test(1)) passed_counter++;
+    if (create_people_test(2)) passed_counter++;
+    if (create_people_test(3)) passed_counter++;
+    if (create_people_test(4)) passed_counter++;
+    if (create_people_test(5)) passed_counter++;
+        
+    // Prints results
+    printf ("\ncreate_people_test() %d tests out of 5\n\n\n"
+    ,passed_counter);
+}
+
+void run_reset_map_timer_test() {
+    printf ("\nreset_map_timer_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (reset_map_timer_test(CENTRE, true)) passed_counter++;
+    if (reset_map_timer_test(N, false)) passed_counter++;
+        
+    // Prints results
+    printf ("\nreset_map_timer_test() %d tests out of 2\n\n\n"
+    ,passed_counter);
+}
+
+void run_reset_map_test() {
+    printf ("\nreset_map_test() \n\n");
+    int passed_counter = 0;
+
+    // Runs test with all differnt possible inputs
+    if (reset_map_test()) passed_counter++;
+        
+    // Prints results
+    printf ("\nreset_map_test() %d tests out of 1\n\n\n"
+    ,passed_counter);
+}
 #endif
\ No newline at end of file