Arcade Shooter
PlayerShip.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  class Level;
17 
20  {
21 
22  public:
23 
26  PlayerShip(const uint8_t playerIndex);
27 
28  virtual ~PlayerShip() { }
29 
33  virtual void LoadContent(ResourceManager *pResourceManager);
34 
37  virtual void Update(const GameTime *pGameTime);
38 
41  virtual void Draw(SpriteBatch *pSpriteBatch);
42 
45  virtual void HandleInput(const InputState *pInput);
46 
49  virtual void Hit(const float damage);
50 
53  virtual void Initialize(Level *pLevel);
54 
57  virtual void SetAITarget(Vector2 position)
58  {
59  m_isAIControlled = true;
60  m_targetPosition = position;
61  ConfineToScreen(false);
62  }
63 
66  virtual Vector2 GetHalfDimensions() const;
67 
70  virtual bool IsAIControlled() const { return m_isAIControlled; }
71 
75  virtual void PowerUp()
76  {
77  if (!GetWeapon(1)->IsActive()) GetWeapon(1)->Activate();
78  else
79  {
80  GetWeapon(2)->Activate();
81  ((Launcher *)GetWeapon(1))->ResetCooldown();
82  ((Launcher *)GetWeapon(2))->ResetCooldown();
83  }
84  }
85 
86 
87  private:
88 
89  Animation *m_pAnimation;
90  Animation *m_pColorAnimation;
91 
92  Level *m_pLevel;
93 
94  Color m_color;
95 
96  float m_scale = 1.5f;
97 
98  Animation *m_pThrusterAnimation;
99  Vector2 m_thrusterOffset[2];
100  float m_thrusterScale;
101 
102  Vector2 m_targetPosition;
103 
104  bool m_isAIControlled;
105 
106  };
107 }
Sample is a sample game to use as a template for using Katana Engine and Shooter Library.
Definition: Background.cpp:14
virtual void HandleInput(const InputState *pInput)
Called when the game has determined that player input needs to be processed.
virtual void SetAITarget(Vector2 position)
Sets the target position for the AI to move to.
Definition: PlayerShip.h:57
virtual void Activate()
Activates the weapon.
Definition: Weapon.h:62
virtual bool IsAIControlled() const
Determines if the player ship is currently being controlled by AI.
Definition: PlayerShip.h:70
Base class for shooter levels.
Definition: Level.h:26
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
Class for a missile launcher.
Definition: Launcher.h:19
virtual void ConfineToScreen(const bool isConfined=true)
Confines the player ship to the screen.
Definition: PlayerShip.h:64
Base class for player ships.
Definition: PlayerShip.h:20
virtual void LoadContent(ResourceManager *pResourceManager)
Called when resources need to be loaded.
Definition: PlayerShip.cpp:33
virtual void PowerUp()
Powers up the ship.
Definition: PlayerShip.h:75
virtual void Hit(const float damage)
Hits the ship, dealing damage to it.
Definition: PlayerShip.cpp:163
virtual bool IsActive() const
Determines if the game object is active.
Definition: GameObject.h:68
virtual void Draw(SpriteBatch *pSpriteBatch)
Called when the game determines it is time to draw a frame.
Class for player ships.
Definition: PlayerShip.h:19
virtual void Update(const GameTime *pGameTime)
Called when the game has determined that game logic needs to be processed.
virtual Vector2 GetHalfDimensions() const
Gets the half dimensions of the game object.
Definition: PlayerShip.cpp:175
PlayerShip(const uint8_t playerIndex)
Instantiate a player ship object.
Definition: PlayerShip.cpp:19