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

Represents a projectile that can be fired by a weapon. More...

#include <Projectile.h>

Inheritance diagram for Projectile:

Public Member Functions

 Projectile ()
 Instantiate a projectile object.
 
virtual ~Projectile ()
 
virtual void Update (const GameTime &gameTime)
 Update the projectile.
 
virtual void Draw (SpriteBatch &spriteBatch)
 Render the projectile.
 
virtual void Activate (const Vector2 &position, bool wasShotByPlayer=true)
 Activate the projectile.
 
virtual float GetDamage () const
 Get the amount of damage the projectile will deal.
 
virtual std::string ToString () const
 Get the string representation of the projectile.
 
virtual CollisionType GetCollisionType () const
 Get the type of collision the projectile will have.
 
- 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 void Hit (const float damage)
 Hits the object with a specified amount of damage.
 
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
 

Static Public Member Functions

static void SetTexture (Texture *pTexture)
 Set the texture that will be used to render the projectile.
 
- Static Public Member Functions inherited from GameObject
static void SetCurrentLevel (Level *pLevel)
 Set the current level.
 
static LevelGetCurrentLevel ()
 Get the current level.
 

Protected Member Functions

virtual void SetSpeed (const float speed)
 Set the speed of the projectile.
 
virtual void SetDamage (const float damage)
 Set the amount of damage the projectile will deal.
 
virtual void SetDirection (const Vector2 direction)
 Set the direction of the projectile.
 
virtual float GetSpeed () const
 Get the speed of the projectile.
 
virtual Vector2GetDirection ()
 Get the direction of the projectile.
 
virtual bool WasShotByPlayer () const
 Determine if the projectile was fired by the player.
 
virtual CollisionType GetProjectileType () const
 Get the collision type of the projectile.
 
- 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
 

Detailed Description

Represents a projectile that can be fired by a weapon.

Definition at line 8 of file Projectile.h.

Constructor & Destructor Documentation

◆ Projectile()

Projectile::Projectile ( )

Instantiate a projectile object.

Definition at line 7 of file Projectile.cpp.

◆ ~Projectile()

virtual Projectile::~Projectile ( )
inlinevirtual

Definition at line 15 of file Projectile.h.

Member Function Documentation

◆ Activate()

void Projectile::Activate ( const Vector2 & position,
bool wasShotByPlayer = true )
virtual

Activate the projectile.

Parameters
positionThe position to activate the projectile at.
wasShotByPlayerA flag to determine if the projectile was fired by the player.

Definition at line 42 of file Projectile.cpp.

◆ Draw()

void Projectile::Draw ( SpriteBatch & spriteBatch)
virtual

Render the projectile.

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

Implements GameObject.

Definition at line 33 of file Projectile.cpp.

◆ GetCollisionType()

CollisionType Projectile::GetCollisionType ( ) const
virtual

Get the type of collision the projectile will have.

Returns
The type of collision the projectile will have.

Implements GameObject.

Definition at line 55 of file Projectile.cpp.

◆ GetDamage()

virtual float Projectile::GetDamage ( ) const
inlinevirtual

Get the amount of damage the projectile will deal.

Returns
The amount of damage the projectile will deal.

Definition at line 36 of file Projectile.h.

◆ GetDirection()

virtual Vector2 & Projectile::GetDirection ( )
inlineprotectedvirtual

Get the direction of the projectile.

Returns
The direction of the projectile.

Definition at line 67 of file Projectile.h.

◆ GetProjectileType()

virtual CollisionType Projectile::GetProjectileType ( ) const
inlineprotectedvirtual

Get the collision type of the projectile.

Returns
The collision type of the projectile.

Definition at line 75 of file Projectile.h.

◆ GetSpeed()

virtual float Projectile::GetSpeed ( ) const
inlineprotectedvirtual

Get the speed of the projectile.

Returns
The speed of the projectile.

Definition at line 63 of file Projectile.h.

◆ SetDamage()

virtual void Projectile::SetDamage ( const float damage)
inlineprotectedvirtual

Set the amount of damage the projectile will deal.

Parameters
damageThe amount of damage the projectile will deal.

Definition at line 55 of file Projectile.h.

◆ SetDirection()

virtual void Projectile::SetDirection ( const Vector2 direction)
inlineprotectedvirtual

Set the direction of the projectile.

Parameters
directionThe direction of the projectile.

Definition at line 59 of file Projectile.h.

◆ SetSpeed()

virtual void Projectile::SetSpeed ( const float speed)
inlineprotectedvirtual

Set the speed of the projectile.

Parameters
speedThe speed of the projectile.

Definition at line 51 of file Projectile.h.

◆ SetTexture()

static void Projectile::SetTexture ( Texture * pTexture)
inlinestatic

Set the texture that will be used to render the projectile.

Parameters
pTextureA pointer to the texture.

Definition at line 19 of file Projectile.h.

◆ ToString()

std::string Projectile::ToString ( ) const
virtual

Get the string representation of the projectile.

Returns
The string representation of the projectile.

Implements GameObject.

Definition at line 50 of file Projectile.cpp.

◆ Update()

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

Update the projectile.

Parameters
pGameTimeTiming values including time since last update.

Reimplemented from GameObject.

Definition at line 13 of file Projectile.cpp.

◆ WasShotByPlayer()

virtual bool Projectile::WasShotByPlayer ( ) const
inlineprotectedvirtual

Determine if the projectile was fired by the player.

Returns
True if the projectile was fired by the player.

Definition at line 71 of file Projectile.h.


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