Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Acid/Acid.cpp
- Committer:
- haoyan
- Date:
- 2020-05-14
- Revision:
- 6:b59bc5e15cf3
- Parent:
- 5:32dbfaf578dd
File content as of revision 6:b59bc5e15cf3:
#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 = 1.5*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;
}