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

Represents a ship in the game. More...

#include <Ship.h>

Inheritance diagram for Ship:

Public Member Functions

 Ship ()
 Creates a new instance of Ship.
 
virtual ~Ship ()
 
virtual void Update (const GameTime &gameTime)
 Updates the ship.
 
virtual void Draw (SpriteBatch &spriteBatch)=0
 Draws the 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 std::string ToString () const
 Gets the string representation of the ship.
 
virtual CollisionType GetCollisionType () const =0
 Gets the collision type 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 Vector2 GetHalfDimensions () const
 Get the half dimensions of the object.
 
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 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 a ship in the game.

Definition at line 8 of file Ship.h.

Constructor & Destructor Documentation

◆ Ship()

Ship::Ship ( )

Creates a new instance of Ship.

Definition at line 6 of file Ship.cpp.

◆ ~Ship()

virtual Ship::~Ship ( )
inlinevirtual

Definition at line 15 of file Ship.h.

Member Function Documentation

◆ AttachItem()

void Ship::AttachItem ( IAttachment * item,
Vector2 position )
virtual

Attaches a weapon to the ship.

Parameters
pWeaponA pointer to the weapon to attach.
positionThe position on the ship that the weapon will be attached, offset from the center of the ship.

Definition at line 83 of file Ship.cpp.

◆ Draw()

virtual void Ship::Draw ( SpriteBatch & spriteBatch)
pure virtual

Draws the ship.

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

Implements GameObject.

Implemented in BioEnemyShip, EnemyShip, and PlayerShip.

◆ FireWeapons()

void Ship::FireWeapons ( TriggerType type = TriggerType::All)
protectedvirtual

Fires the ship's weapons.

Parameters
typeThe type of trigger that fired the weapons.

Definition at line 61 of file Ship.cpp.

◆ GetAttachment() [1/2]

IAttachment * Ship::GetAttachment ( const int index)
virtual

Implements KatanaEngine::IAttachable.

Definition at line 44 of file Ship.cpp.

◆ GetAttachment() [2/2]

IAttachment * Ship::GetAttachment ( const std::string & key)
virtual

Implements KatanaEngine::IAttachable.

Definition at line 37 of file Ship.cpp.

◆ GetCollisionType()

virtual CollisionType Ship::GetCollisionType ( ) const
pure virtual

Gets the collision type of the ship.

Returns
Returns the collision type of the ship.

Implements GameObject.

Implemented in EnemyShip, and PlayerShip.

◆ GetHitPoints()

virtual float Ship::GetHitPoints ( ) const
inlineprotectedvirtual

Gets the current hit points of the ship.

Returns
Returns the current hit points of the ship.

Definition at line 91 of file Ship.h.

◆ GetMaxHitPoints()

virtual float Ship::GetMaxHitPoints ( ) const
inlineprotectedvirtual

Gets the max hit points of the ship.

Returns
Returns the max hit points of the ship.

Definition at line 95 of file Ship.h.

◆ GetSpeed()

virtual float Ship::GetSpeed ( ) const
inlinevirtual

Gets the speed of the ship.

Returns
Returns the speed of the ship.

Definition at line 55 of file Ship.h.

◆ GetWeapon()

virtual Weapon * Ship::GetWeapon ( const std::string & key)
inlineprotectedvirtual

Gets a weapon from the ship's weapon list.

Parameters
indexThe index of the weapon to get.
Returns
Returns a pointer to the weapon.

Definition at line 83 of file Ship.h.

◆ Hit()

void Ship::Hit ( const float damage)
virtual

Applies damage to the ship.

Parameters
damageThe amount of damage to apply.

Reimplemented from GameObject.

Reimplemented in EnemyShip.

Definition at line 26 of file Ship.cpp.

◆ Initialize()

void Ship::Initialize ( )
protectedvirtual

Initializes the ship.

Definition at line 56 of file Ship.cpp.

◆ IsInvulnurable()

virtual bool Ship::IsInvulnurable ( ) const
inlinevirtual

To determine if the ship should take damage when hit.

Returns
True if the ship is invulnerable, false otherwise.

Definition at line 31 of file Ship.h.

◆ SetInvulnurable()

virtual void Ship::SetInvulnurable ( bool isInvulnurable = true)
inlinevirtual

Sets the invulnerability of the ship.

Parameters
isInvulnurableTrue to make the ship invulnerable, false otherwise.

Definition at line 35 of file Ship.h.

◆ SetMaxHitPoints()

virtual void Ship::SetMaxHitPoints ( const float hitPoints)
inlinevirtual

Sets the max hit points of the ship.

Parameters
hitPointsThe max hit points of the ship.

Definition at line 63 of file Ship.h.

◆ SetSpeed()

virtual void Ship::SetSpeed ( const float speed)
inlinevirtual

Sets the speed of the ship.

Parameters
speedThe speed of the ship.

Definition at line 59 of file Ship.h.

◆ ToString()

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

Gets the string representation of the ship.

Returns
Returns the string "Ship".

Implements GameObject.

Reimplemented in EnemyShip, and PlayerShip.

Definition at line 39 of file Ship.h.

◆ Update()

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

Updates the ship.

Parameters
pGameTimeA pointer to the game time object.

Reimplemented from GameObject.

Reimplemented in BioEnemyShip, EnemyShip, and PlayerShip.

Definition at line 14 of file Ship.cpp.


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