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
Diff: People/People.cpp
- Revision:
- 2:67b51ee7fc34
- Child:
- 3:b8fbaefc496c
diff -r b133934e0d45 -r 67b51ee7fc34 People/People.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/People/People.cpp Sun Apr 12 04:35:32 2020 +0000 @@ -0,0 +1,64 @@ +#include "People.h" +#define INIT_x 40 +#define INIT_y 20 + + +const int people_sprite[4][4] = { + {0,1,1,0}, + {1,1,1,1}, + {0,1,1,0}, + {0,1,1,0}, +};//try to simulate a people, but for the operability of game, seems not good + +People::People() { + +} + +People::~People() { + +} + +void People::init() { + + _x = INIT_x; + _y = INIT_y;//Set initial postion of people +} +void People::draw(N5110 &lcd) { + + //Draw sprite to represent a people + lcd.drawSprite(_x,_y,4,4,(int*)people_sprite); + printf("drawSprite"); +} + +void People::update() +{ + _x += _velocity.x; + _y += _velocity.y; +} + +void People::set_pos(Vector2D p) +{ + _x = p.x; + _y = p.y; +} + +void People::set_velocity(Vector2D v) +{ + _velocity.x = v.x; + _velocity.y = v.y; +} + +Vector2D People::get_pos() +{ + Vector2D p = {_x,_y}; + return p; +} + +Vector2D People::get_velocity() +{ + Vector2D v = {_velocity.x,_velocity.y}; + return v; +} + + + \ No newline at end of file