Arcade Shooter
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ShooterLibrary::Projectile Class Reference

Base class for all projectile types. More...

#include <Projectile.h>

Inheritance diagram for ShooterLibrary::Projectile:
ShooterLibrary::GameObject Sample::Missile

Public Member Functions

virtual void Update (const GameTime *pGameTime)
 Called when the game determines it is time to draw a frame. More...
 
virtual void Draw (SpriteBatch *pSpriteBatch)
 Called when the game determines it is time to draw a frame. More...
 
virtual void Activate (const Vector2 &position, bool wasShotByPlayer=true)
 Activates the projectile. More...
 
virtual float GetDamage () const
 Gets the damage of the projectile. More...
 
virtual std::string ToString () const
 Gets a string representation of the projectile. More...
 
virtual CollisionType GetCollisionType () const
 Gets the collision type mask. More...
 
virtual bool IsDrawnByLevel () const
 Determines if the level should draw the projectile. More...
 
virtual void SetManualDraw (const bool drawManually=true)
 Sets if the level should draw the projectile. More...
 
- Public Member Functions inherited from ShooterLibrary::GameObject
virtual void SetDeactivateCallback (OnDeactivate callback)
 Sets the callback function for when the menu item is selected. More...
 
virtual void Update (const GameTime *pGameTime)
 Updates the game object. More...
 
virtual void Draw (SpriteBatch *pSpriteBatch)=0
 Renders the game object. More...
 
virtual bool IsActive () const
 Determines if the game object is active. More...
 
virtual void Activate ()
 Activates the game object.
 
virtual void Deactivate ()
 Deactivates the game object.
 
virtual Vector2GetPosition ()
 Gets the position of the game object. More...
 
virtual Vector2GetPreviousPosition ()
 Gets the previous position of the game object. More...
 
virtual Vector2 GetHalfDimensions () const
 Gets the half dimensions of the game object. More...
 
virtual uint32_t GetIndex () const
 Gets the index of the game object. More...
 
virtual float GetCollisionRadius () const
 Gets the collision radius. More...
 
virtual void Hit (const float damage)
 Hits the object, dealing damage to it. More...
 
virtual bool HasMask (CollisionType mask) const
 Determines if the object contains part of a collision bit-mask. More...
 
virtual bool IsMask (CollisionType mask) const
 Determines if the object matches a collision bit-mask. More...
 

Static Public Member Functions

static void SetTexture (Texture *pTexture)
 Sets the texture of the player ship. More...
 
- Static Public Member Functions inherited from ShooterLibrary::GameObject
static void SetCurrentLevel (Level *pLevel)
 Sets the current game level. More...
 
static LevelGetCurrentLevel ()
 Gets the current level. More...
 

Protected Member Functions

virtual void SetSpeed (const float speed)
 Sets the speed of the projectile. More...
 
virtual void SetDamage (const float damage)
 Sets the amount of damage the projectile inflicts. More...
 
virtual void SetDirection (const Vector2 direction)
 Sets the direction of the projectile. More...
 
virtual float GetSpeed () const
 Gets the speed of the projectile in pixels per second. More...
 
virtual Vector2 & GetDirection ()
 Gets the direction of the projectile. More...
 
virtual bool WasShotByPlayer () const
 Determines if the projectile was shot by a player. More...
 
virtual CollisionType GetProjectileType () const
 Gets the collision type mask for the projectile. More...
 
virtual std::string GetProjectileTypeString () const
 Gets a string representation of the projectile. More...
 
- Protected Member Functions inherited from ShooterLibrary::GameObject
virtual void SetCollisionRadius (const int radius)
 Sets the collision radius for the object. More...
 
virtual void SetPosition (const float x, const float y)
 Sets the screen position of the object. More...
 
virtual void SetPosition (const Vector2 &position)
 Sets the screen position of the object. More...
 
virtual void TranslatePosition (const float x, const float y)
 Offsets the current screen position of the object. More...
 
virtual void TranslatePosition (const Vector2 &offset)
 Offsets the current screen position of the object. More...
 
