deemo1

Dependencies:   mbed

Committer:
haoyan
Date:
Thu May 14 06:30:39 2020 +0000
Revision:
6:b59bc5e15cf3
Parent:
5:32dbfaf578dd
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
haoyan 4:9fa0c5edd1a1 1 #include "Acid.h"
haoyan 4:9fa0c5edd1a1 2
haoyan 4:9fa0c5edd1a1 3 Acid::Acid()
haoyan 4:9fa0c5edd1a1 4 {
haoyan 4:9fa0c5edd1a1 5
haoyan 4:9fa0c5edd1a1 6 }
haoyan 4:9fa0c5edd1a1 7
haoyan 4:9fa0c5edd1a1 8 Acid::~Acid()
haoyan 4:9fa0c5edd1a1 9 {
haoyan 4:9fa0c5edd1a1 10
haoyan 4:9fa0c5edd1a1 11 }
haoyan 4:9fa0c5edd1a1 12
haoyan 4:9fa0c5edd1a1 13 void Acid::init(int height,int width,int speed)
haoyan 4:9fa0c5edd1a1 14 {
haoyan 4:9fa0c5edd1a1 15 Vector2D Boss_pos = _Boss.get_pos();
haoyan 4:9fa0c5edd1a1 16 _width = width;
haoyan 4:9fa0c5edd1a1 17 _height = height;
haoyan 4:9fa0c5edd1a1 18 // Set Acid's position
haoyan 4:9fa0c5edd1a1 19 _x = Boss_pos.x + 3;
haoyan 4:9fa0c5edd1a1 20 _y = Boss_pos.y + 5;
haoyan 4:9fa0c5edd1a1 21
haoyan 4:9fa0c5edd1a1 22 srand(time(NULL));
haoyan 4:9fa0c5edd1a1 23
haoyan 4:9fa0c5edd1a1 24 _velocity.x = 0;
haoyan 6:b59bc5e15cf3 25 _velocity.y = 1.5*speed;
haoyan 4:9fa0c5edd1a1 26
haoyan 4:9fa0c5edd1a1 27 }
haoyan 4:9fa0c5edd1a1 28
haoyan 4:9fa0c5edd1a1 29 void Acid::draw(N5110 &lcd)
haoyan 4:9fa0c5edd1a1 30 {
haoyan 4:9fa0c5edd1a1 31 lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
haoyan 4:9fa0c5edd1a1 32 }
haoyan 4:9fa0c5edd1a1 33
haoyan 4:9fa0c5edd1a1 34 void Acid::update()
haoyan 4:9fa0c5edd1a1 35 {
haoyan 4:9fa0c5edd1a1 36 _x += _velocity.x;
haoyan 4:9fa0c5edd1a1 37 _y += _velocity.y;
haoyan 4:9fa0c5edd1a1 38 }
haoyan 4:9fa0c5edd1a1 39
haoyan 4:9fa0c5edd1a1 40 void Acid::set_velocity(Vector2D v)
haoyan 4:9fa0c5edd1a1 41 {
haoyan 4:9fa0c5edd1a1 42 _velocity.x = v.x;
haoyan 4:9fa0c5edd1a1 43 _velocity.y = v.y;
haoyan 4:9fa0c5edd1a1 44 }
haoyan 4:9fa0c5edd1a1 45
haoyan 4:9fa0c5edd1a1 46 Vector2D Acid::get_velocity()
haoyan 4:9fa0c5edd1a1 47 {
haoyan 4:9fa0c5edd1a1 48 Vector2D v = {_velocity.x,_velocity.y};
haoyan 4:9fa0c5edd1a1 49 return v;
haoyan 4:9fa0c5edd1a1 50 }
haoyan 4:9fa0c5edd1a1 51
haoyan 4:9fa0c5edd1a1 52 Vector2D Acid::get_pos()
haoyan 4:9fa0c5edd1a1 53 {
haoyan 4:9fa0c5edd1a1 54 Vector2D p = {_x,_y};
haoyan 4:9fa0c5edd1a1 55 return p;
haoyan 4:9fa0c5edd1a1 56 }
haoyan 4:9fa0c5edd1a1 57
haoyan 4:9fa0c5edd1a1 58 void Acid::set_pos(Vector2D p)
haoyan 4:9fa0c5edd1a1 59 {
haoyan 4:9fa0c5edd1a1 60 _x = p.x;
haoyan 4:9fa0c5edd1a1 61 _y = p.y;
haoyan 4:9fa0c5edd1a1 62 }
haoyan 4:9fa0c5edd1a1 63
haoyan 4:9fa0c5edd1a1 64
haoyan 4:9fa0c5edd1a1 65
haoyan 4:9fa0c5edd1a1 66
haoyan 4:9fa0c5edd1a1 67
haoyan 4:9fa0c5edd1a1 68
haoyan 4:9fa0c5edd1a1 69
haoyan 4:9fa0c5edd1a1 70
haoyan 4:9fa0c5edd1a1 71
haoyan 4:9fa0c5edd1a1 72
haoyan 4:9fa0c5edd1a1 73