Rex Raj / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

EnemyBeam/EnemyBeam2.cpp

Committer:
RexRoshan
Date:
2019-04-13
Revision:
0:99fa5a619081
Child:
4:4d673fb2d9dc

File content as of revision 0:99fa5a619081:

#include "EnemyBeam2.h"

EnemyBeam2::EnemyBeam2()
{

}

EnemyBeam2::~EnemyBeam2()
{

}

void EnemyBeam2::init(int size,int a, int b ,int c, int d)
{
    _size = size;
    _x = _size;
    _y = _size;
    _a = a;
    _b = b + 5;
    _c = c;
    _d = d;
}

void EnemyBeam2::draw(N5110 &lcd)
{
    lcd.drawRect(_a,_b,_x,_y,FILL_BLACK);
    lcd.drawRect(_c,_d,_x,_y,FILL_BLACK);
}

void EnemyBeam2::update()
{
    _speed = 5.0;  // scale is arbitrary, could be changed in future

    // update y value depending on direction of movement
    // North is decrement as origin is at the top-left so decreasing moves up
        _a-=_speed;
        _c-=_speed;
    
}

Vector2D EnemyBeam2::get_pos_21()
{
    Vector2D b = {_a,_b};
    return b;
}

Vector2D EnemyBeam2::get_pos_22()
{
    Vector2D c = {_c,_d};
    return c;
}

void EnemyBeam2::set_pos_21(Vector2D p)
{
    _a = p.x ;
    _b = p.y ;
}

void EnemyBeam2::set_pos_22(Vector2D p)
{
    _c = p.x ;
    _d = p.y ;
}