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@6:1fcfd331c047, 2019-05-08 (annotated)
- Committer:
- RexRoshan
- Date:
- Wed May 08 10:03:24 2019 +0000
- Revision:
- 6:1fcfd331c047
- Parent:
- 5:016a7315b75d
- Child:
- 7:574c66ebd8b0
Documentation has been completed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RexRoshan | 0:99fa5a619081 | 1 | #include "EnemyBeam.h" |
RexRoshan | 0:99fa5a619081 | 2 | |
RexRoshan | 0:99fa5a619081 | 3 | EnemyBeam::EnemyBeam() |
RexRoshan | 0:99fa5a619081 | 4 | { |
RexRoshan | 0:99fa5a619081 | 5 | |
RexRoshan | 0:99fa5a619081 | 6 | } |
RexRoshan | 0:99fa5a619081 | 7 | |
RexRoshan | 0:99fa5a619081 | 8 | EnemyBeam::~EnemyBeam() |
RexRoshan | 0:99fa5a619081 | 9 | { |
RexRoshan | 0:99fa5a619081 | 10 | |
RexRoshan | 0:99fa5a619081 | 11 | } |
RexRoshan | 0:99fa5a619081 | 12 | |
RexRoshan | 4:4d673fb2d9dc | 13 | void EnemyBeam::init(int size,int a, int b) // initialising beam for the enemy in the first 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 = 1; // height of the beam |
RexRoshan | 6:1fcfd331c047 | 18 | _a = a; // x position of the enemy beam |
RexRoshan | 4:4d673fb2d9dc | 19 | _b = b + 4; // y position of the enemy beam |
RexRoshan | 0:99fa5a619081 | 20 | } |
RexRoshan | 0:99fa5a619081 | 21 | |
RexRoshan | 0:99fa5a619081 | 22 | void EnemyBeam::draw(N5110 &lcd) |
RexRoshan | 0:99fa5a619081 | 23 | { |
RexRoshan | 4:4d673fb2d9dc | 24 | // draws the beam of the first stage enemy |
RexRoshan | 0:99fa5a619081 | 25 | lcd.drawRect(_a,_b,_x,_y,FILL_BLACK); |
RexRoshan | 0:99fa5a619081 | 26 | } |
RexRoshan | 0:99fa5a619081 | 27 | |
RexRoshan | 0:99fa5a619081 | 28 | void EnemyBeam::update() |
RexRoshan | 0:99fa5a619081 | 29 | { |
RexRoshan | 5:016a7315b75d | 30 | _speed = 5.0; // the speed of the beam moving is set at 5 |
RexRoshan | 0:99fa5a619081 | 31 | |
RexRoshan | 5:016a7315b75d | 32 | _a-=_speed; // the beam moves in the negative x direction |
RexRoshan | 0:99fa5a619081 | 33 | |
RexRoshan | 0:99fa5a619081 | 34 | } |
RexRoshan | 0:99fa5a619081 | 35 | |
RexRoshan | 0:99fa5a619081 | 36 | Vector2D EnemyBeam::get_pos() |
RexRoshan | 0:99fa5a619081 | 37 | { |
RexRoshan | 4:4d673fb2d9dc | 38 | // gets the position of the enemy beam |
RexRoshan | 0:99fa5a619081 | 39 | Vector2D b = {_a,_b}; |
RexRoshan | 0:99fa5a619081 | 40 | return b; |
RexRoshan | 0:99fa5a619081 | 41 | } |
RexRoshan | 0:99fa5a619081 | 42 | |
RexRoshan | 0:99fa5a619081 | 43 | void EnemyBeam::set_pos(Vector2D p) |
RexRoshan | 0:99fa5a619081 | 44 | { |
RexRoshan | 4:4d673fb2d9dc | 45 | // sets the position of the enemy beam |
RexRoshan | 0:99fa5a619081 | 46 | _a = p.x ; |
RexRoshan | 0:99fa5a619081 | 47 | _b = p.y ; |
RexRoshan | 0:99fa5a619081 | 48 | } |