RUOFAN LI / Mbed 2 deprecated el17rl

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UFO.cpp Source File

UFO.cpp

00001 #include "UFO.h"
00002 
00003 UFO::UFO()
00004 {
00005  
00006 }
00007 UFO::~UFO()
00008 {
00009     
00010 }
00011 
00012 void UFO::init(int width,int height, int speed){
00013 
00014     _width = width;
00015     _height = height; // define the size of UFO
00016     _x = rand() % (84- _width);
00017     _y = 0; 
00018     _speed=2;
00019 }
00020 
00021 Vector2D UFO::getPos()
00022 {
00023     Vector2D p = {_x,_y};
00024     return p;
00025 }
00026 void UFO::update()
00027 {
00028     _y+=_speed;
00029 }
00030 void UFO::setBlood(int get_shot){ 
00031     _blood -= get_shot; 
00032 }
00033 void UFO::draw(N5110 &lcd)
00034 {
00035     //different ufo shapes for each level
00036     int UFO[5][12] =   {
00037      1,1,1,1,1,1,1,1,1,1,1,1 ,
00038      1,1,1,0,0,0,0,0,0,1,1,1 ,
00039      1,1,1,0,0,0,0,0,0,1,1,1 ,
00040      1,1,1,0,0,0,0,0,0,1,1,1 ,
00041      1,1,1,1,1,1,1,1,1,1,1,1 };
00042 
00043         Bitmap sprite(enemy, _width, _height); 
00044         sprite.render(lcd, _x, _y); 
00045 }
00046 int UFO::getBlood(){
00047     return _blood;
00048 }
00049 void UFO::setSpeed(int speed){
00050     _speed = speed;
00051 }
00052 int UFO::getSpeed(){
00053     return _speed;
00054 }