Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Revision:
37:a05eac7fcb4c
Parent:
33:7fedd8029473
Child:
38:75bd968daa31
--- a/People/People_test.h	Fri May 15 16:31:25 2020 +0000
+++ b/People/People_test.h	Sat May 16 16:16:43 2020 +0000
@@ -0,0 +1,45 @@
+#ifndef PEOPLE_TEST_H
+#define PEOPLE_TEST_H
+
+/** People Test
+ * @brief Checks People draw corectly and moves joystick direction
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ * @return true if test are passed 
+ */
+bool people_draw_test(Direction d_, int expected_pixel_status, int expected_x){
+    // Objects reqired for test 
+    Gamepad pad;
+    Map map;
+    People people;
+    N5110 lcd;
+    
+    // Initialises
+    pad.init();
+    lcd.init();
+    map.init(pad); 
+    people.init(pad,expected_x),
+
+    printf(" expected pixel status = %d  ",expected_pixel_status);
+    
+    // Draws people
+    people.draw_people(lcd, d_, map.get_length_map(), map.get_position_x_map());
+    
+    // gets the position of person as it's random
+    Vector2D people_pos = people.get_pos();
+    
+    // Reads pixel where person is expected to be drawn 
+    int actual_pixel_status = lcd.getPixel(people_pos.x + 1, 
+    people_pos.y + 1);
+    
+    // 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