Zikang Qian / Mbed 2 deprecated el17z2q

Dependencies:   mbed

Fork of el17z2q by ELEC2645 (2017/18)

GameEngine/CoinWithBoundary-test.h

Committer:
yzjdxl
Date:
2018-05-07
Revision:
1:00a4ea97c4cd
Child:
2:6dc7bc55c1cb

File content as of revision 1:00a4ea97c4cd:

#ifndef COINWITHBOUNDARY_TEST_H
#define COINWITHBOUNDARY_TEST_H

/** CoinWithBoundayr-test Class
* @brief Check that the coin object correctly collides with boundary
* @author Zikang Qian
* @date April, 2018
*/

/** \returns true if all the tests passed
 */
bool CoinWithBoundary_test_collide()
{ 
    Coin coin;
    Bag bag;
    GameEngine game;
    
    coin.init(2.5,1);
    game.init(17,2,2.5,1);
    
    Vector2D initial_coin_position = {5,0};
    coin.set_position(initial_coin_position);
    
    Vecotr2D read_coin_position = coin.get_position;
    printf("%f, %f\n", read_coin_position.x, read_coin_position.y);
    
    // Set the velocity to -2, 3
    Vector2D velocity = {0, 48};
    coin.set_velocity(velocity);

    // Update the position
    coin.update();
    
    int nodead = game.update(pad);
    
    // Now check that both the positions are as expected
    bool success = true;
    
    // Fail the test if the initial position is wrong
    if (nodead != 0) {
        success = false;
    }

    return success;
}
#endif