Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of el17z2q by
GameEngine/CoinWithBoundary-test.h
- Committer:
- yzjdxl
- Date:
- 2018-05-07
- Branch:
- GameEngine
- Revision:
- 2:6dc7bc55c1cb
- Parent:
- 1:00a4ea97c4cd
File content as of revision 2:6dc7bc55c1cb:
#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; // initial coin's size coin.init(2.5,1); game.init(17,2,2.5,1); // initial coin position Vector2D initial_coin_position = {5,0}; coin.set_position(initial_coin_position); // Read the position of coin Vecotr2D read_coin_position = coin.get_position; printf("%f, %f\n", read_coin_position.x, read_coin_position.y); // Set the velocity to 0, 48 so that the coin can collide with bottom boundary immediately Vector2D velocity = {0, 48}; coin.set_velocity(velocity); // Update the coin coin.update(); // get the result of colliding analysis int nodead = game.update(pad); bool success = true; // failed if game is not over if (nodead != 0) { success = false; } return success; } #endif