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@2:360a6c301a4e, 2019-04-10 (annotated)
- Committer:
- el17m2h
- Date:
- Wed Apr 10 17:34:02 2019 +0000
- Revision:
- 2:360a6c301a4e
- Parent:
- 1:0001cb3eb053
- Child:
- 3:116913e97fd7
I created an engine .cpp and .h file to add 10 floors to the screen once the button start is pressed and I used the rand syntax to place them in random positions within the screen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17m2h | 1:0001cb3eb053 | 1 | #include "Floors.h" |
el17m2h | 1:0001cb3eb053 | 2 | |
el17m2h | 1:0001cb3eb053 | 3 | Floors::Floors(){ |
el17m2h | 1:0001cb3eb053 | 4 | } |
el17m2h | 1:0001cb3eb053 | 5 | Floors::~Floors(){ |
el17m2h | 1:0001cb3eb053 | 6 | } |
el17m2h | 2:360a6c301a4e | 7 | // screen WIDTH =84 and HEIGHT = 48 |
el17m2h | 2:360a6c301a4e | 8 | |
el17m2h | 2:360a6c301a4e | 9 | void Floors::init(int _x, int _y, int height, int width){ |
el17m2h | 1:0001cb3eb053 | 10 | _height = height; |
el17m2h | 1:0001cb3eb053 | 11 | _width = width; |
el17m2h | 2:360a6c301a4e | 12 | |
el17m2h | 2:360a6c301a4e | 13 | |
el17m2h | 1:0001cb3eb053 | 14 | |
el17m2h | 1:0001cb3eb053 | 15 | _velocity.x = 0; |
el17m2h | 1:0001cb3eb053 | 16 | _velocity.y = 1; |
el17m2h | 1:0001cb3eb053 | 17 | } |
el17m2h | 1:0001cb3eb053 | 18 | |
el17m2h | 1:0001cb3eb053 | 19 | void Floors::draw(N5110 &lcd){ |
el17m2h | 1:0001cb3eb053 | 20 | lcd.drawRect(_x, _y, _height, _width,FILL_BLACK); |
el17m2h | 1:0001cb3eb053 | 21 | } |
el17m2h | 1:0001cb3eb053 | 22 | |
el17m2h | 1:0001cb3eb053 | 23 | |
el17m2h | 1:0001cb3eb053 | 24 | void Floors::set_velocity(Vector2D v){ |
el17m2h | 1:0001cb3eb053 | 25 | _velocity.x = v.x; |
el17m2h | 1:0001cb3eb053 | 26 | _velocity.y = v.y; |
el17m2h | 1:0001cb3eb053 | 27 | } |
el17m2h | 1:0001cb3eb053 | 28 | |
el17m2h | 1:0001cb3eb053 | 29 | Vector2D Floors::get_velocity(){ |
el17m2h | 1:0001cb3eb053 | 30 | Vector2D v = {_velocity.x,_velocity.y}; |
el17m2h | 1:0001cb3eb053 | 31 | return v; |
el17m2h | 1:0001cb3eb053 | 32 | } |
el17m2h | 1:0001cb3eb053 | 33 | |
el17m2h | 1:0001cb3eb053 | 34 | Vector2D Floors::get_pos(){ |
el17m2h | 1:0001cb3eb053 | 35 | Vector2D p = {_x,_y}; |
el17m2h | 1:0001cb3eb053 | 36 | return p; |
el17m2h | 1:0001cb3eb053 | 37 | } |
el17m2h | 1:0001cb3eb053 | 38 | |
el17m2h | 1:0001cb3eb053 | 39 | void Floors::set_pos(Vector2D p){ |
el17m2h | 1:0001cb3eb053 | 40 | _x = p.x; |
el17m2h | 1:0001cb3eb053 | 41 | _y = p.y; |
el17m2h | 1:0001cb3eb053 | 42 | } |