My Project
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
BaseScene Struct Referenceabstract

The BaseScene struct provides a basic template for game scenes, including player, enemies, food, and grounds. More...

#include <BaseScene.h>

Inheritance diagram for BaseScene:
Scene Level1Scene Level2Scene Level3Scene

Public Member Functions

 BaseScene (SDL_Renderer *renderer, SDL_Window *window)
 Constructor for BaseScene.
 
virtual ~BaseScene () override
 Destructor for BaseScene.
 
void Init () override
 Initializes the scene.
 
void StartUp () override
 Starts up the scene.
 
void Cleanup () override
 Cleans up the scene.
 
bool IsCompleted () const override
 Checks if the scene is completed.
 
bool IsWin () const override
 Checks if the player has won the scene.
 
void HandleInput (float deltaTime) override
 Handles player input for the scene.
 
void Render () override
 Renders all entities in the scene.
 
void Update (float deltaTime) override
 Updates the state of the scene.
 
virtual void SetupLevel ()=0
 Sets up the level-specific entities and logic.
 

Protected Attributes

std::vector< std::shared_ptr< EnemyGameEntity > > enemies
 
std::vector< std::shared_ptr< FoodGameEntity > > foods
 
std::unique_ptr< PlayerGameEntitymainCharacter
 
std::vector< std::shared_ptr< GroundGameEntity > > Grounds
 
std::unique_ptr< BackGroundGameEntitybackGround
 
bool mRun {true}
 
float mPoints {0.0f}
 
SDL_Window * mWindow = nullptr
 
SDL_Renderer * mRenderer = nullptr
 
bool isCompleted = false
 
bool isWin = false
 

Detailed Description

The BaseScene struct provides a basic template for game scenes, including player, enemies, food, and grounds.

This structure manages a collection of game entities and implements common scene behaviors such as initialization, input handling, updating state, and rendering. It serves as a base for more specific scene implementations in the game.

Constructor & Destructor Documentation

◆ BaseScene()

BaseScene::BaseScene ( SDL_Renderer * renderer,
SDL_Window * window )
inline

Constructor for BaseScene.

Parameters
rendererThe SDL renderer for drawing entities.
windowThe SDL window for rendering.

Initializes the scene with the given renderer and window, setting up the basic scene structure.

◆ ~BaseScene()

virtual BaseScene::~BaseScene ( )
inlineoverridevirtual

Destructor for BaseScene.

Handles clean-up and resource deallocation.

Member Function Documentation

◆ Cleanup()

void BaseScene::Cleanup ( )
inlineoverridevirtual

Cleans up the scene.

Deallocates resources and performs any necessary clean-up operations.

Implements Scene.

◆ HandleInput()

void BaseScene::HandleInput ( float deltaTime)
inlineoverridevirtual

Handles player input for the scene.

Parameters
deltaTimeThe time since the last update.

Processes SDL events and updates player states based on input.

Implements Scene.

◆ Init()

void BaseScene::Init ( )
inlineoverridevirtual

Initializes the scene.

Sets up resources and prepares the scene for starting.

Implements Scene.

◆ IsCompleted()

bool BaseScene::IsCompleted ( ) const
inlineoverridevirtual

Checks if the scene is completed.

Returns
True if the scene is completed, false otherwise.

Implements Scene.

◆ IsWin()

bool BaseScene::IsWin ( ) const
inlineoverridevirtual

Checks if the player has won the scene.

Returns
True if the player has won, false otherwise.

Implements Scene.

◆ Render()

void BaseScene::Render ( )
inlineoverridevirtual

Renders all entities in the scene.

Draws the background, player, enemies, food, and grounds to the screen.

Implements Scene.

◆ SetupLevel()

virtual void BaseScene::SetupLevel ( )
pure virtual

Sets up the level-specific entities and logic.

This method must be implemented by derived classes to create a specific level's layout and gameplay elements.

◆ StartUp()

void BaseScene::StartUp ( )
inlineoverridevirtual

Starts up the scene.

Loads and initializes all essential entities for the scene.

Implements Scene.

◆ Update()

void BaseScene::Update ( float deltaTime)
inlineoverridevirtual

Updates the state of the scene.

Parameters
deltaTimeThe time since the last update.

Updates the positions and states of all entities in the scene. Handles gameplay logic such as collisions and scoring.

Implements Scene.


The documentation for this struct was generated from the following file: