Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Committer:
evanso
Date:
Thu May 21 20:23:24 2020 +0000
Revision:
67:a2984682d641
Parent:
66:33f479036a5d
Child:
82:3211b31e9421
Added SaveGame unit test which all passed! Had to define the unit test that tests actually saving and reading from a file as kept getting an error when declaring the sd object.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 66:33f479036a5d 1 #ifndef HUD_TEST_H
evanso 66:33f479036a5d 2 #define HUD_TEST_H
evanso 66:33f479036a5d 3
evanso 66:33f479036a5d 4 /** HUD Test
evanso 66:33f479036a5d 5 * @brief Checks that the differnt parts of the hud draw
evanso 66:33f479036a5d 6 * @author Benjamin Evans, University of Leeds
evanso 66:33f479036a5d 7 * @date May 2020
evanso 66:33f479036a5d 8 * @return true if test are passed
evanso 66:33f479036a5d 9 */
evanso 66:33f479036a5d 10 bool HUD_draw_test(int spaceship_lives, int points, int smart_bomb_counter,
evanso 66:33f479036a5d 11 int expected_pixel_status, int expected_postion_x, int expected_postion_y){
evanso 66:33f479036a5d 12
evanso 66:33f479036a5d 13 // Objects reqired for test
evanso 66:33f479036a5d 14 HUD hud;
evanso 66:33f479036a5d 15 N5110 lcd;
evanso 66:33f479036a5d 16
evanso 66:33f479036a5d 17 // Initialise lcd
evanso 66:33f479036a5d 18 lcd.init();
evanso 66:33f479036a5d 19
evanso 66:33f479036a5d 20 printf("HUD_draw x,y = %d,%d : ",expected_postion_x,expected_postion_y );
evanso 66:33f479036a5d 21
evanso 66:33f479036a5d 22 hud.draw_HUD(lcd,spaceship_lives, points, smart_bomb_counter);
evanso 66:33f479036a5d 23
evanso 66:33f479036a5d 24 // Reads pixel where hud is expected to be drawn
evanso 66:33f479036a5d 25 int actual_pixel_status = lcd.getPixel(expected_postion_x,
evanso 66:33f479036a5d 26 expected_postion_y);
evanso 66:33f479036a5d 27
evanso 66:33f479036a5d 28 // Checks if pixel is drawn and therefor testing it hasnt gone of screen
evanso 66:33f479036a5d 29 if (actual_pixel_status == expected_pixel_status) {
evanso 66:33f479036a5d 30 printf ( "Passed!\n");
evanso 66:33f479036a5d 31 return true;
evanso 66:33f479036a5d 32 } else {
evanso 66:33f479036a5d 33 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
evanso 66:33f479036a5d 34 expected_pixel_status);
evanso 66:33f479036a5d 35 return false;
evanso 66:33f479036a5d 36 }
evanso 66:33f479036a5d 37 }
evanso 66:33f479036a5d 38 #endif