This is the description
Dependencies: mbed Menu Joystick
Diff: Plane/Plane.cpp
- Revision:
- 0:59cbc5800eb6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plane/Plane.cpp Mon Apr 27 14:04:30 2020 +0000 @@ -0,0 +1,52 @@ +#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; +} \ No newline at end of file