Haoyan Zhang
/
el17h2z1
deemo1
Acid/Acid.cpp@5:32dbfaf578dd, 2020-05-14 (annotated)
- Committer:
- haoyan
- Date:
- Thu May 14 05:21:50 2020 +0000
- Revision:
- 5:32dbfaf578dd
- Parent:
- 4:9fa0c5edd1a1
- Child:
- 6:b59bc5e15cf3
final
Who changed what in which revision?
User | Revision | Line number | New 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 | 5:32dbfaf578dd | 25 | _velocity.y = 2*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 |