Nemesis game, fifth enemy
Revision 4:4932cfd474c9, committed 2017-05-03
- Comitter:
- musallambseiso
- Date:
- Wed May 03 20:04:23 2017 +0000
- Parent:
- 3:6b0386fe794c
- Commit message:
- Removed redundant code, perfected Doxygen, added inline comments.
Changed in this revision
Enemy5.cpp | Show annotated file Show diff for this revision Revisions of this file |
Enemy5.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6b0386fe794c -r 4932cfd474c9 Enemy5.cpp --- a/Enemy5.cpp Tue May 02 22:14:38 2017 +0000 +++ b/Enemy5.cpp Wed May 03 20:04:23 2017 +0000 @@ -2,24 +2,27 @@ Enemy5::Enemy5() { - } Enemy5::~Enemy5() { +} -} + +// Initializion method: void Enemy5::init(int speed) { - int x = rand() % 63 + 84; - _x = x; - _y = 27; + _x = rand() % 63 + 84; // Starting x position is randomized off screen. Creates a random ship generation. + _y = 27; // Starting y position (fixed, fifth lane) - _velocity.x = -speed; + _velocity.x = -speed; // Velocity is based on the speed, which is input when method is used. _velocity.y = 0; } + +// Draws fifth enemy ship onto LCD: + void Enemy5::draw(N5110 &lcd) { lcd.drawLine(_x,_y,_x,_y+5,1); @@ -29,12 +32,19 @@ lcd.drawLine(_x-4,_y+2,_x-4,_y+3,1); } + +// Updates fifth enemy ship's position: + void Enemy5::update() { + // X and y positions depend on velocity: _x += _velocity.x; _y += _velocity.y; } + +// Obtains fifth enemy ship's current position: + Vector2D Enemy5::get_pos() { Vector2D p = {_x,_y};
diff -r 6b0386fe794c -r 4932cfd474c9 Enemy5.h --- a/Enemy5.h Tue May 02 22:14:38 2017 +0000 +++ b/Enemy5.h Wed May 03 20:04:23 2017 +0000 @@ -6,6 +6,17 @@ #include "Gamepad.h" #include "Friendly.h" +/** Enemy5 Class +@brief Used for generating the fifth enemy ship in the Nemesis game. Includes drawing and updating functions. +@brief Incorporates N5110.h file by Craig A. Evans. + +@brief Revision 1.0 + +@author Musallam M. M. Bseiso +@date 3rd May 2017 +*/ + + class Enemy5 { @@ -31,6 +42,8 @@ /** Draw Enemy5 * * Draws the fifth enemy ship onto the LCD, in accordance with the parameters initialized in the "init" method. + * @param N5110 - nokia LCD library + * @param lcd - pointer to nokia LCD library */ void draw(N5110 &lcd);