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.
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 }
Generated on Wed Jul 13 2022 13:02:18 by
