Arcade Shooter
Missile.h
1 
2 /* .oooooo..o .o. ooo ooooo ooooooooo. ooooo oooooooooooo
3  d8P' `Y8 .888. `88. .888' `888 `Y88. `888' `888' `8
4  Y88bo. .8"888. 888b d'888 888 .d88' 888 888
5  `"Y8888o. .8' `888. 8 Y88. .P 888 888ooo88P' 888 888oooo8
6  `"Y88b .88ooo8888. 8 `888' 888 888 888 888 "
7  oo .d8P .8' `888. 8 Y 888 888 888 o 888 o
8  8""88888P' o88o o8888o o8o o888o o888o o888ooooood8 o888ooooood8
9 
10  Sample © 2017 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace Sample
15 {
16 
19  {
20 
21  public:
22 
23  Missile();
24  virtual ~Missile() { }
25 
28  virtual void SetAnimation(Animation *pAnimation) { m_pAnimation = pAnimation; }
29 
32  virtual void Update(const GameTime *pGameTime);
33 
36  virtual void Draw(SpriteBatch *pSpriteBatch);
37 
41  virtual void Activate(const Vector2 &position, bool wasShotByPlayer = true);
42 
45  virtual void SetEmitter(Emitter *pEmitter) { m_pEmitter = pEmitter; }
46 
49  virtual std::string ToString() const { return "Missile"; }
50 
51 
52  protected:
53 
56  void SetTurnSpeed(const float turnSpeed) { m_turnSpeed = Math::Abs(turnSpeed); }
57 
60  void SetRange(const float range) { m_range = range; }
61 
64  void SetAngle(const float angle) { m_angle = angle; }
65 
68  void SetTarget(GameObject *pTarget = nullptr) { m_pTarget = pTarget; }
69 
71  void ResetTargetingDelay() { m_targetingDelayFrames = Math::GetRandomInt(8, 9); }
72 
75  GameObject *GetTarget() const { return m_pTarget; }
76 
77 
78  private:
79 
80  Animation *m_pAnimation;
81 
82  int m_targetingDelayFrames;
83 
84  Vector2 m_targetingOffset;
85 
86  float m_angle;
87  float m_range;
88  float m_turnSpeed;
89 
90  GameObject *m_pTarget;
91 
92  Emitter *m_pEmitter;
93 
94  };
95 }
virtual std::string ToString() const
Gets a string representation of the missile.
Definition: Missile.h:49
Sample is a sample game to use as a template for using Katana Engine and Shooter Library.
Definition: Background.cpp:14
virtual void Draw(SpriteBatch *pSpriteBatch)
Called when the game determines it is time to draw a frame.
Definition: Missile.cpp:78
virtual void SetAnimation(Animation *pAnimation)
Sets the animation for the missile.
Definition: Missile.h:28
virtual void SetEmitter(Emitter *pEmitter)
Sets the particle emitter for particle trail.
Definition: Missile.h:45
virtual void Update(const GameTime *pGameTime)
Called when the game determines it is time to draw a frame.
Definition: Missile.cpp:27
void SetAngle(const float angle)
Sets the current angle of the missile.
Definition: Missile.h:64
Class for missiles.
Definition: Missile.h:18
void SetTurnSpeed(const float turnSpeed)
Sets the turn speed of the missile.
Definition: Missile.h:56
Base class for all projectile types.
Definition: Projectile.h:20
void SetRange(const float range)
Sets the target range of the missile.
Definition: Missile.h:60
GameObject * GetTarget() const
Gets the missile's target object.
Definition: Missile.h:75
void ResetTargetingDelay()
Resets the timer for when the missile should reaquire a target.
Definition: Missile.h:71
void SetTarget(GameObject *pTarget=nullptr)
Sets the missile's target.
Definition: Missile.h:68
virtual void Activate()
Activates the game object.
Definition: GameObject.h:71