Li Ruofan 201199450

Dependencies:   mbed Gamepad Joystick

Committer:
DannyLee
Date:
Sat May 16 17:26:10 2020 +0000
Revision:
8:b4a2954dd74f
Parent:
6:cbd9e1f26a10
Debugging

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DannyLee 3:cf9fead9c3f4 1 #include "UFO.h"
DannyLee 3:cf9fead9c3f4 2
DannyLee 5:e3a9f0548922 3 UFO::UFO()
DannyLee 3:cf9fead9c3f4 4 {
DannyLee 5:e3a9f0548922 5
DannyLee 3:cf9fead9c3f4 6 }
DannyLee 3:cf9fead9c3f4 7 UFO::~UFO()
DannyLee 3:cf9fead9c3f4 8 {
DannyLee 3:cf9fead9c3f4 9
DannyLee 3:cf9fead9c3f4 10 }
DannyLee 3:cf9fead9c3f4 11
DannyLee 8:b4a2954dd74f 12 void UFO::init(int sizeX,int sizeY){
DannyLee 3:cf9fead9c3f4 13
DannyLee 8:b4a2954dd74f 14 _sizeX = sizeX;
DannyLee 8:b4a2954dd74f 15 _sizeY = sizeY;
DannyLee 8:b4a2954dd74f 16 _x = rand() % (84- _sizeX);
DannyLee 6:cbd9e1f26a10 17 _y = 0;
DannyLee 6:cbd9e1f26a10 18 _speed=2;
DannyLee 3:cf9fead9c3f4 19 }
DannyLee 3:cf9fead9c3f4 20
DannyLee 3:cf9fead9c3f4 21 Vector2D UFO::getPos()
DannyLee 3:cf9fead9c3f4 22 {
DannyLee 3:cf9fead9c3f4 23 Vector2D p = {_x,_y};
DannyLee 3:cf9fead9c3f4 24 return p;
DannyLee 3:cf9fead9c3f4 25 }
DannyLee 3:cf9fead9c3f4 26 void UFO::update()
DannyLee 3:cf9fead9c3f4 27 {
DannyLee 3:cf9fead9c3f4 28 _y+=_speed;
DannyLee 3:cf9fead9c3f4 29 }
DannyLee 3:cf9fead9c3f4 30 void UFO::setBlood(int get_shot){
DannyLee 6:cbd9e1f26a10 31 _blood -= get_shot;
DannyLee 3:cf9fead9c3f4 32 }
DannyLee 5:e3a9f0548922 33 void UFO::draw(N5110 &lcd)
DannyLee 3:cf9fead9c3f4 34 {
DannyLee 3:cf9fead9c3f4 35 //different ufo shapes for each level
DannyLee 8:b4a2954dd74f 36 int UFO[60] = {
DannyLee 3:cf9fead9c3f4 37 1,1,1,1,1,1,1,1,1,1,1,1 ,
DannyLee 3:cf9fead9c3f4 38 1,1,1,0,0,0,0,0,0,1,1,1 ,
DannyLee 3:cf9fead9c3f4 39 1,1,1,0,0,0,0,0,0,1,1,1 ,
DannyLee 3:cf9fead9c3f4 40 1,1,1,0,0,0,0,0,0,1,1,1 ,
DannyLee 3:cf9fead9c3f4 41 1,1,1,1,1,1,1,1,1,1,1,1 };
DannyLee 5:e3a9f0548922 42
DannyLee 8:b4a2954dd74f 43 Bitmap sprite(UFO, _sizeX, _sizeY);
DannyLee 6:cbd9e1f26a10 44 sprite.render(lcd, _x, _y);
DannyLee 3:cf9fead9c3f4 45 }
DannyLee 3:cf9fead9c3f4 46 int UFO::getBlood(){
DannyLee 3:cf9fead9c3f4 47 return _blood;
DannyLee 3:cf9fead9c3f4 48 }
DannyLee 3:cf9fead9c3f4 49 void UFO::setSpeed(int speed){
DannyLee 3:cf9fead9c3f4 50 _speed = speed;
DannyLee 3:cf9fead9c3f4 51 }
DannyLee 3:cf9fead9c3f4 52 int UFO::getSpeed(){
DannyLee 3:cf9fead9c3f4 53 return _speed;
DannyLee 3:cf9fead9c3f4 54 }