Ikenna Adrian Ozoemena 201157039
Dependencies: mbed
Enemy/Enemy.h@45:fe5fc85a5c73, 2019-05-09 (annotated)
- Committer:
- ikenna1
- Date:
- Thu May 09 03:56:41 2019 +0000
- Revision:
- 45:fe5fc85a5c73
- Parent:
- 41:e1fa36c0492e
- Child:
- 46:b23c1b16ac08
Documentation Test 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ikenna1 | 15:009ccc07bb57 | 1 | #ifndef ENEMY_H |
ikenna1 | 15:009ccc07bb57 | 2 | #define ENEMY_H |
ikenna1 | 15:009ccc07bb57 | 3 | |
ikenna1 | 15:009ccc07bb57 | 4 | #include "mbed.h" |
ikenna1 | 15:009ccc07bb57 | 5 | #include "N5110.h" |
ikenna1 | 15:009ccc07bb57 | 6 | #include "Gamepad.h" |
ikenna1 | 37:8d8c8cce0bc7 | 7 | #include <ctime> |
ikenna1 | 40:90c7a893d513 | 8 | #include <cmath> |
ikenna1 | 15:009ccc07bb57 | 9 | |
ikenna1 | 45:fe5fc85a5c73 | 10 | /** Enemy Class |
ikenna1 | 45:fe5fc85a5c73 | 11 | @brief Library that updates the position of all enemies and enemy weapons for rosen game |
ikenna1 | 45:fe5fc85a5c73 | 12 | @author Ozoemena Adrian Ikrnna |
ikenna1 | 45:fe5fc85a5c73 | 13 | @date 8th May 2019 |
ikenna1 | 45:fe5fc85a5c73 | 14 | */ |
ikenna1 | 15:009ccc07bb57 | 15 | class Enemy |
ikenna1 | 15:009ccc07bb57 | 16 | { |
ikenna1 | 15:009ccc07bb57 | 17 | public: |
ikenna1 | 45:fe5fc85a5c73 | 18 | /** constructor */ |
ikenna1 | 15:009ccc07bb57 | 19 | Enemy(); |
ikenna1 | 45:fe5fc85a5c73 | 20 | /** destructor */ |
ikenna1 | 15:009ccc07bb57 | 21 | ~Enemy(); |
ikenna1 | 15:009ccc07bb57 | 22 | |
ikenna1 | 45:fe5fc85a5c73 | 23 | /** A mutator method that initializes the number of enemies |
ikenna1 | 45:fe5fc85a5c73 | 24 | *@param noShooters: the number of enemy shooters on screen |
ikenna1 | 45:fe5fc85a5c73 | 25 | *@param noSeekers: the number of enemy seekers on screen |
ikenna1 | 45:fe5fc85a5c73 | 26 | *<note that these should not be confused with seno and shno which are used to |
ikenna1 | 45:fe5fc85a5c73 | 27 | *<reference particular enemies i.e shooter1 and shooter2 |
ikenna1 | 45:fe5fc85a5c73 | 28 | */ |
ikenna1 | 45:fe5fc85a5c73 | 29 | void init(int noShooters, int noSeekers); |
ikenna1 | 45:fe5fc85a5c73 | 30 | /** A mutator method that sets the number of shooters, used for increasing game difficulty |
ikenna1 | 45:fe5fc85a5c73 | 31 | *@param noShooters: the number of enemy shooters on screen |
ikenna1 | 45:fe5fc85a5c73 | 32 | */ |
ikenna1 | 45:fe5fc85a5c73 | 33 | void set_noshooters(int noShooters); |
ikenna1 | 45:fe5fc85a5c73 | 34 | /** A mutator method that sets the number of seekers, used for increasing game difficulty |
ikenna1 | 45:fe5fc85a5c73 | 35 | *@param noSeekers: the number of enemy seekers on screen |
ikenna1 | 45:fe5fc85a5c73 | 36 | */ |
ikenna1 | 45:fe5fc85a5c73 | 37 | void set_noseekers(int noSeekers); |
ikenna1 | 45:fe5fc85a5c73 | 38 | /** Draws the shooter on screen |
ikenna1 | 45:fe5fc85a5c73 | 39 | *@param &lcd: pointer to the N5110 library used for the lcd display |
ikenna1 | 45:fe5fc85a5c73 | 40 | */ |
ikenna1 | 45:fe5fc85a5c73 | 41 | void draw_shooter(N5110 &lcd); |
ikenna1 | 45:fe5fc85a5c73 | 42 | /** Draws the seeker on screen |
ikenna1 | 45:fe5fc85a5c73 | 43 | *@param &lcd: pointer to the N5110 library used for the lcd display |
ikenna1 | 45:fe5fc85a5c73 | 44 | */ |
ikenna1 | 15:009ccc07bb57 | 45 | void draw_seeker(N5110 &lcd); |
ikenna1 | 45:fe5fc85a5c73 | 46 | /** A mutator method that updates the shooter position according to the player ships position |
ikenna1 | 45:fe5fc85a5c73 | 47 | *@param ship_xpos: the ships x co-ordinate |
ikenna1 | 45:fe5fc85a5c73 | 48 | *@param ship_ypos: the ships y co-ordinate |
ikenna1 | 45:fe5fc85a5c73 | 49 | */ |
ikenna1 | 45:fe5fc85a5c73 | 50 | void update_shooter(int ship_xpos, int ship_ypos); |
ikenna1 | 45:fe5fc85a5c73 | 51 | /** A mutator method that updates the seekers position according to the player ships position |
ikenna1 | 45:fe5fc85a5c73 | 52 | *@param ship_xpos: the ships x co-ordinate |
ikenna1 | 45:fe5fc85a5c73 | 53 | *@param ship_ypos: the ships y co-ordinate |
ikenna1 | 45:fe5fc85a5c73 | 54 | */ |
ikenna1 | 15:009ccc07bb57 | 55 | void update_seeker(int ship_xpos, int ship_ypos); |
ikenna1 | 45:fe5fc85a5c73 | 56 | /** resets the shooter to the top of screen |
ikenna1 | 45:fe5fc85a5c73 | 57 | *@param shno: the shooter number used to reference the shooter of interest |
ikenna1 | 45:fe5fc85a5c73 | 58 | *Ranges from 0-3 as there can be a maximum of three shooters |
ikenna1 | 45:fe5fc85a5c73 | 59 | */ |
ikenna1 | 41:e1fa36c0492e | 60 | void reset_shooter(int shno); |
ikenna1 | 45:fe5fc85a5c73 | 61 | /** resets the seeker to the top of screen |
ikenna1 | 45:fe5fc85a5c73 | 62 | *@param seno: the seeker number used to reference the seekerr of interest |
ikenna1 | 45:fe5fc85a5c73 | 63 | *Ranges from 0-3 as there can be a maximum of three seekers |
ikenna1 | 45:fe5fc85a5c73 | 64 | */ |
ikenna1 | 45:fe5fc85a5c73 | 65 | void reset_seeker(int seno); |
ikenna1 | 45:fe5fc85a5c73 | 66 | /** draws the projectile fired from the shooter |
ikenna1 | 45:fe5fc85a5c73 | 67 | *@param &lcd: pointer to the N5110 library used for the lcd display |
ikenna1 | 45:fe5fc85a5c73 | 68 | *@param &pad: pointer to the gamepad library used to read inputs and send outputs to the gamepad |
ikenna1 | 45:fe5fc85a5c73 | 69 | */ |
ikenna1 | 34:6d0786582d81 | 70 | void draw_shw(N5110 &lcd,Gamepad &pad); |
ikenna1 | 45:fe5fc85a5c73 | 71 | /** A mutator method that updates the position of the projectile fired from the shooter |
ikenna1 | 45:fe5fc85a5c73 | 72 | */ |
ikenna1 | 32:098fbc1222cd | 73 | void update_shw(); |
ikenna1 | 45:fe5fc85a5c73 | 74 | /** An accessor method that gets the position of the projectile fired by the shooter |
ikenna1 | 45:fe5fc85a5c73 | 75 | *@param shno: the shooter number used to reference the shooter of interest |
ikenna1 | 45:fe5fc85a5c73 | 76 | *Ranges from 0-3 as there can be a maximum of three shooters |
ikenna1 | 45:fe5fc85a5c73 | 77 | */ |
ikenna1 | 37:8d8c8cce0bc7 | 78 | Vector2D get_shwpos(int shno); |
ikenna1 | 45:fe5fc85a5c73 | 79 | /** An accessor method that gets the position of any shooter on screen |
ikenna1 | 45:fe5fc85a5c73 | 80 | *@param shno: the shooter number used to reference the shooter of interest |
ikenna1 | 45:fe5fc85a5c73 | 81 | *Ranges from 0-3 as there can be a maximum of three shooters |
ikenna1 | 45:fe5fc85a5c73 | 82 | */ |
ikenna1 | 37:8d8c8cce0bc7 | 83 | Vector2D get_shooterpos(int shno); |
ikenna1 | 45:fe5fc85a5c73 | 84 | /** An accessor method that gets the position of any seeker on screen |
ikenna1 | 45:fe5fc85a5c73 | 85 | *@param seno: the seeker number used to reference the seekerr of interest |
ikenna1 | 45:fe5fc85a5c73 | 86 | *Ranges from 0-3 as there can be a maximum of three seekers |
ikenna1 | 45:fe5fc85a5c73 | 87 | */ |
ikenna1 | 45:fe5fc85a5c73 | 88 | Vector2D get_seekerpos(int seno); |
ikenna1 | 45:fe5fc85a5c73 | 89 | /** A random number generator that creates a random number that can be scaled |
ikenna1 | 45:fe5fc85a5c73 | 90 | *appropriately using the <ctime> library |
ikenna1 | 45:fe5fc85a5c73 | 91 | *@param scale: this will determine the maximum output of the function |
ikenna1 | 45:fe5fc85a5c73 | 92 | *@returns a random number between 0 and scale |
ikenna1 | 45:fe5fc85a5c73 | 93 | */ |
ikenna1 | 37:8d8c8cce0bc7 | 94 | int rand_no(int scale); |
ikenna1 | 45:fe5fc85a5c73 | 95 | /** A mutator function which changes enemy speed and number as time goes on |
ikenna1 | 45:fe5fc85a5c73 | 96 | *@param time_elapsed: the amount of time that has passed since a player pressed play in seconds |
ikenna1 | 45:fe5fc85a5c73 | 97 | */ |
ikenna1 | 39:7824f9080f59 | 98 | void sh_scaling(float time_elapsed); |
ikenna1 | 45:fe5fc85a5c73 | 99 | /** Finds the average distance between two points on the 2D screen |
ikenna1 | 45:fe5fc85a5c73 | 100 | *@param x1: the x co-ordinate of the first point |
ikenna1 | 45:fe5fc85a5c73 | 101 | *@param y1: the y co-ordinate of the first point |
ikenna1 | 45:fe5fc85a5c73 | 102 | *@param x2: the x co-ordinate of the second point |
ikenna1 | 45:fe5fc85a5c73 | 103 | *@param y2: the y co-ordinate of the second point |
ikenna1 | 45:fe5fc85a5c73 | 104 | *@returns the distance between the two points |
ikenna1 | 45:fe5fc85a5c73 | 105 | */ |
ikenna1 | 45:fe5fc85a5c73 | 106 | int distance(int x1, int y1, int x2, int y2); |
ikenna1 | 45:fe5fc85a5c73 | 107 | /** Finds the closest enemy ship on screen |
ikenna1 | 45:fe5fc85a5c73 | 108 | *< used for the orions weapon tracking |
ikenna1 | 45:fe5fc85a5c73 | 109 | *@param ship_xpos: the ships x co-ordinate |
ikenna1 | 45:fe5fc85a5c73 | 110 | *@param ship_ypos: the ships y co-ordinate |
ikenna1 | 45:fe5fc85a5c73 | 111 | *@param noShooters: the number of enemy shooters on screen |
ikenna1 | 45:fe5fc85a5c73 | 112 | *@param noSeekers: the number of enemy seekers on screen |
ikenna1 | 45:fe5fc85a5c73 | 113 | */ |
ikenna1 | 45:fe5fc85a5c73 | 114 | Vector2D find_closest(int ship_xpos,int ship_ypos,int noSeekers, int noShooters); |
ikenna1 | 37:8d8c8cce0bc7 | 115 | |
ikenna1 | 15:009ccc07bb57 | 116 | |
ikenna1 | 15:009ccc07bb57 | 117 | private: |
ikenna1 | 45:fe5fc85a5c73 | 118 | //_______________Private-Methods__________________________________________ |
ikenna1 | 32:098fbc1222cd | 119 | void draw_shw1(N5110 &lcd,Gamepad &pad); |
ikenna1 | 32:098fbc1222cd | 120 | void draw_shw2(N5110 &lcd,Gamepad &pad); |
ikenna1 | 32:098fbc1222cd | 121 | void draw_shw3(N5110 &lcd,Gamepad &pad); |
ikenna1 | 39:7824f9080f59 | 122 | void update_seeker1(int ship_xpos, int ship_ypos); |
ikenna1 | 39:7824f9080f59 | 123 | void update_seeker2(int ship_xpos, int ship_ypos); |
ikenna1 | 39:7824f9080f59 | 124 | void update_seeker3(int ship_xpos, int ship_ypos); |
ikenna1 | 39:7824f9080f59 | 125 | Vector2D shooter_motion(int shooter_xpos,int shooter_ypos,int ship_xpos, int ship_ypos, int projx, int projy,int vx, int vy); |
ikenna1 | 45:fe5fc85a5c73 | 126 | |
ikenna1 | 45:fe5fc85a5c73 | 127 | //_______________Private-Variables__________________________________________ |
ikenna1 | 45:fe5fc85a5c73 | 128 | Vector2D _seekerPos[3]; //a 2D array of all the seekers position values |
ikenna1 | 45:fe5fc85a5c73 | 129 | Vector2D _shooterPos[3]; //a 2D array of all the shooters position values |
ikenna1 | 45:fe5fc85a5c73 | 130 | Vector2D _shooterSpeed[3]; //a 2D array of all the shooters speed values |
ikenna1 | 45:fe5fc85a5c73 | 131 | Vector2D _shooterWPos[3]; //a 2D array of all the shooters-projectile position position values |
ikenna1 | 45:fe5fc85a5c73 | 132 | Vector2D _shooterWSpeed[3]; //a 2D array of all the shooters-projectile speed position values |
ikenna1 | 45:fe5fc85a5c73 | 133 | int _reset[3]; //an array or reset values used to reset projectiles from the shooter weapon |
ikenna1 | 45:fe5fc85a5c73 | 134 | int _noShooters; //the number of shooters on the screen |
ikenna1 | 45:fe5fc85a5c73 | 135 | int _noSeekers; //the number of seekers on the screen |
ikenna1 | 15:009ccc07bb57 | 136 | |
ikenna1 | 15:009ccc07bb57 | 137 | }; |
ikenna1 | 15:009ccc07bb57 | 138 | #endif |