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

Represents a level in the game. More...

#include <Level.h>

Inheritance diagram for Level:

Public Member Functions

 Level ()
 Instantiate a level object.
 
virtual ~Level ()
 
virtual void LoadContent (ResourceManager &resourceManager)
 Load the content for the level, including game objects and resources.
 
virtual void UnloadContent ()
 Unload the content for the level.
 
virtual void HandleInput (const InputState &input)
 Handle input for the level.
 
virtual void Update (const GameTime &gameTime)
 Update the level.
 
virtual void Draw (SpriteBatch &spriteBatch)
 Render the level, and all of the game objects within it.
 
virtual void AddGameObject (GameObject *pGameObject)
 Add a game object to the level. This object will be updated, rendered, and checked for collisions.
 
virtual void UpdateSectorPosition (GameObject *pGameObject)
 Update the position of a game object within the level, based on its collision sector (only objects within the same or adjacent sectors will be checked for collisions).
 
virtual void SetGameplayScreen (GameplayScreen *pGameplayScreen)
 Set a reference to the gameplay screen.
 
virtual void SpawnExplosion (GameObject *pExplodingObject)
 Spawn an explosion at a specific position.
 
virtual void SetBackground (Texture *pBackground)
 Set the background texture for the level.
 
virtual float GetAlpha () const
 Get the alpha value of the screen.
 
virtual bool IsScreenTransitioning () const
 Check if the screen is transitioning.
 
template<typename T >
TGetClosestObject (const Vector2 position, const float range)
 Get a pointer to the closest object of a specific type.
 

Protected Member Functions

virtual CollisionManagerGetCollisionManager ()
 Get a pointer to the collision manager.
 
virtual GameplayScreenGetGameplayScreen () const
 Get a pointer to the gameplay screen.
 
virtual void SetBackgroundAudio (AudioSample *pAudio)
 Set the background audio for the level.
 
virtual AudioSampleGetBackgroundAudio ()
 Get the background audio for the level.
 

Detailed Description

Represents a level in the game.

Definition at line 14 of file Level.h.

Constructor & Destructor Documentation

◆ Level()

Level::Level ( )

Instantiate a level object.

Definition at line 32 of file Level.cpp.

◆ ~Level()

Level::~Level ( )
virtual

Definition at line 75 of file Level.cpp.

Member Function Documentation

◆ AddGameObject()

virtual void Level::AddGameObject ( GameObject * pGameObject)
inlinevirtual

Add a game object to the level. This object will be updated, rendered, and checked for collisions.

Parameters
pGameObjectA pointer to the game object to add.

Definition at line 46 of file Level.h.

◆ Draw()

void Level::Draw ( SpriteBatch & spriteBatch)
virtual

Render the level, and all of the game objects within it.

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

Definition at line 243 of file Level.cpp.

◆ GetAlpha()

float Level::GetAlpha ( ) const
virtual

Get the alpha value of the screen.

Returns
The alpha value of the screen.

Definition at line 212 of file Level.cpp.

◆ GetBackgroundAudio()

virtual AudioSample * Level::GetBackgroundAudio ( )
inlineprotectedvirtual

Get the background audio for the level.

Returns
A pointer to the audio sample to play.

Definition at line 129 of file Level.h.

◆ GetClosestObject()

template<typename T >
T * Level::GetClosestObject ( const Vector2 position,
const float range )
inline

Get a pointer to the closest object of a specific type.

Parameters
positionThe position to check from.
rangeThe maximum range to check.
Returns
A pointer to the closest object of the specified type.

Definition at line 78 of file Level.h.

◆ GetCollisionManager()

virtual CollisionManager * Level::GetCollisionManager ( )
inlineprotectedvirtual

Get a pointer to the collision manager.

Returns
A pointer to the collision manager.

Definition at line 117 of file Level.h.

◆ GetGameplayScreen()

virtual GameplayScreen * Level::GetGameplayScreen ( ) const
inlineprotectedvirtual

Get a pointer to the gameplay screen.

Returns
A pointer to the gameplay screen.

Definition at line 121 of file Level.h.

◆ HandleInput()

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

Handle input for the level.

Parameters
inputThe current state of all player input devices.

Definition at line 110 of file Level.cpp.

◆ IsScreenTransitioning()

virtual bool Level::IsScreenTransitioning ( ) const
inlinevirtual

Check if the screen is transitioning.

Returns
True if the screen is transitioning.

Definition at line 71 of file Level.h.

◆ LoadContent()

void Level::LoadContent ( ResourceManager & resourceManager)
virtual

Load the content for the level, including game objects and resources.

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

Reimplemented in Level01, and Level02.

Definition at line 88 of file Level.cpp.

◆ SetBackground()

virtual void Level::SetBackground ( Texture * pBackground)
inlinevirtual

Set the background texture for the level.

Parameters
pBackgroundA pointer to the texture to use as the background.

Definition at line 63 of file Level.h.

◆ SetBackgroundAudio()

virtual void Level::SetBackgroundAudio ( AudioSample * pAudio)
inlineprotectedvirtual

Set the background audio for the level.

Parameters
pAudioA pointer to the audio sample to play.

Definition at line 125 of file Level.h.

◆ SetGameplayScreen()

virtual void Level::SetGameplayScreen ( GameplayScreen * pGameplayScreen)
inlinevirtual

Set a reference to the gameplay screen.

Parameters
pGameplayScreenA pointer to the gameplay screen.

Definition at line 55 of file Level.h.

◆ SpawnExplosion()

void Level::SpawnExplosion ( GameObject * pExplodingObject)
virtual

Spawn an explosion at a specific position.

Parameters
positionThe position to spawn the explosion at.

Definition at line 188 of file Level.cpp.

◆ UnloadContent()

virtual void Level::UnloadContent ( )
inlinevirtual

Unload the content for the level.

Definition at line 29 of file Level.h.

◆ Update()

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

Update the level.

Parameters
pGameTimeTiming values including time since last update.

Definition at line 118 of file Level.cpp.

◆ UpdateSectorPosition()

void Level::UpdateSectorPosition ( GameObject * pGameObject)
virtual

Update the position of a game object within the level, based on its collision sector (only objects within the same or adjacent sectors will be checked for collisions).

Parameters
pGameObjectA pointer to the game object to update.

Definition at line 153 of file Level.cpp.


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