ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18jkeo

Dependencies:   mbed

Committer:
josh_ohara
Date:
Tue May 19 16:24:39 2020 +0000
Revision:
36:78efa0e7bd31
Parent:
35:517b56b010df
Child:
37:90a0671d2ba7
Finishing touches to sounds and ship and alien render functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
josh_ohara 8:86cb9a9f8a73 1 #ifndef SHIP_H
josh_ohara 8:86cb9a9f8a73 2 #define SHIP_H
josh_ohara 2:c2316b659b97 3
josh_ohara 3:8a140aa1ddcd 4 #include "mbed.h"
josh_ohara 3:8a140aa1ddcd 5 #include "N5110.h"
josh_ohara 3:8a140aa1ddcd 6 #include "Gamepad.h"
josh_ohara 21:970807533b10 7 #include "BulletS.h"
josh_ohara 2:c2316b659b97 8
josh_ohara 25:823b1a997a0c 9 /** Ship Class
josh_ohara 25:823b1a997a0c 10 @author Joshua Ohara, el18jkeo, 201291390
josh_ohara 25:823b1a997a0c 11 @brief Controls the ship
josh_ohara 25:823b1a997a0c 12 @date May 2020
josh_ohara 25:823b1a997a0c 13 */
josh_ohara 25:823b1a997a0c 14
josh_ohara 2:c2316b659b97 15 class Ship
josh_ohara 2:c2316b659b97 16 {
josh_ohara 2:c2316b659b97 17
josh_ohara 2:c2316b659b97 18 public:
josh_ohara 8:86cb9a9f8a73 19 Ship();
josh_ohara 8:86cb9a9f8a73 20 ~Ship();
josh_ohara 27:eb755a345b1f 21 void init(int height, int width); //initialises ship object, sets private variables
josh_ohara 27:eb755a345b1f 22 void render(N5110 &lcd); //draws ship if alive
josh_ohara 35:517b56b010df 23 void update(Direction d, float mag, Gamepad &pad, N5110 &lcd, int counter, int powerup); //updates the position and shooting of the ship
josh_ohara 27:eb755a345b1f 24 //accessors and mutators
josh_ohara 27:eb755a345b1f 25 void set_life(bool life); //sets the life of the ship
josh_ohara 27:eb755a345b1f 26 bool get_life(); //returns the life of the ship
josh_ohara 27:eb755a345b1f 27 void set_bullet_hit(int i, bool hit); //sets the life of a given ship bullet (hit if a collsion occurs)
josh_ohara 27:eb755a345b1f 28 Vector2D get_position(); //returns the position of the ship for collision check
josh_ohara 27:eb755a345b1f 29 vector<ShipBullet> get_bullet_vector(); //returns the ship bullet vector for collsion check
josh_ohara 2:c2316b659b97 30
josh_ohara 2:c2316b659b97 31 private:
josh_ohara 27:eb755a345b1f 32 int _height; //height of the ship main rectangle
josh_ohara 27:eb755a345b1f 33 int _width; //width of the ship main rectangle
josh_ohara 27:eb755a345b1f 34 int _x; //x posittion of ship
josh_ohara 27:eb755a345b1f 35 int _y; //y position of the ship
josh_ohara 36:78efa0e7bd31 36 int _speed;
josh_ohara 36:78efa0e7bd31 37 int _powerup; //speed of the ship in x direction
josh_ohara 27:eb755a345b1f 38 bool _life; //whether the ship is alive or not
josh_ohara 27:eb755a345b1f 39 BulletS _ship_bullet_vector; //object to create ship bullet vector
josh_ohara 2:c2316b659b97 40 };
josh_ohara 8:86cb9a9f8a73 41
josh_ohara 8:86cb9a9f8a73 42 #endif