Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Committer:
evanso
Date:
Sun Apr 26 20:31:53 2020 +0000
Revision:
14:7419c680656f
Parent:
13:12276eed13ac
Child:
15:90b6821bcf64
Added map movement test unit and doxygen details to comments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 12:1c0b6796aaca 1 #ifndef MAP_TEST_H
evanso 12:1c0b6796aaca 2 #define MAP_TEST_H
evanso 12:1c0b6796aaca 3
evanso 13:12276eed13ac 4 // Objects reqired for test ----------------------------------------------------
evanso 13:12276eed13ac 5 Gamepad pad;
evanso 13:12276eed13ac 6 N5110 lcd;
evanso 13:12276eed13ac 7 Map map;
evanso 13:12276eed13ac 8
evanso 12:1c0b6796aaca 9 /** Map Test
evanso 14:7419c680656f 10 @brief Checks that the map goes to the correct x postion when moved.
evanso 12:1c0b6796aaca 11 @author Benjamin Evans, University of Leeds
evanso 12:1c0b6796aaca 12 @date April 2020
evanso 12:1c0b6796aaca 13 @return true if test are passed
evanso 12:1c0b6796aaca 14 */
evanso 12:1c0b6796aaca 15
evanso 14:7419c680656f 16 bool map_move_test(int move_map, int expected_x_position){
evanso 14:7419c680656f 17 // Objects reqired for test ------------------------------------------------
evanso 14:7419c680656f 18 Gamepad pad;
evanso 14:7419c680656f 19 Map map;
evanso 12:1c0b6796aaca 20
evanso 14:7419c680656f 21 // Initialise map in start postion of -84,42
evanso 14:7419c680656f 22 pad.init();
evanso 14:7419c680656f 23 map.init(pad);
evanso 12:1c0b6796aaca 24
evanso 14:7419c680656f 25 printf("move map = %d : ", move_map);
evanso 12:1c0b6796aaca 26
evanso 14:7419c680656f 27 // Draws map but with move variable set so it starts above 0
evanso 14:7419c680656f 28 // As can't rea pixel of the LCD
evanso 14:7419c680656f 29 map.draw_map(lcd, move_map);
evanso 12:1c0b6796aaca 30
evanso 14:7419c680656f 31 //Reads start postion of map drawn
evanso 14:7419c680656f 32 int map_start_draw_postion = map.get_position_x_map();
evanso 12:1c0b6796aaca 33
evanso 14:7419c680656f 34 // Checks final position with espected
evanso 14:7419c680656f 35 if (map_start_draw_postion == expected_x_position) {
evanso 14:7419c680656f 36 printf ( "Passed!\n");
evanso 14:7419c680656f 37 return true;
evanso 14:7419c680656f 38 } else {
evanso 14:7419c680656f 39 printf ( "Failed! value = %d, (expecting %d)\n",map_start_draw_postion, expected_x_position);
evanso 14:7419c680656f 40 return false;
evanso 12:1c0b6796aaca 41 }
evanso 14:7419c680656f 42 }
evanso 12:1c0b6796aaca 43
evanso 12:1c0b6796aaca 44 #endif