ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Revision:
34:a9b14a4ccd46
Parent:
33:de130e274391
Child:
35:b99b563c3eb6
--- a/Floors/Floors.cpp	Thu May 09 11:39:59 2019 +0000
+++ b/Floors/Floors.cpp	Thu May 09 14:07:09 2019 +0000
@@ -6,16 +6,19 @@
 {
 }
 
+
+// Function to set the intial position of the floor at a specified input y-coordinate (from engine) and then sets a random 
+// x-coordinate position. 
 void Floors::init(int y, int width, int height)
 {
-    _height = height;
+    _height = height;  // defines the width and height as private variables
     _width = width;
     end_game = false;  // the read decision should be false initially so that the game is not ended as soon as it starts
-    int decide = rand() % 2;  // x-coordinate initially random: 2-30 or 40-71 so doodler falls to bottom floor
+    int decide = rand() % 2;  // x-coordinate initially random: 2-30 or 40-71 so doodler falls to bottom floor specified in engine
     if (decide == 0) {  // right
         _position.x = 2 + (rand()% 28);
     } else {  // left
-        _position.x = 40 + (rand()% 31);
+        _position.x = 40 + (rand()% 31); // position is within screen parameters
     }
     _position.y = y;