Zikang Qian / Mbed 2 deprecated el17z2q

Dependencies:   mbed

Fork of el17z2q by ELEC2645 (2017/18)

Revision:
1:00a4ea97c4cd
Child:
2:6dc7bc55c1cb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GameEngine/CoinWithBoundary-test.h	Mon May 07 21:24:25 2018 +0000
@@ -0,0 +1,46 @@
+#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
\ No newline at end of file