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: Engine/Engine.cpp
- Revision:
- 3:116913e97fd7
- Parent:
- 2:360a6c301a4e
- Child:
- 4:8ec314f806ae
diff -r 360a6c301a4e -r 116913e97fd7 Engine/Engine.cpp
--- a/Engine/Engine.cpp	Wed Apr 10 17:34:02 2019 +0000
+++ b/Engine/Engine.cpp	Wed Apr 10 19:07:41 2019 +0000
@@ -5,41 +5,46 @@
 Engine::~Engine(){
 }
 
-void Engine::init(int floors_height, int floors_width){
+void Engine::init(int floors_width, int floors_height){
     _floors_height = floors_height;
     _floors_width = floors_width;
 
-    _f1x = rand() % 84; // random floors position between 0 and 83 
-    _f2x = rand() % 84;
-    _f3x = rand() % 84;
-    _f4x = rand() % 84;
-    _f5x = rand() % 84;
-    _f6x = rand() % 84;
-    _f7x = rand() % 84;
-    _f8x = rand() % 84;
-    _f9x = rand() % 84;
-    _f10x = rand() % 84;
-    _f1y = rand() % 84;
-    _f2y = rand() % 84;
-    _f3y = rand() % 84;
-    _f4y = rand() % 84;
-    _f5y = rand() % 84;
-    _f6y = rand() % 84;
-    _f7y = rand() % 84;
-    _f8y = rand() % 84;
-    _f9y = rand() % 84;
-    _f10y = rand() % 84;
+// screen WIDTH =84 and FLOORS_WIDTH = 10
+// x- coordinate of floors position is fixed
+    _f1x = rand() % 9 + 2; // random floors position between 2 and 9
+    _f2x = rand() % 17 + 10; // random position between 10 and 17...
+    _f3x = rand() % 25 + 18;
+    _f4x = rand() % 33 + 26;
+    _f5x = rand() % 41 + 34;
+    _f6x = rand() % 49 + 42;
+    _f7x = rand() % 57 + 50;
+    _f8x = rand() % 65 + 58;
+    _f9x = rand() % 73 + 66;
+    _f10x = rand() % 81 + 74;
+
+// screen HEIGHT = 48 and FLOORS_HEIGHT = 2
+// y -coordinate for each floor position (depends on doodler)
+    _f1y = rand() % 24 + 2; // random floors position between 24 and 2
+    _f2y = rand() % 46 + 25; // random between 46 and 25
+    _f3y = rand() % 24 + 2;// random between 24 and 2
+    _f4y = rand() % 46 + 25;// random between 46 and 25
+    _f5y = rand() % 24 + 2;// random between 24 and 2
+    _f6y = rand() % 46 + 25;// random between 46 and 25
+    _f7y = rand() % 24 + 2;// random between 24 and 2
+    _f8y = rand() % 46 + 25;// random between 46 and 25
+    _f9y = rand() % 24 + 2;// random between 24 and 2
+    _f10y = rand() % 46 + 25;// random between 46 and 25
     
-    _f1.init(_f1x, _f1y, _floors_height, _floors_width);
-    _f2.init(_f2x, _f2y, _floors_height, _floors_width);
-    _f3.init(_f3x, _f3y, _floors_height, _floors_width);
-    _f4.init(_f4x, _f4y, _floors_height, _floors_width);
-    _f5.init(_f5x, _f5y, _floors_height, _floors_width);
-    _f6.init(_f6x, _f6y, _floors_height, _floors_width);
-    _f7.init(_f7x, _f7y, _floors_height, _floors_width);
-    _f8.init(_f8x, _f8y, _floors_height, _floors_width);
-    _f9.init(_f9x, _f9y, _floors_height, _floors_width);
-    _f10.init(_f10x, _f10y, _floors_height, _floors_width);
+    _f1.init(_f1x, _f1y, _floors_width, _floors_height);
+    _f2.init(_f2x, _f2y, _floors_width, _floors_height);
+    _f3.init(_f3x, _f3y, _floors_width, _floors_height);
+    _f4.init(_f4x, _f4y, _floors_width, _floors_height);
+    _f5.init(_f5x, _f5y, _floors_width, _floors_height);
+    _f6.init(_f6x, _f6y, _floors_width, _floors_height);
+    _f7.init(_f7x, _f7y, _floors_width, _floors_height);
+    _f8.init(_f8x, _f8y, _floors_width, _floors_height);
+    _f9.init(_f9x, _f9y, _floors_width, _floors_height);
+    _f10.init(_f10x, _f10y, _floors_width, _floors_height);
 }
 
 void Engine::draw(N5110 &lcd){