Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Map/Map_test.h

Committer:
evanso
Date:
2020-04-28
Revision:
15:90b6821bcf64
Parent:
14:7419c680656f
Child:
18:11068b98e261

File content as of revision 15:90b6821bcf64:

#ifndef MAP_TEST_H
#define MAP_TEST_H

// Objects reqired for test ----------------------------------------------------
Gamepad pad;
N5110 lcd;
Map map;

/** Map Test
@brief Checks that the map moves to the correct x position depedning on map_move input.
Also checks that map can go to required range of x positions.
@author Benjamin Evans, University of Leeds
@date April 2020
@return true if test are passed 
*/

bool map_move_test(int move_map, int expected_x_position){
    // Objects reqired for test ------------------------------------------------
    Gamepad pad;
    Map map;
    
    // Initialise map in start postion of -84,42
    pad.init();
    map.init(pad); 
    
    printf("move map = %d : ", move_map);
    
    // Draws map but with move variable set so it starts above 0
    // As can't rea pixel of the LCD
    map.draw_map(lcd, move_map);
    
    //Reads start postion of map drawn
    int map_start_draw_postion = map.get_position_x_map();
    
    // Checks final position with espected
    if (map_start_draw_postion  == expected_x_position) {
        printf ( "Passed!\n");
        return true;
    } else {
        printf ( "Failed! value = %d,  (expecting  %d)\n",map_start_draw_postion, expected_x_position);
        return false;
    }
}

#endif