Arcade Shooter
Projectile.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 namespace ShooterLibrary
17 {
18 
20  class Projectile : public GameObject
21  {
22 
23  public:
24 
25  Projectile();
26  virtual ~Projectile() { }
27 
30  static void SetTexture(Texture *pTexture) { s_pTexture = pTexture; }
31 
34  virtual void Update(const GameTime *pGameTime);
35 
38  virtual void Draw(SpriteBatch *pSpriteBatch);
39 
43  virtual void Activate(const Vector2 &position, bool wasShotByPlayer = true);
44 
47  virtual float GetDamage() const { return m_damage; }
48 
51  virtual std::string ToString() const;
52 
57  virtual CollisionType GetCollisionType() const;
58 
64  virtual bool IsDrawnByLevel() const { return m_drawnByLevel; }
65 
69  virtual void SetManualDraw(const bool drawManually = true) { m_drawnByLevel = !drawManually; }
70 
71 
72  protected:
73 
76  virtual void SetSpeed(const float speed) { m_speed = speed; }
77 
80  virtual void SetDamage(const float damage) { m_damage = damage; }
81 
84  virtual void SetDirection(const Vector2 direction) { m_direction = direction; }
85 
88  virtual float GetSpeed() const { return m_speed; }
89 
92  virtual Vector2 &GetDirection() { return m_direction; }
93 
96  virtual bool WasShotByPlayer() const { return m_wasShotByPlayer; }
97 
102 
106  virtual std::string GetProjectileTypeString() const { return "Projectile"; }
107 
108 
109  private:
110 
111  static Texture *s_pTexture;
112 
113  float m_speed;
114  float m_damage;
115 
116  Vector2 m_direction;
117 
118  bool m_wasShotByPlayer;
119 
120  bool m_drawnByLevel;
121  };
122 }
virtual void SetSpeed(const float speed)
Sets the speed of the projectile.
Definition: Projectile.h:76
virtual CollisionType GetProjectileType() const
Gets the collision type mask for the projectile.
Definition: Projectile.h:101
virtual std::string ToString() const
Gets a string representation of the projectile.
Definition: Projectile.cpp:66
virtual void SetManualDraw(const bool drawManually=true)
Sets if the level should draw the projectile.
Definition: Projectile.h:69
virtual float GetDamage() const
Gets the damage of the projectile.
Definition: Projectile.h:47
virtual void SetDamage(const float damage)
Sets the amount of damage the projectile inflicts.
Definition: Projectile.h:80
Base class for all objects that will be updated and rendered on a GameplayScreen. ...
Definition: GameObject.h:29
virtual bool WasShotByPlayer() const
Determines if the projectile was shot by a player.
Definition: Projectile.h:96
Shooter Library is a library of classes, interfaces, and value types that provides a foundation for d...
Definition: Background.h:16
virtual void Update(const GameTime *pGameTime)
Called when the game determines it is time to draw a frame.
Definition: Projectile.cpp:30
virtual void SetDirection(const Vector2 direction)
Sets the direction of the projectile.
Definition: Projectile.h:84
virtual std::string GetProjectileTypeString() const
Gets a string representation of the projectile.
Definition: Projectile.h:106
virtual bool IsDrawnByLevel() const
Determines if the level should draw the projectile.
Definition: Projectile.h:64
virtual Vector2 & GetDirection()
Gets the direction of the projectile.
Definition: Projectile.h:92
virtual float GetSpeed() const
Gets the speed of the projectile in pixels per second.
Definition: Projectile.h:88
Base class for all projectile types.
Definition: Projectile.h:20
virtual void Draw(SpriteBatch *pSpriteBatch)
Called when the game determines it is time to draw a frame.
Definition: Projectile.cpp:50
static void SetTexture(Texture *pTexture)
Sets the texture of the player ship.
Definition: Projectile.h:30
static const CollisionType PROJECTILE
Represents a projectile.
Definition: CollisionType.h:34
virtual CollisionType GetCollisionType() const
Gets the collision type mask.
Definition: Projectile.cpp:71
Defines the types of game objects that can collide with each other.
Definition: CollisionType.h:20
virtual void Activate()
Activates the game object.
Definition: GameObject.h:71