ELEC2645 (2018/19) / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 09:49:35 2019 +0000
Revision:
0:d9cf94b41df3
Documentation has been completed and the code has been slightly modified

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RexRoshan 0:d9cf94b41df3 1 #include "EnemyBeam.h"
RexRoshan 0:d9cf94b41df3 2
RexRoshan 0:d9cf94b41df3 3 EnemyBeam::EnemyBeam()
RexRoshan 0:d9cf94b41df3 4 {
RexRoshan 0:d9cf94b41df3 5
RexRoshan 0:d9cf94b41df3 6 }
RexRoshan 0:d9cf94b41df3 7
RexRoshan 0:d9cf94b41df3 8 EnemyBeam::~EnemyBeam()
RexRoshan 0:d9cf94b41df3 9 {
RexRoshan 0:d9cf94b41df3 10
RexRoshan 0:d9cf94b41df3 11 }
RexRoshan 0:d9cf94b41df3 12
RexRoshan 0:d9cf94b41df3 13 void EnemyBeam::init(int size,int a, int b) // initialising beam for the enemy in the first stage
RexRoshan 0:d9cf94b41df3 14 {
RexRoshan 0:d9cf94b41df3 15 _size = size; // size of the beam
RexRoshan 0:d9cf94b41df3 16 _x = _size; // length of the beam
RexRoshan 0:d9cf94b41df3 17 _y = 1; // height of the beam
RexRoshan 0:d9cf94b41df3 18 _a = a; // x position of the enemy beam
RexRoshan 0:d9cf94b41df3 19 _b = b + 4; // y position of the enemy beam
RexRoshan 0:d9cf94b41df3 20 }
RexRoshan 0:d9cf94b41df3 21
RexRoshan 0:d9cf94b41df3 22 void EnemyBeam::draw(N5110 &lcd)
RexRoshan 0:d9cf94b41df3 23 {
RexRoshan 0:d9cf94b41df3 24 // draws the beam of the first stage enemy
RexRoshan 0:d9cf94b41df3 25 lcd.drawRect(_a,_b,_x,_y,FILL_BLACK);
RexRoshan 0:d9cf94b41df3 26 }
RexRoshan 0:d9cf94b41df3 27
RexRoshan 0:d9cf94b41df3 28 void EnemyBeam::update()
RexRoshan 0:d9cf94b41df3 29 {
RexRoshan 0:d9cf94b41df3 30 _speed = 5.0; // the speed of the beam moving is set at 5
RexRoshan 0:d9cf94b41df3 31
RexRoshan 0:d9cf94b41df3 32 _a-=_speed; // the beam moves in the negative x direction
RexRoshan 0:d9cf94b41df3 33
RexRoshan 0:d9cf94b41df3 34 }
RexRoshan 0:d9cf94b41df3 35
RexRoshan 0:d9cf94b41df3 36 Vector2D EnemyBeam::get_pos()
RexRoshan 0:d9cf94b41df3 37 {
RexRoshan 0:d9cf94b41df3 38 // gets the position of the enemy beam
RexRoshan 0:d9cf94b41df3 39 Vector2D b = {_a,_b};
RexRoshan 0:d9cf94b41df3 40 return b;
RexRoshan 0:d9cf94b41df3 41 }
RexRoshan 0:d9cf94b41df3 42
RexRoshan 0:d9cf94b41df3 43 void EnemyBeam::set_pos(Vector2D p)
RexRoshan 0:d9cf94b41df3 44 {
RexRoshan 0:d9cf94b41df3 45 // sets the position of the enemy beam
RexRoshan 0:d9cf94b41df3 46 _a = p.x ;
RexRoshan 0:d9cf94b41df3 47 _b = p.y ;
RexRoshan 0:d9cf94b41df3 48 }