Haoyan Zhang
/
el17h2z1
deemo1
Acid/Acid.cpp
- Committer:
- haoyan
- Date:
- 2020-05-14
- Revision:
- 5:32dbfaf578dd
- Parent:
- 4:9fa0c5edd1a1
- Child:
- 6:b59bc5e15cf3
File content as of revision 5:32dbfaf578dd:
#include "Acid.h" Acid::Acid() { } Acid::~Acid() { } void Acid::init(int height,int width,int speed) { Vector2D Boss_pos = _Boss.get_pos(); _width = width; _height = height; // Set Acid's position _x = Boss_pos.x + 3; _y = Boss_pos.y + 5; srand(time(NULL)); _velocity.x = 0; _velocity.y = 2*speed; } void Acid::draw(N5110 &lcd) { lcd.drawRect(_x,_y,_width,_height,FILL_BLACK); } void Acid::update() { _x += _velocity.x; _y += _velocity.y; } void Acid::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } Vector2D Acid::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } Vector2D Acid::get_pos() { Vector2D p = {_x,_y}; return p; } void Acid::set_pos(Vector2D p) { _x = p.x; _y = p.y; }