galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::scene::Scene Class Referencefinal

Represents a scene in a game. Like the menu, game, etc. Does not share resources. More...

#include <Scene.hpp>

+ Inheritance diagram for galaxy::scene::Scene:
+ Collaboration diagram for galaxy::scene::Scene:

Public Member Functions

 Scene (const std::string &name)
 Name constructor.
 
virtual ~Scene ()
 Destructor.
 
virtual void load ()
 When scene is loaded and made active.
 
virtual void unload ()
 When scene is deactivated / unloaded.
 
virtual void update ()
 Process events and updates.
 
virtual void render ()
 Render scene.
 
bool load_world (const std::string &file)
 Loads an LDTK world for this scene.
 
nlohmann::json serialize () override
 Serializes object.
 
void deserialize (const nlohmann::json &json) override
 Deserializes from object.
 
 Scene (const std::string &name)
 Name constructor.
 
virtual ~Scene ()
 Destructor.
 
void add_system (const std::string &system)
 Add a system to operate on entities in this scene.
 
void load ()
 When scene is loaded and made active.
 
void unload ()
 When scene is deactivated / unloaded.
 
void update (core::Registry &registry)
 Process events and updates.
 
void render ()
 Update ui.
 
const std::string & name () const noexcept
 Get scene name.
 
nlohmann::json serialize () override
 Serializes object.
 
void deserialize (const nlohmann::json &json) override
 Deserializes from object.
 

Public Attributes

std::string m_name
 Scene name for debug purposes.
 
graphics::Camera m_camera
 Camera.
 
entt::dispatcher m_dispatcher
 Scene event handler.
 
core::Registry m_registry
 Entity data.
 
b2World m_b2world
 Box2D physics world.
 
map::World m_world
 LDTK world.
 
int m_velocity_iterations
 Box2D world velocity iterations.
 
int m_position_iterations
 Box2d world position iterations.
 

Private Member Functions

 Scene ()=delete
 Constructor.
 
 Scene ()=delete
 Constructor.
 

Private Attributes

meta::SystemStack m_systems
 List of systems to run.
 

Detailed Description

Represents a scene in a game. Like the menu, game, etc. Does not share resources.

Represents a scene in a game. Like the menu, game, etc.

Scenes should be logically grouped -> i.e. a map, player data + ui, battle, menu, etc. Each scene is an independant collection of systems, but not entities.

Definition at line 28 of file Scene.hpp.

Constructor & Destructor Documentation

◆ Scene() [1/4]

galaxy::scene::Scene::Scene ( const std::string & name)

Name constructor.

Parameters
nameName of the scene for debug / editor purposes.

Definition at line 35 of file Scene.cpp.

+ Here is the call graph for this function:

◆ ~Scene() [1/2]

galaxy::scene::Scene::~Scene ( )
virtual

Destructor.

Definition at line 47 of file Scene.cpp.

◆ Scene() [2/4]

galaxy::scene::Scene::Scene ( )
privatedelete

Constructor.

◆ Scene() [3/4]

galaxy::scene::Scene::Scene ( const std::string & name)

Name constructor.

Parameters
nameName of the scene for debug / editor purposes.

◆ ~Scene() [2/2]

virtual galaxy::scene::Scene::~Scene ( )
virtual

Destructor.

◆ Scene() [4/4]

galaxy::scene::Scene::Scene ( )
privatedelete

Constructor.

Member Function Documentation

◆ load() [1/2]

void galaxy::scene::Scene::load ( )
virtual

When scene is loaded and made active.

Definition at line 51 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ unload() [1/2]

void galaxy::scene::Scene::unload ( )
virtual

When scene is deactivated / unloaded.

Definition at line 56 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ update() [1/2]

void galaxy::scene::Scene::update ( )
virtual

Process events and updates.

Definition at line 61 of file Scene.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render() [1/2]

void galaxy::scene::Scene::render ( )
virtual

Render scene.

Definition at line 68 of file Scene.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_world()

bool galaxy::scene::Scene::load_world ( const std::string & file)
nodiscard

Loads an LDTK world for this scene.

Parameters
file.ldtk project file to load.
Returns
True if loaded successfully.

Definition at line 82 of file Scene.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize() [1/2]

nlohmann::json galaxy::scene::Scene::serialize ( )
nodiscardoverride

Serializes object.

Returns
JSON object containing data to write out.

Definition at line 93 of file Scene.cpp.

+ Here is the call graph for this function:

◆ deserialize() [1/2]

void galaxy::scene::Scene::deserialize ( const nlohmann::json & json)
override

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Definition at line 124 of file Scene.cpp.

+ Here is the call graph for this function:

◆ add_system()

void galaxy::scene::Scene::add_system ( const std::string & system)

Add a system to operate on entities in this scene.

Scene is called in order of adding. So i.e. if you add anim then render, systems are called in that order.

Parameters
systemName of system to add to this scene.

Definition at line 40 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ load() [2/2]

void galaxy::scene::Scene::load ( )

When scene is loaded and made active.

◆ unload() [2/2]

void galaxy::scene::Scene::unload ( )

When scene is deactivated / unloaded.

◆ update() [2/2]

void galaxy::scene::Scene::update ( core::Registry & registry)

Process events and updates.

Parameters
registryRegistry to process.

Definition at line 55 of file Scene.cpp.

◆ render() [2/2]

void galaxy::scene::Scene::render ( )

Update ui.

Render scene.

◆ name()

const std::string & galaxy::scene::Scene::name ( ) const
nodiscardnoexcept

Get scene name.

Definition at line 103 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ serialize() [2/2]

nlohmann::json galaxy::scene::Scene::serialize ( )
nodiscardoverride

Serializes object.

Returns
JSON object containing data to write out.

◆ deserialize() [2/2]

void galaxy::scene::Scene::deserialize ( const nlohmann::json & json)
override

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Member Data Documentation

◆ m_name

std::string galaxy::scene::Scene::m_name

Scene name for debug purposes.

Definition at line 94 of file Scene.hpp.

◆ m_camera

graphics::Camera galaxy::scene::Scene::m_camera

Camera.

Definition at line 99 of file Scene.hpp.

◆ m_dispatcher

entt::dispatcher galaxy::scene::Scene::m_dispatcher

Scene event handler.

Definition at line 104 of file Scene.hpp.

◆ m_registry

core::Registry galaxy::scene::Scene::m_registry

Entity data.

Definition at line 109 of file Scene.hpp.

◆ m_b2world

b2World galaxy::scene::Scene::m_b2world

Box2D physics world.

Definition at line 114 of file Scene.hpp.

◆ m_world

map::World galaxy::scene::Scene::m_world

LDTK world.

Definition at line 119 of file Scene.hpp.

◆ m_velocity_iterations

int galaxy::scene::Scene::m_velocity_iterations

Box2D world velocity iterations.

Definition at line 124 of file Scene.hpp.

◆ m_position_iterations

int galaxy::scene::Scene::m_position_iterations

Box2d world position iterations.

Definition at line 129 of file Scene.hpp.

◆ m_systems

meta::SystemStack galaxy::scene::Scene::m_systems
private

List of systems to run.

Definition at line 115 of file Scene.hpp.


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