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 "EnemyBeam3.h"
RexRoshan 0:d9cf94b41df3 2
RexRoshan 0:d9cf94b41df3 3 EnemyBeam3::EnemyBeam3()
RexRoshan 0:d9cf94b41df3 4 {
RexRoshan 0:d9cf94b41df3 5
RexRoshan 0:d9cf94b41df3 6 }
RexRoshan 0:d9cf94b41df3 7
RexRoshan 0:d9cf94b41df3 8 EnemyBeam3::~EnemyBeam3()
RexRoshan 0:d9cf94b41df3 9 {
RexRoshan 0:d9cf94b41df3 10
RexRoshan 0:d9cf94b41df3 11 }
RexRoshan 0:d9cf94b41df3 12
RexRoshan 0:d9cf94b41df3 13 void EnemyBeam3::init(int size,int a, int b ,int c, int d, int e, int f) // initialising beam for all the enemy in the third 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 boss enemy beam
RexRoshan 0:d9cf94b41df3 19 _b = b + 6; // y position of the boss enemy beam
RexRoshan 0:d9cf94b41df3 20 _c = c; // x position of the first enemy beam
RexRoshan 0:d9cf94b41df3 21 _d = d + 3; // y position of the first enemy beam
RexRoshan 0:d9cf94b41df3 22 _e = e; // x position of the second enemy beam
RexRoshan 0:d9cf94b41df3 23 _f = f + 3; // y position of the second enemy beam
RexRoshan 0:d9cf94b41df3 24 }
RexRoshan 0:d9cf94b41df3 25
RexRoshan 0:d9cf94b41df3 26 void EnemyBeam3::draw(N5110 &lcd)
RexRoshan 0:d9cf94b41df3 27 {
RexRoshan 0:d9cf94b41df3 28 int random = rand()%4;
RexRoshan 0:d9cf94b41df3 29 if(random < 2){
RexRoshan 0:d9cf94b41df3 30 // draws the beam of the enemy boss
RexRoshan 0:d9cf94b41df3 31 lcd.drawRect(_a,_b,_x,_y,FILL_BLACK);
RexRoshan 0:d9cf94b41df3 32 }
RexRoshan 0:d9cf94b41df3 33 // draws the beam of the first regular enemy
RexRoshan 0:d9cf94b41df3 34 lcd.drawRect(_c,_d,_x,_y,FILL_BLACK);
RexRoshan 0:d9cf94b41df3 35 // draws the beam of the second regular enemy
RexRoshan 0:d9cf94b41df3 36 lcd.drawRect(_e,_f,_x,_y,FILL_BLACK);
RexRoshan 0:d9cf94b41df3 37 }
RexRoshan 0:d9cf94b41df3 38
RexRoshan 0:d9cf94b41df3 39 void EnemyBeam3::update()
RexRoshan 0:d9cf94b41df3 40 {
RexRoshan 0:d9cf94b41df3 41 _speed = 5.0; // the speed of the beam moving is set at 5
RexRoshan 0:d9cf94b41df3 42
RexRoshan 0:d9cf94b41df3 43 // moves the enemy beams in the negative x direction
RexRoshan 0:d9cf94b41df3 44 _a-=_speed;
RexRoshan 0:d9cf94b41df3 45 _c-=_speed;
RexRoshan 0:d9cf94b41df3 46 _e-=_speed;
RexRoshan 0:d9cf94b41df3 47
RexRoshan 0:d9cf94b41df3 48 }
RexRoshan 0:d9cf94b41df3 49
RexRoshan 0:d9cf94b41df3 50 Vector2D EnemyBeam3::get_pos_boss()
RexRoshan 0:d9cf94b41df3 51 {
RexRoshan 0:d9cf94b41df3 52 // gets the position of the enemy boss beam
RexRoshan 0:d9cf94b41df3 53 Vector2D b = {_a,_b};
RexRoshan 0:d9cf94b41df3 54 return b;
RexRoshan 0:d9cf94b41df3 55 }
RexRoshan 0:d9cf94b41df3 56
RexRoshan 0:d9cf94b41df3 57 Vector2D EnemyBeam3::get_pos_enemy1()
RexRoshan 0:d9cf94b41df3 58 {
RexRoshan 0:d9cf94b41df3 59 // gets the position of the first enemy beam
RexRoshan 0:d9cf94b41df3 60 Vector2D c = {_c,_d};
RexRoshan 0:d9cf94b41df3 61 return c;
RexRoshan 0:d9cf94b41df3 62 }
RexRoshan 0:d9cf94b41df3 63
RexRoshan 0:d9cf94b41df3 64 Vector2D EnemyBeam3::get_pos_enemy2()
RexRoshan 0:d9cf94b41df3 65 {
RexRoshan 0:d9cf94b41df3 66 // gets the position of the second enemy beam
RexRoshan 0:d9cf94b41df3 67 Vector2D d = {_e,_f};
RexRoshan 0:d9cf94b41df3 68 return d;
RexRoshan 0:d9cf94b41df3 69 }
RexRoshan 0:d9cf94b41df3 70 void EnemyBeam3::set_pos_boss(Vector2D p)
RexRoshan 0:d9cf94b41df3 71 {
RexRoshan 0:d9cf94b41df3 72 // sets the position of the enemy boss beam
RexRoshan 0:d9cf94b41df3 73 _a = p.x ;
RexRoshan 0:d9cf94b41df3 74 _b = p.y ;
RexRoshan 0:d9cf94b41df3 75 }
RexRoshan 0:d9cf94b41df3 76
RexRoshan 0:d9cf94b41df3 77 void EnemyBeam3::set_pos_enemy1(Vector2D p)
RexRoshan 0:d9cf94b41df3 78 {
RexRoshan 0:d9cf94b41df3 79 // gets the position of the first enemy beam
RexRoshan 0:d9cf94b41df3 80 _c = p.x ;
RexRoshan 0:d9cf94b41df3 81 _d = p.y ;
RexRoshan 0:d9cf94b41df3 82 }
RexRoshan 0:d9cf94b41df3 83
RexRoshan 0:d9cf94b41df3 84 void EnemyBeam3::set_pos_enemy2(Vector2D p)
RexRoshan 0:d9cf94b41df3 85 {
RexRoshan 0:d9cf94b41df3 86 // gets the position of the second enemy beam
RexRoshan 0:d9cf94b41df3 87 _e = p.x ;
RexRoshan 0:d9cf94b41df3 88 _f = p.y ;
RexRoshan 0:d9cf94b41df3 89 }