ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18jkeo

Dependencies:   mbed

Committer:
josh_ohara
Date:
Mon May 25 15:25:14 2020 +0000
Revision:
38:6f50b548226e
Parent:
31:27c938ec2a11
Child:
40:35f27f0e7833
Safety commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
josh_ohara 16:987f72d9bb8f 1 #include "mbed.h"
josh_ohara 16:987f72d9bb8f 2 #include "N5110.h"
josh_ohara 16:987f72d9bb8f 3 #include "Gamepad.h"
josh_ohara 16:987f72d9bb8f 4
josh_ohara 30:4504b5dd47d1 5 /** Alien Bullet class
josh_ohara 38:6f50b548226e 6 * @brief Creates and controls alien bullet object
josh_ohara 30:4504b5dd47d1 7 * @author Joshua O'hara
josh_ohara 30:4504b5dd47d1 8 * @date May, 2017
josh_ohara 30:4504b5dd47d1 9 */
josh_ohara 38:6f50b548226e 10
josh_ohara 16:987f72d9bb8f 11 class AlienBullet
josh_ohara 16:987f72d9bb8f 12 {
josh_ohara 38:6f50b548226e 13
josh_ohara 16:987f72d9bb8f 14 public:
josh_ohara 38:6f50b548226e 15
josh_ohara 38:6f50b548226e 16 /**Constructor*/
josh_ohara 27:eb755a345b1f 17 AlienBullet();
josh_ohara 38:6f50b548226e 18
josh_ohara 38:6f50b548226e 19 /**Destructor*/
josh_ohara 16:987f72d9bb8f 20 ~AlienBullet();
josh_ohara 38:6f50b548226e 21
josh_ohara 38:6f50b548226e 22 /**Sets private variables to starting values*/
josh_ohara 27:eb755a345b1f 23 void init(int x, int y); //initialises objects and sets private variables
josh_ohara 38:6f50b548226e 24
josh_ohara 38:6f50b548226e 25 /**Draws the bullet if it has not yet been hit*/
josh_ohara 27:eb755a345b1f 26 void render(N5110 &lcd); //draws bullet
josh_ohara 38:6f50b548226e 27
josh_ohara 38:6f50b548226e 28 /**Updates relevant private variables*/
josh_ohara 27:eb755a345b1f 29 void update(); //udpdates private variables
josh_ohara 38:6f50b548226e 30
josh_ohara 27:eb755a345b1f 31 //accessors and mutators
josh_ohara 38:6f50b548226e 32
josh_ohara 38:6f50b548226e 33 /**Returns a 2D vector of the x and y position of the bullet
josh_ohara 38:6f50b548226e 34 *@return bullets position (Vector2D)
josh_ohara 38:6f50b548226e 35 */
josh_ohara 27:eb755a345b1f 36 Vector2D get_position(); //returns the x and y position of the bullet
josh_ohara 38:6f50b548226e 37
josh_ohara 38:6f50b548226e 38 /**Sets the hit value of the bullet, hit = true means bullet has hit something
josh_ohara 38:6f50b548226e 39 *@param _hit (bool)
josh_ohara 38:6f50b548226e 40 */
josh_ohara 27:eb755a345b1f 41 void set_hit(bool x); //sets the hit value of the bullet
josh_ohara 38:6f50b548226e 42
josh_ohara 38:6f50b548226e 43 /**Returns the hit value of the bullet
josh_ohara 38:6f50b548226e 44 *@return _hit (bool)
josh_ohara 38:6f50b548226e 45 */
josh_ohara 27:eb755a345b1f 46 bool get_hit(); //returns the hit value of the bullet
josh_ohara 16:987f72d9bb8f 47
josh_ohara 16:987f72d9bb8f 48 private:
josh_ohara 27:eb755a345b1f 49 int _y; //y position of the bullet
josh_ohara 27:eb755a345b1f 50 int _x; //x position of the bullet
josh_ohara 27:eb755a345b1f 51 int _speed; //speed of the bullet (y direction)
josh_ohara 27:eb755a345b1f 52 bool _hit; //variable to show if bullet has caused a hit, functions the same as the life variable of the ship but logically opposite
josh_ohara 16:987f72d9bb8f 53 };
josh_ohara 16:987f72d9bb8f 54
josh_ohara 16:987f72d9bb8f 55