ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19zf

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;
}