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@5:8814d6de77d0, 2019-04-13 (annotated)
- Committer:
- el17m2h
- Date:
- Sat Apr 13 17:37:52 2019 +0000
- Revision:
- 5:8814d6de77d0
- Parent:
- 3:116913e97fd7
- Child:
- 7:0d9cee90ab0d
Created an update function for the doodler to change its position depending on the user moving the joystick left or right.
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 | 3:116913e97fd7 | 7 | |
el17m2h | 3:116913e97fd7 | 8 | void Floors::init(int x, int y, int width, int height){ |
el17m2h | 1:0001cb3eb053 | 9 | _height = height; |
el17m2h | 1:0001cb3eb053 | 10 | _width = width; |
el17m2h | 3:116913e97fd7 | 11 | |
el17m2h | 3:116913e97fd7 | 12 | _x = x; |
el17m2h | 3:116913e97fd7 | 13 | _y = y; |
el17m2h | 1:0001cb3eb053 | 14 | |
el17m2h | 1:0001cb3eb053 | 15 | _velocity.x = 0; |
el17m2h | 3:116913e97fd7 | 16 | _velocity.y = 0; |
el17m2h | 1:0001cb3eb053 | 17 | } |
el17m2h | 1:0001cb3eb053 | 18 | |
el17m2h | 1:0001cb3eb053 | 19 | void Floors::draw(N5110 &lcd){ |
el17m2h | 3:116913e97fd7 | 20 | lcd.drawRect(_x, _y, _width, _height, FILL_BLACK); |
el17m2h | 1:0001cb3eb053 | 21 | } |
el17m2h | 1:0001cb3eb053 | 22 | |
el17m2h | 5:8814d6de77d0 | 23 | void Floors::update(){ |
el17m2h | 5:8814d6de77d0 | 24 | } |
el17m2h | 5:8814d6de77d0 | 25 | |
el17m2h | 1:0001cb3eb053 | 26 | |
el17m2h | 1:0001cb3eb053 | 27 | void Floors::set_velocity(Vector2D v){ |
el17m2h | 1:0001cb3eb053 | 28 | _velocity.x = v.x; |
el17m2h | 1:0001cb3eb053 | 29 | _velocity.y = v.y; |
el17m2h | 1:0001cb3eb053 | 30 | } |
el17m2h | 1:0001cb3eb053 | 31 | |
el17m2h | 1:0001cb3eb053 | 32 | Vector2D Floors::get_velocity(){ |
el17m2h | 1:0001cb3eb053 | 33 | Vector2D v = {_velocity.x,_velocity.y}; |
el17m2h | 1:0001cb3eb053 | 34 | return v; |
el17m2h | 1:0001cb3eb053 | 35 | } |
el17m2h | 1:0001cb3eb053 | 36 | |
el17m2h | 1:0001cb3eb053 | 37 | Vector2D Floors::get_pos(){ |
el17m2h | 1:0001cb3eb053 | 38 | Vector2D p = {_x,_y}; |
el17m2h | 1:0001cb3eb053 | 39 | return p; |
el17m2h | 1:0001cb3eb053 | 40 | } |
el17m2h | 1:0001cb3eb053 | 41 | |
el17m2h | 1:0001cb3eb053 | 42 | void Floors::set_pos(Vector2D p){ |
el17m2h | 1:0001cb3eb053 | 43 | _x = p.x; |
el17m2h | 1:0001cb3eb053 | 44 | _y = p.y; |
el17m2h | 1:0001cb3eb053 | 45 | } |