ELEC2645 (2018/19) / Mbed 2 deprecated el17lw

Dependencies:   mbed

Revision:
21:20478f086bc2
Parent:
16:331be5c7ed80
Child:
26:4253656c0755
--- a/Coin/Coin.cpp	Tue Apr 16 19:19:43 2019 +0000
+++ b/Coin/Coin.cpp	Sat Apr 20 14:46:50 2019 +0000
@@ -23,15 +23,14 @@
 Coin::~Coin() {}
 
 void Coin::init() {
-  // Initialise starting position of the coin.
   _x = 20;
   _y = 33;
   _coin_counter = 0;
 }
 
 void Coin::generate_coin() {
-  // Toggle the state of the coin every 3 loop iterations so it looks
-  // like it is rotating.
+  // Toggle the state of the coin every 3 loop iterations so it looks like it is
+  // rotating.
   if (_coin_counter == 2) {
     _coin_counter = 0;
     _rotate_coin = !_rotate_coin;
@@ -39,15 +38,14 @@
   _coin_counter++;      
 }
 
-void Coin::update_coin(int rand_x, int rand_y) {
-  // Move the coin to a new random location
-  if (rand_y > 40) {
+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;
   } else {
     _y = 33;
   }
   _x = rand_x;
-  if (_x < 3 || _x > 80) {
+  if (_x < 3 || _x > 78) {  // Ensures the coin does not generate off-screen
     _x = 50;
   }
 }
@@ -67,3 +65,5 @@
 int Coin::get_coin_y() {
   return _y;
 } 
+
+