Projectile Library

Projectile.cpp

Committer:
ll14c4p
Date:
2017-04-29
Revision:
2:b079859c59ba
Parent:
1:2aee0cb1ebf9
Child:
3:70c599d9f191

File content as of revision 2:b079859c59ba:

#include "Projectile.h"
#include "Player.h"

Projectile::Projectile()
{

}

Projectile::~Projectile()
{

}

void Projectile::init(int size,int speed)
{
    _size = 1;
    //Make intial position of projectile = centre of player
    _velocity.x = 0;
    _velocity.y = speed;
    _x = playerx;
    _y = playery;
}

void Projectile::draw(N5110 &lcd)
{
    lcd.drawRect(_x,_y,_size,_size,FILL_BLACK);
}

void Projectile::update()
{
    _x += _velocity.x;
    _y += _velocity.y;
}

void Projectile::set_velocity(Vector2D v)
{
    _velocity.x = 3;
    _velocity.y = 3;
}

Vector2D Projectile::get_velocity()
{
    Vector2D v = {_velocity.x,_velocity.y};
    return v;
}

Vector2D Projectile::get_pos()
{
    Vector2D ppos = {_x,_y};
    return ppos;
}

void Projectile::set_pos(Vector2D p)
{
    _x = p.x;
    _y = p.y;
}