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:
- 12:c5123abb4fbe
- Parent:
- 11:2041290b5a74
- Child:
- 13:10851784af9a
File content as of revision 12:c5123abb4fbe:
#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(){ // when they leave the screen they will re-appear in random x-coordinate so that 10 floors are always on screen _pos = get_pos(); if (_pos.y > 48 ){ _pos.y = 0; _pos.x = rand()% 74; } 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; }