Arcade Shooter
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
ShooterLibrary::GameObject Class Referenceabstract

Base class for all objects that will be updated and rendered on a GameplayScreen. More...

#include <GameObject.h>

Inheritance diagram for ShooterLibrary::GameObject:
Sample::PowerUp ShooterLibrary::Projectile ShooterLibrary::Ship Sample::Missile ShooterLibrary::EnemyShip ShooterLibrary::PlayerShip Sample::BioEnemyShip Sample::PlayerShip

Public Member Functions

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 std::string ToString () const =0
 Gets a string representation 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 CollisionType GetCollisionType () const =0
 Gets the collision type mask. 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...
 
virtual bool IsDrawnByLevel () const
 Determines if the level should draw the game object. More...
 

Static Public Member Functions

static void SetCurrentLevel (Level *pLevel)
 Sets the current game level. More...
 
static LevelGetCurrentLevel ()
 Gets the current level. More...
 

Protected Member Functions

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...
 

Friends

class Game
 

Detailed Description

Base class for all objects that will be updated and rendered on a GameplayScreen.

Member Function Documentation

◆ Draw()

virtual void ShooterLibrary::GameObject::Draw ( SpriteBatch pSpriteBatch)
pure virtual

Renders the game object.

Parameters
pSpriteBatchThe game's sprite batch, used for rendering.
Remarks
This should be called automatically by the Level, as long as the gameobject is added to the Level by calling Level::AddGameObject().
See also
Level::AddGameObject()

◆ GetCollisionRadius()

virtual float ShooterLibrary::GameObject::GetCollisionRadius ( ) const
inlinevirtual

Gets the collision radius.

Returns
Returns the collision radius.

◆ GetCollisionType()

virtual CollisionType ShooterLibrary::GameObject::GetCollisionType ( ) const
pure virtual

Gets the collision type mask.

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

Implemented in ShooterLibrary::PlayerShip, ShooterLibrary::Ship, ShooterLibrary::EnemyShip, ShooterLibrary::Projectile, and Sample::PowerUp.

◆ GetCurrentLevel()

static Level* ShooterLibrary::GameObject::GetCurrentLevel ( )
inlinestatic

Gets the current level.

Returns
Returns a pointer to the current level.

◆ GetHalfDimensions()

Vector2 ShooterLibrary::GameObject::GetHalfDimensions ( ) const
virtual

Gets the half dimensions of the game object.

Returns
Returns the half dimensions of the object.

Reimplemented in Sample::PlayerShip, and ShooterLibrary::PlayerShip.

◆ GetIndex()

virtual uint32_t ShooterLibrary::GameObject::GetIndex ( ) const
inlinevirtual

Gets the index of the game object.

Returns
Returns the index of the object.

◆ GetPosition()

virtual Vector2& ShooterLibrary::GameObject::GetPosition ( )
inlinevirtual

Gets the position of the game object.

Returns
Returns the object's position on the screen.

◆ GetPreviousPosition()

virtual Vector2& ShooterLibrary::GameObject::GetPreviousPosition ( )
inlinevirtual

Gets the previous position of the game object.

Returns
Returns the object's position on the screen during the previous frame.

◆ HasMask()

virtual bool ShooterLibrary::GameObject::HasMask ( CollisionType  mask) const
inlinevirtual

Determines if the object contains part of a collision bit-mask.

Parameters
maskThe mask to test.
Returns
Returns true if the object's collision mask matches or contains part of the bit-mask, false otherwise.

◆ Hit()

virtual void ShooterLibrary::GameObject::Hit ( const float  damage)
inlinevirtual

Hits the object, dealing damage to it.

Parameters
damageThe amount of damage to inflict.

Reimplemented in Sample::PlayerShip, ShooterLibrary::EnemyShip, Sample::BioEnemyShip, and ShooterLibrary::Ship.

◆ IsActive()

virtual bool ShooterLibrary::GameObject::IsActive ( ) const
inlinevirtual

Determines if the game object is active.

Returns
Returns true if the game object is active, false otherwise.

◆ IsDrawnByLevel()

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

Determines if the level should draw the game object.

Returns
Returns true if the level should be responsible for drawing the game object.
Remarks
Override this method if you want to manually draw it.

Reimplemented in ShooterLibrary::Projectile.

◆ IsMask()

virtual bool ShooterLibrary::GameObject::IsMask ( CollisionType  mask) const
inlinevirtual

Determines if the object matches a collision bit-mask.

Parameters
maskThe mask to test.
Returns
Returns true if the object's collision mask matches the bit-mask, false otherwise.

◆ IsOnScreen()

bool ShooterLibrary::GameObject::IsOnScreen ( ) const
protectedvirtual

Determines if the game object is on the screen.

Returns
Returns true if the game object is on the screen, false otherwise.

◆ SetCollisionRadius()

virtual void ShooterLibrary::GameObject::SetCollisionRadius ( const int  radius)
inlineprotectedvirtual

Sets the collision radius for the object.

Parameters
radiusThe collision radius.

◆ SetCurrentLevel()

static void ShooterLibrary::GameObject::SetCurrentLevel ( Level pLevel)
inlinestatic

Sets the current game level.

Parameters
pLevelA pointer to the current level.
Remarks
This is called automatically when a Level is constructed.

◆ SetDeactivateCallback()

virtual void ShooterLibrary::GameObject::SetDeactivateCallback ( OnDeactivate  callback)
inlinevirtual

Sets the callback function for when the menu item is selected.

Parameters
callbackThe callback function.

◆ SetPosition() [1/2]

void ShooterLibrary::GameObject::SetPosition ( const float  x,
const float  y 
)
protectedvirtual

Sets the screen position of the object.

Parameters
xThe horizontal position.
yThe vertical position.

◆ SetPosition() [2/2]

void ShooterLibrary::GameObject::SetPosition ( const Vector2 position)
protectedvirtual

Sets the screen position of the object.

Parameters
positionThe new position.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ToString()

virtual std::string ShooterLibrary::GameObject::ToString ( ) const
pure virtual

Gets a string representation of the game object.

Returns
Returns a string displaying the type of object.

Implemented in Sample::PowerUp, ShooterLibrary::Ship, ShooterLibrary::EnemyShip, ShooterLibrary::Projectile, ShooterLibrary::PlayerShip, and Sample::Missile.

◆ TranslatePosition() [1/2]

void ShooterLibrary::GameObject::TranslatePosition ( const float  x,
const float  y 
)
protectedvirtual

Offsets the current screen position of the object.

Parameters
xThe horizontal distance to offset.
yThe vertical distance to offset.

◆ TranslatePosition() [2/2]

void ShooterLibrary::GameObject::TranslatePosition ( const Vector2 offset)
protectedvirtual

Offsets the current screen position of the object.

Parameters
offsetThe offset.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Update()

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

Updates the game object.

Parameters
pGameTimeTiming values including time since last update.
Remarks
This should be called automatically by the Level, as long as the gameobject is added to the Level by calling Level::AddGameObject().
See also
Level::AddGameObject()

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