Rex Raj / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 14:23:35 2019 +0000
Revision:
14:c7302ffe6eab
Parent:
5:016a7315b75d
Final Modification

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RexRoshan 0:99fa5a619081 1 #include "EnemyBeam2.h"
RexRoshan 0:99fa5a619081 2
RexRoshan 0:99fa5a619081 3 EnemyBeam2::EnemyBeam2()
RexRoshan 0:99fa5a619081 4 {
RexRoshan 0:99fa5a619081 5
RexRoshan 0:99fa5a619081 6 }
RexRoshan 0:99fa5a619081 7
RexRoshan 0:99fa5a619081 8 EnemyBeam2::~EnemyBeam2()
RexRoshan 0:99fa5a619081 9 {
RexRoshan 0:99fa5a619081 10
RexRoshan 0:99fa5a619081 11 }
RexRoshan 0:99fa5a619081 12
RexRoshan 4:4d673fb2d9dc 13 void EnemyBeam2::init(int size,int a, int b ,int c, int d) // initialising beam for the first and second enemy in the second stage
RexRoshan 0:99fa5a619081 14 {
RexRoshan 4:4d673fb2d9dc 15 _size = size; // size of the beam
RexRoshan 4:4d673fb2d9dc 16 _x = _size; // length of the beam
RexRoshan 4:4d673fb2d9dc 17 _y = _size; // height of the beam
RexRoshan 4:4d673fb2d9dc 18 _a = a; // x position of the first enemy beam
RexRoshan 4:4d673fb2d9dc 19 _b = b + 5; // y position of the first enemy beam
RexRoshan 4:4d673fb2d9dc 20 _c = c; // x position of the second enemy beam
RexRoshan 4:4d673fb2d9dc 21 _d = d; // y position of the second enemy beam
RexRoshan 0:99fa5a619081 22 }
RexRoshan 0:99fa5a619081 23
RexRoshan 0:99fa5a619081 24 void EnemyBeam2::draw(N5110 &lcd)
RexRoshan 0:99fa5a619081 25 {
RexRoshan 4:4d673fb2d9dc 26 // draws the first enemy beam of the second stage
RexRoshan 0:99fa5a619081 27 lcd.drawRect(_a,_b,_x,_y,FILL_BLACK);
RexRoshan 4:4d673fb2d9dc 28 // draws the second enemy beam of the second stage
RexRoshan 0:99fa5a619081 29 lcd.drawRect(_c,_d,_x,_y,FILL_BLACK);
RexRoshan 0:99fa5a619081 30 }
RexRoshan 0:99fa5a619081 31
RexRoshan 0:99fa5a619081 32 void EnemyBeam2::update()
RexRoshan 0:99fa5a619081 33 {
RexRoshan 4:4d673fb2d9dc 34 _speed = 5.0; // the speed of the beam moving is set at 5
RexRoshan 0:99fa5a619081 35
RexRoshan 5:016a7315b75d 36 _a-=_speed; // moves the first enemy beam in the negative x direction
RexRoshan 5:016a7315b75d 37 _c-=_speed; // moves the second enemy beam in the negative x direction
RexRoshan 4:4d673fb2d9dc 38
RexRoshan 4:4d673fb2d9dc 39 // the y direction is kept constant
RexRoshan 0:99fa5a619081 40
RexRoshan 0:99fa5a619081 41 }
RexRoshan 0:99fa5a619081 42
RexRoshan 0:99fa5a619081 43 Vector2D EnemyBeam2::get_pos_21()
RexRoshan 0:99fa5a619081 44 {
RexRoshan 4:4d673fb2d9dc 45 // gets the position of the first enemy beam
RexRoshan 0:99fa5a619081 46 Vector2D b = {_a,_b};
RexRoshan 0:99fa5a619081 47 return b;
RexRoshan 0:99fa5a619081 48 }
RexRoshan 0:99fa5a619081 49
RexRoshan 0:99fa5a619081 50 Vector2D EnemyBeam2::get_pos_22()
RexRoshan 0:99fa5a619081 51 {
RexRoshan 4:4d673fb2d9dc 52 // gets the position of the second enemy beam
RexRoshan 0:99fa5a619081 53 Vector2D c = {_c,_d};
RexRoshan 0:99fa5a619081 54 return c;
RexRoshan 0:99fa5a619081 55 }
RexRoshan 0:99fa5a619081 56
RexRoshan 0:99fa5a619081 57 void EnemyBeam2::set_pos_21(Vector2D p)
RexRoshan 0:99fa5a619081 58 {
RexRoshan 4:4d673fb2d9dc 59 // sets the position of the first enemy beam
RexRoshan 0:99fa5a619081 60 _a = p.x ;
RexRoshan 0:99fa5a619081 61 _b = p.y ;
RexRoshan 0:99fa5a619081 62 }
RexRoshan 0:99fa5a619081 63
RexRoshan 0:99fa5a619081 64 void EnemyBeam2::set_pos_22(Vector2D p)
RexRoshan 0:99fa5a619081 65 {
RexRoshan 4:4d673fb2d9dc 66 // sets the position of the second enemy beam
RexRoshan 0:99fa5a619081 67 _c = p.x ;
RexRoshan 0:99fa5a619081 68 _d = p.y ;
RexRoshan 0:99fa5a619081 69 }