Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HUD_test.h Source File

HUD_test.h

00001 #ifndef HUD_TEST_H
00002 #define HUD_TEST_H
00003 
00004 /** HUD Test
00005  * @brief Checks that the different parts of the hud draw
00006  * @author Benjamin Evans, University of Leeds
00007  * @date May 2020
00008  * @return true if test are passed 
00009  */
00010 bool HUD_draw_test(int spaceship_lives, int points,  int smart_bomb_counter, 
00011 int expected_pixel_status, int expected_postion_x, int expected_postion_y) {
00012     
00013     // Objects required for test 
00014     HUD hud;
00015     N5110 lcd;
00016     
00017     // Initialise lcd
00018     lcd.init();
00019     
00020     printf("HUD_draw x,y = %d,%d : ",expected_postion_x,expected_postion_y );
00021     
00022     hud.draw_HUD(lcd,spaceship_lives, points, smart_bomb_counter);
00023     
00024     // Reads pixel where hud is expected to be drawn 
00025     int actual_pixel_status = lcd.getPixel(expected_postion_x, 
00026     expected_postion_y);
00027     
00028     // Checks if pixel is drawn and therefor testing it hasn’t gone of screen
00029     if (actual_pixel_status == expected_pixel_status) {
00030         printf ( "Passed!\n");
00031         return true;
00032     } else {
00033         printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, 
00034         expected_pixel_status);
00035         return false;
00036     }
00037 }
00038 #endif