Li Ruofan 201199450
Dependencies: mbed Gamepad Joystick
UFO/UFO.cpp
- Committer:
- DannyLee
- Date:
- 2020-05-15
- Revision:
- 6:cbd9e1f26a10
- Parent:
- 5:e3a9f0548922
- Child:
- 8:b4a2954dd74f
File content as of revision 6:cbd9e1f26a10:
#include "UFO.h" UFO::UFO() { } UFO::~UFO() { } void UFO::init(int width,int height, int speed){ _width = width; _height = height; // define the size of UFO _x = rand() % (84- _width); _y = 0; _speed=2; } Vector2D UFO::getPos() { Vector2D p = {_x,_y}; return p; } void UFO::update() { _y+=_speed; } void UFO::setBlood(int get_shot){ _blood -= get_shot; } void UFO::draw(N5110 &lcd) { //different ufo shapes for each level int UFO[5][12] = { 1,1,1,1,1,1,1,1,1,1,1,1 , 1,1,1,0,0,0,0,0,0,1,1,1 , 1,1,1,0,0,0,0,0,0,1,1,1 , 1,1,1,0,0,0,0,0,0,1,1,1 , 1,1,1,1,1,1,1,1,1,1,1,1 }; Bitmap sprite(enemy, _width, _height); sprite.render(lcd, _x, _y); } int UFO::getBlood(){ return _blood; } void UFO::setSpeed(int speed){ _speed = speed; } int UFO::getSpeed(){ return _speed; }