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
Diff: GameEngine/CoinWithBoundary-test.h
- Branch:
- GameEngine
- Revision:
- 2:6dc7bc55c1cb
- Parent:
- 1:00a4ea97c4cd
--- a/GameEngine/CoinWithBoundary-test.h Mon May 07 21:24:25 2018 +0000 +++ b/GameEngine/CoinWithBoundary-test.h Mon May 07 22:11:43 2018 +0000 @@ -15,28 +15,31 @@ 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 -2, 3 + // 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 position + // Update the coin coin.update(); + // get the result of colliding analysis 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 + // failed if game is not over if (nodead != 0) { success = false; }