Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
PlayerShip.h
Go to the documentation of this file.
1
2#pragma once
3
4#include "Ship.h"
5
7class PlayerShip : public Ship
8{
9
10public:
11
14 virtual ~PlayerShip() { }
15
19 virtual void LoadContent(ResourceManager& resourceManager);
20
23 virtual void Update(const GameTime& gameTime);
24
27 virtual void Draw(SpriteBatch& spriteBatch);
28
31 virtual void HandleInput(const InputState& input);
32
36 virtual void Initialize(Level* pLevel, Vector2& startPosition);
37
40 virtual Vector2 GetHalfDimensions() const;
41
44 virtual void SetDesiredDirection(const Vector2 direction) { m_desiredDirection.Set(direction); }
45
48 virtual std::string ToString() const { return "Player Ship"; }
49
53
56 virtual void ConfineToScreen(const bool isConfined = true) { m_isConfinedToScreen = isConfined; }
57
58
59protected:
60
63 virtual void SetResponsiveness(const float responsiveness);
64
67 virtual float GetResponsiveness() const { return m_responsiveness; }
68
71 virtual Vector2 GetDesiredDirection() const { return m_desiredDirection; }
72
73
74private:
75
76 Vector2 m_desiredDirection;
77 Vector2 m_velocity;
78
79 float m_responsiveness = 0;
80
81 bool m_isConfinedToScreen = false;
82
83 Texture* m_pTexture = nullptr;
84
85};
Represents a type of collision.
static const CollisionType Ship
static const CollisionType Player
Contains timing values for game updates and rendering.
Definition GameTime.h:21
Handles the state of multiple player input devices.
Definition InputState.h:22
Loads and manages the lifespan of objects from external files.
Enables a group of sprites to be drawn using the same settings.
Definition SpriteBatch.h:48
Represents a 2D grid of texels.
Definition Texture.h:21
Defines a vector with 2 components (x and y).
Definition Vector2.h:21
void Set(const float x, const float y)
Sets the components of the vector.
Definition Vector2.h:49
Represents a level in the game.
Definition Level.h:15
Represents the player's ship.
Definition PlayerShip.h:8
virtual void ConfineToScreen(const bool isConfined=true)
Prevents the player ship from moving off the screen.
Definition PlayerShip.h:56
virtual void HandleInput(const InputState &input)
Handles input for the player ship.
virtual void SetResponsiveness(const float responsiveness)
Sets the responsiveness of the player ship.
virtual CollisionType GetCollisionType() const
Gets the collision type of the player ship.
Definition PlayerShip.h:52
PlayerShip()
Creates a new instance of PlayerShip.
Definition PlayerShip.h:13
virtual Vector2 GetHalfDimensions() const
Gets the half dimensions of the player ship.
virtual ~PlayerShip()
Definition PlayerShip.h:14
virtual std::string ToString() const
Gets the string representation of the player ship.
Definition PlayerShip.h:48
virtual float GetResponsiveness() const
Gets the responsiveness of the player ship.
Definition PlayerShip.h:67
virtual void LoadContent(ResourceManager &resourceManager)
Loads the content for the player ship.
Definition PlayerShip.cpp:5
virtual void Draw(SpriteBatch &spriteBatch)
Draws the player ship.
virtual Vector2 GetDesiredDirection() const
Gets the desired direction of the player ship.
Definition PlayerShip.h:71
virtual void SetDesiredDirection(const Vector2 direction)
Sets the desired direction of the player ship, based on input.
Definition PlayerShip.h:44
virtual void Update(const GameTime &gameTime)
Updates the player ship.
Represents a ship in the game.
Definition Ship.h:9
virtual void Initialize()
Initializes the ship.
Definition Ship.cpp:56