ELEC2645 (2018/19) / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

SpacecraftBeam/Beam.cpp

Committer:
RexRoshan
Date:
2019-05-09
Revision:
0:d9cf94b41df3

File content as of revision 0:d9cf94b41df3:

#include "Beam.h"

Beam::Beam()
{

}

Beam::~Beam()
{

}

void Beam::init(int size,int a, int b) // Initialise the size, x and y position of the beam
{
    _size = size;
    _x = _size;  // length of the beam
    _y = 1;      // height of the beam
    _a = a + 11; // x position of the beam
    _b = b + 5;  // y position of the beam
}

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

void Beam::update()
{
    _speed = 5.0;  // sets the movement speed of the beam to be 5

    _a+=_speed;    // moves in the x direction
    
}

Vector2D Beam::get_pos()
{
    // Gets the position of the beam
    Vector2D b = {_a,_b};
    return b;
}

void Beam::set_pos(Vector2D p)
{
    // Sets the position  of the beam
    _a = p.x ;
    _b = p.y ;
}