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
Floors/Floors.cpp
- Committer:
- el17m2h
- Date:
- 2019-04-17
- Revision:
- 11:2041290b5a74
- Parent:
- 10:e1d2289705ef
- Child:
- 12:c5123abb4fbe
File content as of revision 11:2041290b5a74:
#include "Floors.h" Floors::Floors(){ } Floors::~Floors(){ } void Floors::init(int y, int width, int height){ _height = height; _width = width; // x-coordinate initially random: screen =84 (visible to 84-FLOORS_WIDTH): 0 left, 70 right _pos.x = rand()% 74; _pos.y = y; } void Floors::draw(N5110 &lcd){ lcd.drawRect(_pos.x, _pos.y, _width, _height, FILL_BLACK); } void Floors::update(Vector2D current_pos){ // when they leave the screen they will re-appear in random x-coordinate so that 10 floors are always on screen _pos = current_pos; srand(time(0)); if (_pos.y > 48 ){ _pos.y = 0; _pos.x = rand()% 74; srand(time(0)); } set_pos(_pos); } Vector2D Floors::get_pos(){ Vector2D p = {_pos.x,_pos.y}; return p; } void Floors::set_pos(Vector2D p){ _pos.x = p.x; _pos.y = p.y; }