Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Revision:
66:33f479036a5d
Child:
67:a2984682d641
diff -r daa792a09e1f -r 33f479036a5d HUD/HUD_test.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HUD/HUD_test.h	Thu May 21 17:37:15 2020 +0000
@@ -0,0 +1,40 @@
+#ifndef HUD_TEST_H
+#define HUD_TEST_H
+
+/** HUD Test
+ * @brief Checks that the differnt parts of the hud draw
+ * of map when being drawn
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ * @return true if test are passed 
+ */
+bool HUD_draw_test(int spaceship_lives, int points,  int smart_bomb_counter, 
+int expected_pixel_status, int expected_postion_x, int expected_postion_y){
+    
+    // Objects reqired for test 
+    HUD hud;
+    N5110 lcd;
+    
+    // Initialise lcd
+    lcd.init();
+    
+    // Reads start spaceship postion 
+    printf("HUD_draw x,y = %d,%d : ",expected_postion_x,expected_postion_y );
+    
+    hud.draw_HUD(lcd,spaceship_lives, points, smart_bomb_counter);
+    
+    // Reads pixel where hud is expected to be drawn 
+    int actual_pixel_status = lcd.getPixel(expected_postion_x, 
+    expected_postion_y);
+    
+    // Checks if pixel is drawn and therefor testing it hasnt gone of screen
+    if (actual_pixel_status == expected_pixel_status) {
+        printf ( "Passed!\n");
+        return true;
+    } else {
+        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, 
+        expected_pixel_status);
+        return false;
+    }
+}
+#endif
\ No newline at end of file