ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Engine/Engine.cpp

Committer:
el17m2h
Date:
2019-04-10
Revision:
3:116913e97fd7
Parent:
2:360a6c301a4e
Child:
4:8ec314f806ae

File content as of revision 3:116913e97fd7:

#include "Engine.h"

Engine::Engine(){
}
Engine::~Engine(){
}

void Engine::init(int floors_width, int floors_height){
    _floors_height = floors_height;
    _floors_width = floors_width;

// 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_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){
    _f1.draw(lcd);
    _f2.draw(lcd);
    _f3.draw(lcd);
    _f4.draw(lcd);
    _f5.draw(lcd);
    _f6.draw(lcd);
    _f7.draw(lcd);
    _f8.draw(lcd);
    _f9.draw(lcd);
    _f10.draw(lcd);
    
}