ELEC2645 (2018/19) / Mbed 2 deprecated el17zl

Dependencies:   mbed

Fork of el17zl by Zhenwen Liao

Ppl/Ppl.cpp

Committer:
franklzw
Date:
2019-03-24
Revision:
3:9fa31396d89d
Child:
4:750d3f9b54de

File content as of revision 3:9fa31396d89d:

#include "Ppl.h"

const int ppl[8][8]= {
    {0,0,0,0,1,1,1,0},
    {0,0,0,0,1,0,1,0},
    {0,0,0,0,1,1,1,0},
    {1,0,0,0,0,1,0,0},
    {0,1,1,0,0,1,0,0},
    {0,0,0,1,1,1,0,0},
    {0,0,0,0,0,1,0,0},
    {0,0,0,1,1,0,1,1},

};

Ppl::Ppl()
{

}

Ppl::~Ppl()
{

}

void Ppl::init(int x0, int y0)
{
    _x = x0;
    _y = y0;

}

void Ppl::draw(N5110 &lcd)
{
    lcd.drawSprite(_x,_y,8,8,(int *)ppl);
}

void Ppl::update()
{
   
    // check the y origin to ensure that the paddle doesn't go off screen
    if (_y < 4) {
        _y = 4;
    }
    if (_y > 37) {
        _y = 37;
    }
    if (_x > 75) {
        _x = 75;
    }
    if (_x < 2) {
        _x = 2;
    }
}

Vector2D Ppl::get_pos()
{
    Vector2D p = {_x,_y};
    return p;
}

void Ppl::set_pos(Vector2D p)
{
    _x = p.x;
    _y = p.y;
}