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.
Dependencies: mbed Gamepad N5110 mbed-rtos
EnemyBeam/EnemyBeam.cpp
- Committer:
- RexRoshan
- Date:
- 2019-05-09
- Revision:
- 14:c7302ffe6eab
- Parent:
- 7:574c66ebd8b0
File content as of revision 14:c7302ffe6eab:
#include "EnemyBeam.h"
EnemyBeam::EnemyBeam()
{
}
EnemyBeam::~EnemyBeam()
{
}
void EnemyBeam::init(int size,int a, int b) // initialising beam for the enemy in the first stage
{
_size = size; // size of the beam
_x = _size; // length of the beam
_y = 1; // height of the beam
_a = a; // x position of the enemy beam
_b = b + 4; // y position of the enemy beam
}
void EnemyBeam::draw(N5110 &lcd)
{
// draws the beam of the first stage enemy
lcd.drawRect(_a,_b,_x,_y,FILL_BLACK);
}
void EnemyBeam::update()
{
_speed = 5.0; // the speed of the beam moving is set at 5
_a-=_speed; // the beam moves in the negative x direction
}
Vector2D EnemyBeam::get_pos()
{
// gets the position of the enemy beam
Vector2D b = {_a,_b};
return b;
}
void EnemyBeam::set_pos(Vector2D p)
{
// sets the position of the enemy beam
_a = p.x ;
_b = p.y ;
}