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
Diff: Weapons/Weapons.h
- Revision:
- 43:500b8cff3715
- Parent:
- 40:90c7a893d513
- Child:
- 44:a6a361bea806
--- a/Weapons/Weapons.h Wed May 08 09:22:16 2019 +0000 +++ b/Weapons/Weapons.h Wed May 08 15:50:40 2019 +0000 @@ -7,41 +7,58 @@ #include "Ship.h" #include "Enemy.h" + +/** Weapon Class +@brief Draws the weapons used by all ships in the game +@author Ozoemena Adrian Ikrnna +@date 8th March 2019 +*/ + class Weapons { public: Weapons(); ~Weapons(); - /* Initialize the class with the ship position */ + + + /** A mutator method that initializes the value of the ship position and ship width + *@param The x position of the ship + *@param The y position of the ship + *@param the width of the ship + */ void init(int ship_xpos, int ship_ypos, int ship_width); - - /* Draw the missle */ - void draw(N5110 &lcd,Gamepad &pad,int shipno,Vector2D closest); - - /* Gets the projectiles position */ - Vector2D get_pos(int shipno); - - /* Moves the projectile across the screen */ + /** Draws the appropriate weapon depending on the ship selected + *@param The N5110 library + *@param The Gamepad library + *@param shipno, a number representing ships 0 for kestrel 1 for imperion and 2 for orion + *@param closest, the position vector of the nearest enemy + */ + void draw(N5110 &lcd,Gamepad &pad,SHIP shipUsed,Vector2D closest); + /** Accessor method that gets the position of the projectile where applicable(depends on ship) + *@param shipno, a number representing ships 0 for kestrel 1 for imperion and 2 for orion + @returns The 2D vector of the projectile fired from ship + */ + Vector2D get_pos(SHIP _shipUsed); + /** Updates the missle position based on the missle velocity + */ void update(); - int ship_xpos; - int ship_ypos; - int _ship_xpos; - int _ship_ypos; - - /** Set Position - * - * This function is used to set the position of the projectile to a specific coordinate on screen. + /** Mutator function used to set the position of the projectile to a specific coordinate on screen. + *used to reset the projectile after a collision with an enemy + *@param xpos, the ships x co-ordinate + *@param ypos, the ships y co-ordinate */ void set_pos(int xpos, int ypos); private: - Enemy _enemy; - int reset; - Vector2D _velocity; - int _size; - int _x; - int _y; + //_______________Private-Variables__________________________________________ + Enemy _enemy; + int _ship_xpos; // ship's x co-ordinate + int _ship_ypos; // ship's y co-ordinate + int reset; // variable to reset the kestrels missle + Vector2D _velocity; // vector to contain the velocity of the kestrels missle + int _x; // missle x co-ordinate + int _y; // missle y co-ordinate }; #endif \ No newline at end of file