This is the description

Dependencies:   mbed Menu Joystick

Plane/Plane.cpp

Committer:
mrkang
Date:
2020-04-27
Revision:
1:099632454013
Parent:
0:59cbc5800eb6

File content as of revision 1:099632454013:

#include "Plane.h"
Plane::Plane()
{

}
Plane::~Plane()
{
    
}
void Plane::init(int x,int y,int sizeX,int sizeY)
{
    _x=x;
    _y=y;
    _sizeX = sizeX;
    _sizeY = sizeY;
    _speed = 4;
}
void Plane::draw(N5110 &lcd)
{
    int _Plane[] = {
        0,0,0,0,1,0,0,0,0,0,
        0,0,0,1,1,1,0,0,0,0,
        0,0,0,1,0,1,0,0,0,0,
        0,0,0,1,1,1,0,0,0,0,
        0,0,1,1,1,1,1,0,0,0,
        0,1,1,1,1,1,1,1,0,0,
        1,1,1,1,1,1,1,1,1,0,
        0,0,0,1,1,1,0,0,0,0,
        0,0,0,1,0,1,0,0,0,0,
        0,0,0,1,0,1,0,0,0,0 };
        
        Bitmap sprite(_Plane, _sizeX, _sizeY);
        sprite.render(lcd, _x, _y);
}
void Plane::update(int d)
{
    if(d == 3){
        _x+=_speed;
         if(_x>75){
             _x = 75;
        }
    }else if(d == 7){
        _x=_speed;
        if(_x<0){
            _x = 0;
        }
    }
}
Vector2D Plane::getPos(){
    Vector2D p ={_x,_y};
    return p;
}