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.
Dependencies: mbed
Diff: Floors/Floors.cpp
- Revision:
- 34:a9b14a4ccd46
- Parent:
- 33:de130e274391
- Child:
- 35:b99b563c3eb6
diff -r de130e274391 -r a9b14a4ccd46 Floors/Floors.cpp
--- 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;