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
Fork of el17zl by
Ppl/Ppl.cpp
- Committer:
- franklzw
- Date:
- 2019-04-09
- Revision:
- 5:b50ce6160013
- Parent:
- 4:750d3f9b54de
- Child:
- 6:6b083e22cb53
File content as of revision 5:b50ce6160013:
#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(int bb,int ba,int bx,int by)
{
if (bx ==0 && bb == 0 && by == 0 && ba == 0){
_x = _x;
_y = _y;
}
if (bx == 1){
_x = _x-8;
_y = _y;
}
if (bb == 1){
_x = _x+8;
_y = _y;
}
if (by == 1){
_y = _y-8;
_x = _x;
}
if (ba == 1){
_y = _y+8;
_x = _x;
}
// check the y origin to ensure that the paddle doesn't go off screen
if (_y < 4) {
_y = 4;
}
if (_y > 36) {
_y = 36;
}
if (_x > 74) {
_x = 74;
}
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;
}
