Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Map_test.h Source File

Map_test.h

00001 #ifndef MAP_TEST_H
00002 #define MAP_TEST_H
00003 
00004 /** Map Test
00005  * @brief Checks that the map moves to the correct x position depending on 
00006  * joystick input
00007  * @author Benjamin Evans, University of Leeds
00008  * @date April 2020
00009  * @return true if test are passed 
00010  */
00011 bool map_move_test(Direction d_, int expected_x_position) {
00012     // Objects required for test
00013     Map map;
00014     N5110 lcd;
00015     Gamepad pad;
00016     
00017     // Initialise map in start position of -84,42
00018     pad.init();
00019     map.init(pad); 
00020     
00021     printf("Espected map x position = %d, : ",expected_x_position);
00022     
00023     // Draws map but with move variable set so it starts above 0
00024     // As can't rea pixel of the LCD
00025     map.draw_map(lcd, d_);
00026     
00027     // Reads start position of map drawn
00028     int map_start_draw_postion = map.get_position_x_map();
00029     
00030     // Checks final position with expected
00031     if (map_start_draw_postion  == expected_x_position) {
00032         printf ( "Passed!\n");
00033         return true;
00034     } else {
00035         printf ( "Failed! value = %d,  (expecting  %d)\n",
00036         map_start_draw_postion, expected_x_position);
00037         return false;
00038     }
00039 }
00040 
00041 #endif