Arcade Shooter
Ship.h
1 
2 /* . ,'`. .
3  . .." _.-;' ⁄‚ `. . `
4  _.-"`.##%"_.--" ,' ⁄` `. "#" ___,,od000
5  ,'"-_ _.-.--"\ ,' `-_ '%#%',,/00000000000
6  ,' |_.' )`/- __..--""`-_`-._ J L/00000000000000
7  . + ,' _.-" / / _-"" `-._`-_/___\///0000 000M
8  .'_.-"" ' :_/_.-' _,`-/__V__\0000 00MMM
9  . _-"" . ' _,/000\ | /000 0MMMMM
10 _-" . ' . . ,/ 000\ | /000000000MMMMM
11  ` Shooter Library ' ,/ 000\|/000000000MMMMMM
12 . © 2017 - Shuriken Studios LLC ,/0 00000|0000000000MMMMMM */
13 
14 #pragma once
15 
16 #include "ShooterLibrary.h"
17 
18 namespace ShooterLibrary
19 {
20 
22  class Ship : public GameObject
23  {
24  public:
25 
26  Ship();
27  virtual ~Ship() { }
28 
31  virtual void Update(const GameTime *pGameTime);
32 
35  virtual void Draw(SpriteBatch *pSpriteBatch) = 0;
36 
39  virtual void Hit(const float damage);
40 
44  virtual bool IsInvulnurable() const { return m_isInvulnurable; }
45 
49  virtual void SetInvulnurable(bool isInvulnurable = true) { m_isInvulnurable = isInvulnurable; }
50 
53  virtual std::string ToString() const { return "Ship"; }
54 
59  virtual CollisionType GetCollisionType() const = 0;
60 
64  virtual void AttachWeapon(Weapon *pWeapon, Vector2 position);
65 
66 
67  protected:
68 
70  virtual void Initialize();
71 
73  virtual float GetSpeed() const { return m_speed; }
74 
77  virtual void SetSpeed(const float speed) { m_speed = speed; }
78 
81  virtual void SetMaxHitPoints(const float hitPoints) { m_maxHitPoints = hitPoints; }
82 
85  virtual void FireWeapons(TriggerType type = TriggerType::ALL);
86 
90  virtual Weapon *GetWeapon(const int index) { return m_weapons[index]; }
91 
92 
93  private:
94 
95  float m_speed;
96 
97  float m_hitPoints;
98  float m_maxHitPoints;
99 
100  bool m_isInvulnurable;
101 
102  std::vector<Weapon *> m_weapons;
103  std::vector<Weapon *>::iterator m_weaponIt;
104  };
105 }
Defines how different types of weapons should be triggered.
Definition: TriggerType.h:20
virtual void AttachWeapon(Weapon *pWeapon, Vector2 position)
Attaches a weapon to the ship.
Definition: Ship.cpp:68
virtual CollisionType GetCollisionType() const =0
Gets the collision type mask.
virtual void SetInvulnurable(bool isInvulnurable=true)
Sets whether or not the ship takes damage.
Definition: Ship.h:49
virtual void Draw(SpriteBatch *pSpriteBatch)=0
Called when the game determines it is time to draw a frame.
virtual void Hit(const float damage)
Hits the ship, dealing damage to it.
Definition: Ship.cpp:41
virtual void Update(const GameTime *pGameTime)
Updates the game object.
Definition: Ship.cpp:30
Base class for all objects that will be updated and rendered on a GameplayScreen. ...
Definition: GameObject.h:29
Shooter Library is a library of classes, interfaces, and value types that provides a foundation for d...
Definition: Background.h:16
virtual bool IsInvulnurable() const
Determines if the ship takes damage.
Definition: Ship.h:44
virtual void SetMaxHitPoints(const float hitPoints)
Sets the maximum hit points of the ship.
Definition: Ship.h:81
virtual std::string ToString() const
Gets a string representation of the ship.
Definition: Ship.h:53
virtual float GetSpeed() const
Gets the speed of the projectile in pixels per second.
Definition: Ship.h:73
virtual Weapon * GetWeapon(const int index)
Gets the weapon at the specified index.
Definition: Ship.h:90
virtual void Initialize()
Initializes the ship.
Definition: Ship.cpp:54
static const TriggerType ALL
Represents a combination of all weapon triggers.
Definition: TriggerType.h:34
Base class for all Weapons.
Definition: Weapon.h:19
virtual void SetSpeed(const float speed)
Sets the speed of the ship.
Definition: Ship.h:77
virtual void FireWeapons(TriggerType type=TriggerType::ALL)
Fires the ship&#39;s weapons.
Definition: Ship.cpp:59
Base class for all ships.
Definition: Ship.h:22
Defines the types of game objects that can collide with each other.
Definition: CollisionType.h:20