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
People/People.cpp
- Committer:
- el19zf
- Date:
- 2020-04-12
- Revision:
- 2:67b51ee7fc34
- Child:
- 3:b8fbaefc496c
File content as of revision 2:67b51ee7fc34:
#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; }