Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
PlayerShip Class Reference

Represents the player's ship. More...

#include <PlayerShip.h>

Inheritance diagram for PlayerShip:

Public Member Functions

 PlayerShip ()
 Creates a new instance of PlayerShip.
 
virtual ~PlayerShip ()
 
virtual void LoadContent (ResourceManager &resourceManager)
 Loads the content for the player ship.
 
virtual void Update (const GameTime &gameTime)
 Updates the player ship.
 
virtual void Draw (SpriteBatch &spriteBatch)
 Draws the player ship.
 
virtual void HandleInput (const InputState &input)
 Handles input for the player ship.
 
virtual void Initialize (Level *pLevel, Vector2 &startPosition)
 Initializes the player ship.
 
virtual Vector2 GetHalfDimensions () const
 Gets the half dimensions of the player ship.
 
virtual void SetDesiredDirection (const Vector2 direction)
 Sets the desired direction of the player ship, based on input.
 
virtual std::string ToString () const
 Gets the string representation of the player ship.
 
virtual CollisionType GetCollisionType () const
 Gets the collision type of the player ship.
 
virtual void ConfineToScreen (const bool isConfined=true)
 Prevents the player ship from moving off the screen.
 
- Public Member Functions inherited from Ship
 Ship ()
 Creates a new instance of Ship.
 
virtual ~Ship ()
 
virtual void Hit (const float damage)
 Applies damage to the ship.
 
virtual bool IsInvulnurable () const
 To determine if the ship should take damage when hit.
 
virtual void SetInvulnurable (bool isInvulnurable=true)
 Sets the invulnerability of the ship.
 
virtual void AttachItem (IAttachment *item, Vector2 position)
 Attaches a weapon to the ship.
 
virtual float GetSpeed () const
 Gets the speed of the ship.
 
virtual void SetSpeed (const float speed)
 Sets the speed of the ship.
 
virtual void SetMaxHitPoints (const float hitPoints)
 Sets the max hit points of the ship.
 
virtual IAttachmentGetAttachment (const std::string &key)
 
virtual IAttachmentGetAttachment (const int index)
 
- Public Member Functions inherited from GameObject
 GameObject ()
 Instantiate a game object.
 
virtual ~GameObject ()
 
virtual bool IsActive () const
 Flag to determine if the object is active.
 
virtual void Activate ()
 Activate the object.
 
virtual void Deactivate ()
 Deactivate the object.
 
virtual Vector2GetPosition ()
 Get the position of the object.
 
virtual Vector2GetPreviousPosition ()
 Get the position of the object during the previous frame.
 
virtual uint32_t GetIndex () const
 Get the index of the object. Each object is assigned a unique ID when created, starting at 0.
 
virtual float GetCollisionRadius () const
 Get the collision radius of the object.
 
virtual bool HasMask (CollisionType mask) const
 Check if the object has a specific collision bit-mask.
 
virtual bool IsMask (CollisionType mask) const
 
virtual bool IsDrawnByLevel () const
 

Protected Member Functions

virtual void SetResponsiveness (const float responsiveness)
 Sets the responsiveness of the player ship.
 
virtual float GetResponsiveness () const
 Gets the responsiveness of the player ship.
 
virtual Vector2 GetDesiredDirection () const
 Gets the desired direction of the player ship.
 
- Protected Member Functions inherited from Ship
virtual void Initialize ()
 Initializes the ship.
 
virtual void FireWeapons (TriggerType type=TriggerType::All)
 Fires the ship's weapons.
 
virtual WeaponGetWeapon (const std::string &key)
 Gets a weapon from the ship's weapon list.
 
virtual float GetHitPoints () const
 Gets the current hit points of the ship.
 
virtual float GetMaxHitPoints () const
 Gets the max hit points of the ship.
 
- Protected Member Functions inherited from GameObject
virtual void SetCollisionRadius (const int radius)
 
virtual void SetPosition (const float x, const float y)
 
virtual void SetPosition (const Vector2 &position)
 
virtual void TranslatePosition (const float x, const float y)
 
virtual void TranslatePosition (const Vector2 &offset)
 
virtual bool IsOnScreen () const
 

Additional Inherited Members

