deemo1

Dependencies:   mbed

Boss/Boss.cpp

Committer:
haoyan
Date:
2020-05-14
Revision:
6:b59bc5e15cf3
Parent:
5:32dbfaf578dd

File content as of revision 6:b59bc5e15cf3:

#include "Boss.h"

Boss::Boss()
{
    
}

Boss::~Boss()
{
    
}

int Bosss[4][6] = {
    {1,1,1,1,1,1},
    {1,1,1,1,1,1},
    {0,0,1,1,0,0},
    {0,0,1,1,0,0},
};

void Boss::init(int height, int width, int speed)
{
     _height = height;
     _width = width;
     _x = rand() % 65;  //set the boss original position
     _y = 2;
     
     srand(time(NULL));

     _velocity.x = 0;
     _velocity.y = speed;
}    
     
void Boss::draw(N5110 &lcd)     
{
     lcd.drawSprite(_x,_y,_height,_width,(int*)Bosss);  
}

void Boss::update()
{
    _x += _velocity.x;
    _y += _velocity.y;
}   
     
void Boss::set_velocity(Vector2D v)
{
    _velocity.x = v.x;
    _velocity.y = v.y;
}

Vector2D Boss::get_velocity()
{
    Vector2D v = {_velocity.x,_velocity.y};
    return v;
}
 
Vector2D Boss::get_pos()
{
    Vector2D p = {_x,_y};
    return p;
}
 
void Boss::set_pos(Vector2D p)
{
    _x = p.x;
    _y = p.y;
}