ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Committer:
el17m2h
Date:
Wed Apr 10 19:07:41 2019 +0000
Revision:
3:116913e97fd7
Parent:
2:360a6c301a4e
Child:
4:8ec314f806ae
I added 10 floors and made their position be random on the screen. I divided these in ranges in order to avoid the collision of the floors and also changed the width to have a random length between 10 and 15.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17m2h 2:360a6c301a4e 1 #include "Engine.h"
el17m2h 2:360a6c301a4e 2
el17m2h 2:360a6c301a4e 3 Engine::Engine(){
el17m2h 2:360a6c301a4e 4 }
el17m2h 2:360a6c301a4e 5 Engine::~Engine(){
el17m2h 2:360a6c301a4e 6 }
el17m2h 2:360a6c301a4e 7
el17m2h 3:116913e97fd7 8 void Engine::init(int floors_width, int floors_height){
el17m2h 2:360a6c301a4e 9 _floors_height = floors_height;
el17m2h 2:360a6c301a4e 10 _floors_width = floors_width;
el17m2h 2:360a6c301a4e 11
el17m2h 3:116913e97fd7 12 // screen WIDTH =84 and FLOORS_WIDTH = 10
el17m2h 3:116913e97fd7 13 // x- coordinate of floors position is fixed
el17m2h 3:116913e97fd7 14 _f1x = rand() % 9 + 2; // random floors position between 2 and 9
el17m2h 3:116913e97fd7 15 _f2x = rand() % 17 + 10; // random position between 10 and 17...
el17m2h 3:116913e97fd7 16 _f3x = rand() % 25 + 18;
el17m2h 3:116913e97fd7 17 _f4x = rand() % 33 + 26;
el17m2h 3:116913e97fd7 18 _f5x = rand() % 41 + 34;
el17m2h 3:116913e97fd7 19 _f6x = rand() % 49 + 42;
el17m2h 3:116913e97fd7 20 _f7x = rand() % 57 + 50;
el17m2h 3:116913e97fd7 21 _f8x = rand() % 65 + 58;
el17m2h 3:116913e97fd7 22 _f9x = rand() % 73 + 66;
el17m2h 3:116913e97fd7 23 _f10x = rand() % 81 + 74;
el17m2h 3:116913e97fd7 24
el17m2h 3:116913e97fd7 25 // screen HEIGHT = 48 and FLOORS_HEIGHT = 2
el17m2h 3:116913e97fd7 26 // y -coordinate for each floor position (depends on doodler)
el17m2h 3:116913e97fd7 27 _f1y = rand() % 24 + 2; // random floors position between 24 and 2
el17m2h 3:116913e97fd7 28 _f2y = rand() % 46 + 25; // random between 46 and 25
el17m2h 3:116913e97fd7 29 _f3y = rand() % 24 + 2;// random between 24 and 2
el17m2h 3:116913e97fd7 30 _f4y = rand() % 46 + 25;// random between 46 and 25
el17m2h 3:116913e97fd7 31 _f5y = rand() % 24 + 2;// random between 24 and 2
el17m2h 3:116913e97fd7 32 _f6y = rand() % 46 + 25;// random between 46 and 25
el17m2h 3:116913e97fd7 33 _f7y = rand() % 24 + 2;// random between 24 and 2
el17m2h 3:116913e97fd7 34 _f8y = rand() % 46 + 25;// random between 46 and 25
el17m2h 3:116913e97fd7 35 _f9y = rand() % 24 + 2;// random between 24 and 2
el17m2h 3:116913e97fd7 36 _f10y = rand() % 46 + 25;// random between 46 and 25
el17m2h 2:360a6c301a4e 37
el17m2h 3:116913e97fd7 38 _f1.init(_f1x, _f1y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 39 _f2.init(_f2x, _f2y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 40 _f3.init(_f3x, _f3y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 41 _f4.init(_f4x, _f4y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 42 _f5.init(_f5x, _f5y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 43 _f6.init(_f6x, _f6y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 44 _f7.init(_f7x, _f7y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 45 _f8.init(_f8x, _f8y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 46 _f9.init(_f9x, _f9y, _floors_width, _floors_height);
el17m2h 3:116913e97fd7 47 _f10.init(_f10x, _f10y, _floors_width, _floors_height);
el17m2h 2:360a6c301a4e 48 }
el17m2h 2:360a6c301a4e 49
el17m2h 2:360a6c301a4e 50 void Engine::draw(N5110 &lcd){
el17m2h 2:360a6c301a4e 51 _f1.draw(lcd);
el17m2h 2:360a6c301a4e 52 _f2.draw(lcd);
el17m2h 2:360a6c301a4e 53 _f3.draw(lcd);
el17m2h 2:360a6c301a4e 54 _f4.draw(lcd);
el17m2h 2:360a6c301a4e 55 _f5.draw(lcd);
el17m2h 2:360a6c301a4e 56 _f6.draw(lcd);
el17m2h 2:360a6c301a4e 57 _f7.draw(lcd);
el17m2h 2:360a6c301a4e 58 _f8.draw(lcd);
el17m2h 2:360a6c301a4e 59 _f9.draw(lcd);
el17m2h 2:360a6c301a4e 60 _f10.draw(lcd);
el17m2h 2:360a6c301a4e 61
el17m2h 2:360a6c301a4e 62 }