- Static Public Member Functions inherited from GameObject
static void SetCurrentLevel (Level *pLevel)
 Set the current level.
 
static LevelGetCurrentLevel ()
 Get the current level.
 

Detailed Description

Represents the player's ship.

Definition at line 7 of file PlayerShip.h.

Constructor & Destructor Documentation

◆ PlayerShip()

PlayerShip::PlayerShip ( )
inline

Creates a new instance of PlayerShip.

Definition at line 13 of file PlayerShip.h.

◆ ~PlayerShip()

virtual PlayerShip::~PlayerShip ( )
inlinevirtual

Definition at line 14 of file PlayerShip.h.

Member Function Documentation

◆ ConfineToScreen()

virtual void PlayerShip::ConfineToScreen ( const bool isConfined = true)
inlinevirtual

Prevents the player ship from moving off the screen.

Parameters
isConfinedTrue to confine the player ship to the screen, false otherwise.

Definition at line 56 of file PlayerShip.h.

◆ Draw()

void PlayerShip::Draw ( SpriteBatch & spriteBatch)
virtual

Draws the player ship.

Parameters
spriteBatchA reference to the game's sprite batch, used for rendering.

Implements Ship.

Definition at line 114 of file PlayerShip.cpp.

◆ GetCollisionType()

virtual CollisionType PlayerShip::GetCollisionType ( ) const
inlinevirtual

Gets the collision type of the player ship.

Returns
Returns the collision type of the player ship.

Implements Ship.

Definition at line 52 of file PlayerShip.h.

◆ GetDesiredDirection()

virtual Vector2 PlayerShip::GetDesiredDirection ( ) const
inlineprotectedvirtual

Gets the desired direction of the player ship.

Returns
Returns the desired direction of the player ship.

Definition at line 71 of file PlayerShip.h.

◆ GetHalfDimensions()

Vector2 PlayerShip::GetHalfDimensions ( ) const
virtual

Gets the half dimensions of the player ship.

Returns
Returns the half dimensions of the player ship.

Reimplemented from GameObject.

Definition at line 124 of file PlayerShip.cpp.

◆ GetResponsiveness()

virtual float PlayerShip::GetResponsiveness ( ) const
inlineprotectedvirtual

Gets the responsiveness of the player ship.

Returns
Returns the responsiveness of the player ship.

Definition at line 67 of file PlayerShip.h.

◆ HandleInput()

void PlayerShip::HandleInput ( const InputState & input)
virtual

Handles input for the player ship.

Parameters
inputThe current state of all player input devices.

Definition at line 26 of file PlayerShip.cpp.

◆ Initialize()

void PlayerShip::Initialize ( Level * pLevel,
Vector2 & startPosition )
virtual

Initializes the player ship.

Parameters
pLevelA pointer to the current level.
startPositionThe starting position of the player ship.

Definition at line 21 of file PlayerShip.cpp.

◆ LoadContent()

void PlayerShip::LoadContent ( ResourceManager & resourceManager)
virtual

Loads the content for the player ship.

Parameters
resourceManagerA reference to the game's resource manager, used for loading and managing game assets (resources).

Definition at line 5 of file PlayerShip.cpp.

◆ SetDesiredDirection()

virtual void PlayerShip::SetDesiredDirection ( const Vector2 direction)
inlinevirtual

Sets the desired direction of the player ship, based on input.

Parameters
directionThe desired direction.

Definition at line 44 of file PlayerShip.h.

◆ SetResponsiveness()

void PlayerShip::SetResponsiveness ( const float responsiveness)
protectedvirtual

Sets the responsiveness of the player ship.

Parameters
responsivenessThe responsiveness of the player ship.

Definition at line 129 of file PlayerShip.cpp.

◆ ToString()

virtual std::string PlayerShip::ToString ( ) const
inlinevirtual

Gets the string representation of the player ship.

Returns
Returns the string "Player Ship".

Reimplemented from Ship.

Definition at line 48 of file PlayerShip.h.

◆ Update()

void PlayerShip::Update ( const GameTime & gameTime)
virtual

Updates the player ship.

Parameters
gameTimeA reference to the game time object.

Reimplemented from Ship.

Definition at line 69 of file PlayerShip.cpp.


The documentation for this class was generated from the following files: