ELEC2645 (2018/19) / Mbed 2 deprecated el17lw

Dependencies:   mbed

Revision:
26:4253656c0755
Parent:
21:20478f086bc2
Child:
29:bdc4138b5171
diff -r aa145767fda5 -r 4253656c0755 Coin/Coin.cpp
--- a/Coin/Coin.cpp	Wed Apr 24 17:58:35 2019 +0000
+++ b/Coin/Coin.cpp	Fri May 03 09:33:34 2019 +0000
@@ -23,6 +23,7 @@
 Coin::~Coin() {}
 
 void Coin::init() {
+  // Starting position of the coin.
   _x = 20;
   _y = 33;
   _coin_counter = 0;
@@ -39,18 +40,19 @@
 }
 
 void Coin::set_coin(int rand_x, int rand_y) {
-  if (rand_y > 40) {  // If random number is >40 set it on the top platforms.
-    _y = 15;
+  if (rand_y > 40) {  
+    _y = 15;  // Set the coin on the top platforms.
   } else {
-    _y = 33;
+    _y = 33;  // Set coin on the bottom platforms.
   }
   _x = rand_x;
-  if (_x < 3 || _x > 78) {  // Ensures the coin does not generate off-screen
-    _x = 50;
+  if (_x < 3 || _x > 78) {  // Ensures the coin does not generate off-screen.
+    _x = 50;  // Default value if the coin generates off-screen.
   }
 }
 
 int * Coin::get_coin_sprite() {
+  // Return different coin sprites.
   if (_rotate_coin) {
     return *coin_front;
   } else {