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/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 ;
}