virtual bool IsOnScreen () const
 Determines if the game object is on the screen. More...
 

Detailed Description

Base class for all projectile types.

Member Function Documentation

◆ Activate()

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

Activates the projectile.

Parameters
positionThe starting position of the projectile.
wasShotByPlayerIndicates if the player fired the projectile.

Reimplemented in Sample::Missile.

◆ Draw()

void ShooterLibrary::Projectile::Draw ( SpriteBatch pSpriteBatch)
virtual

Called when the game determines it is time to draw a frame.

Parameters
pSpriteBatchThe game's sprite batch, used for rendering.

Reimplemented in Sample::Missile.

◆ GetCollisionType()

CollisionType ShooterLibrary::Projectile::GetCollisionType ( ) const
virtual

Gets the collision type mask.

Returns
Returns bit-mask value for the collision type.
See also
CollisionType
CollisionManager

Implements ShooterLibrary::GameObject.

◆ GetDamage()

virtual float ShooterLibrary::Projectile::GetDamage ( ) const
inlinevirtual

Gets the damage of the projectile.

Returns
Returns a the amount of damage the projectile inflicts.

◆ GetDirection()

virtual Vector2& ShooterLibrary::Projectile::GetDirection ( )
inlineprotectedvirtual

Gets the direction of the projectile.

Returns
Returns the direction vector of the projectile.

◆ GetProjectileType()

virtual CollisionType ShooterLibrary::Projectile::GetProjectileType ( ) const
inlineprotectedvirtual

Gets the collision type mask for the projectile.

Returns
Returns bit-mask value for the collision type, not including the ship type.

◆ GetProjectileTypeString()

virtual std::string ShooterLibrary::Projectile::GetProjectileTypeString ( ) const
inlineprotectedvirtual

Gets a string representation of the projectile.

Returns
Returns a string displaying the type of projectile, not including the ship type.

◆ GetSpeed()

virtual float ShooterLibrary::Projectile::GetSpeed ( ) const
inlineprotectedvirtual

Gets the speed of the projectile in pixels per second.

Returns
Returns the speed of the projectile.

◆ IsDrawnByLevel()

virtual bool ShooterLibrary::Projectile::IsDrawnByLevel ( ) const
inlinevirtual

Determines if the level should draw the projectile.

Returns
Returns true if the level should be responsible for drawing the projectile.
Remarks
We may want to manually render some projectiles so we can set the blend type to additive.

Reimplemented from ShooterLibrary::GameObject.

◆ SetDamage()

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

Sets the amount of damage the projectile inflicts.

Parameters
damageThe damage that the projectile inflicts.

◆ SetDirection()

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

Sets the direction of the projectile.

Parameters
directionThe normalized direction vector.

◆ SetManualDraw()

virtual void ShooterLibrary::Projectile::SetManualDraw ( const bool  drawManually = true)
inlinevirtual

Sets if the level should draw the projectile.

Parameters
drawManuallyTrue should be passed if you want to manually render the projectile. False if you want the level to be responsible.

◆ SetSpeed()

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

Sets the speed of the projectile.

Parameters
speedThe desired speed in pixels per second.

◆ SetTexture()

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

Sets the texture of the player ship.

Parameters
pTextureA pointer to the texture resource.

◆ ToString()

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

Gets a string representation of the projectile.

Returns
Returns a string displaying the type of object.

Implements ShooterLibrary::GameObject.

Reimplemented in Sample::Missile.

◆ Update()

void ShooterLibrary::Projectile::Update ( const GameTime pGameTime)
virtual

Called when the game determines it is time to draw a frame.

Parameters
pGameTimeTiming values including time since last update.

Reimplemented in Sample::Missile.

◆ WasShotByPlayer()

virtual bool ShooterLibrary::Projectile::WasShotByPlayer ( ) const
inlineprotectedvirtual

Determines if the projectile was shot by a player.

Returns
Returns true if the projectile was shot by the player, false otherwise.

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