Wraith  0.1.5
Basic 3D game engine in C++

A Scene is the place where GameObject entities exists. NOTE: Users will use the SceneManager to access and set scene entities. More...

Collaboration diagram for Scene:

Functions

void Scene::setCurrentCamera (Camera *pCamera)
 Sets current camera./ More...
 
void Scene::setDefaultCameraAsCurrentCamera ()
 Sets default camera as current camera./ More...
 
void Scene::setCurrent2DCamera (Camera *p2DCamera)
 Sets current 2D camera. More...
 
void Scene::setDefault2DCameraAsCurrentCamera ()
 Sets default 2D camera as current camera 2D. More...
 
Camera * Scene::getCurrentCamera () const
 Gets the current camera. More...
 
Camera * Scene::getDefaultCamera () const
 Gets the default camera. More...
 
Camera * Scene::getCurrent2DCamera () const
 Gets the current 2D camera. More...
 
Camera * Scene::getDefault2DCamera () const
 Gets default 2D camera. More...
 
template<class UserClass1 , class UserClass2 >
void Scene::setCollisionPair ()
 Sets collision pair between two user defined classes. More...
 
template<class UserClass >
void Scene::setCollisionSelf ()
 Sets collision within a single user defined class. More...
 
template<class UserClass >
void Scene::setCollisionTerrain ()
 Sets collision with the terrain. More...
 
void Scene::setTerrain (const std::string &terrainObjectName)
 Sets the terrain to be used in the scene. More...
 
virtual void Scene::initialize ()=0
 Initializes this scene. More...
 
virtual void Scene::sceneEnd ()=0
 Ends the scene. More...
 
static void SceneManager::SetStartScene (Scene *pScene)
 Sets a start scene to begin with. More...
 
static void SceneManager::SetNextScene (Scene *pScene)
 Sets the next scene to change to. More...
 
static SceneSceneManager::GetCurrentScene ()
 Gets the current scene. More...
 

Detailed Description

A Scene is the place where GameObject entities exists. NOTE: Users will use the SceneManager to access and set scene entities.

Scenes handle many of services and callbacks that GameObject entities have such as updating, drawing, inputs, and collisions The Scene entities are managed by SceneManager. The SceneManager allows user access to the current scene. As well as setting the next scene. When deriving from Scene, there are two methods the users musth implement: Scene::initialize and Scene::sceneEnd.

Scene::initialize is where the user instantiates GameObject entities. Also Scene::setCollisionPair() and Scene::setCollisionSelf() that are to be tested within the scene. Refer to Collisions for more information about collisions. As well as setting the terrain (by calling Scene::setTerrain()) the user wants to use in the scene (optional).

Scene::sceneEnd is where the user deletes any GameObject entities created and where entities created by factories should be recalled here.

Here is an example of how a user defined scene would be set up. NOTE: Tanks create bullets with a factory so the factory must recall all bullets in Scene::sceneEnd().

LevelOneScene::initialize()
{
// (OPTIONAL) Setting the terrain to be used
Scene::setTerrain ("MountainTerrain");
// Setting Collision Tests
// -> Collidable vs Collidable
setCollisionSelf<Tank>();
setCollisionPair<Tank, Bullet>();
setCollisionSelf<Bullet>();
setCollisionPair<Bullet, WindMill>();
setCollisionPair<Bullet, Warehouse>();
setCollisionPair<Bullet, Tree>();
// -> Collidable vs Terrain
setCollisionTerrain<Tank>();
setCollisionTerrain<Bullet>();
// Initialzing Entities
Tank* pPlayerTank = new Tank();
Tank* pEnemyTank = new Tank();
WindMill* pWindMill_1 = new WindMill();
WindMill* pWindMill_2 = new WindMill();
}
LevelOneScene::sceneEnd()
{
delete pPlayerTank
delete pEnemyTank;
delete pWindMill_1;
delete pWindMill_2;
// NOTE: This where factories should recall live game object.
BulletFactory::RecallBullets();
}
void setTerrain(const std::string &terrainObjectName)
Sets the terrain to be used in the scene.
Definition: Scene.cpp:8

For switching to another scene we call on SceneManager::SetNextScene() and pass in the scene we want to switch to. Here is an example of how a user defined GameObject SceneChanger could be used to switch to another scene NOTE: You must include SceneManager.h header file to access SceneManager.

#include "SceneManager.h"
SceneChanger::SceneChanger(Scene* pNextScene)
{
_pNextScene = pNextScene;
// Here we will use key press to switch for next scene
GameObject::submitKeyRegistration(AZUL_KEY::SPACE, InputEvent::KEY_PRESS);
}
SceneChanger::keyPressed(AZUL_KEY key)
{
if(key == AZUL_KEY::SPACE)
{
this->switchScene();
}
}
SceneChanger::switchScene()
{
}
A scene. The place where user defined game objects are created and controlled. Scene handles game obj...
Definition: Scene.h:33
void submitKeyRegistration(AZUL_KEY key, InputEvent eventType)
Submit key registration to current scene.
Definition: Inputable.cpp:29
static void SetNextScene(Scene *pScene)
Sets the next scene to change to.
Definition: SceneManager.h:118

Function Documentation

◆ getCurrent2DCamera()

Camera * Scene::getCurrent2DCamera ( ) const

Gets the current 2D camera.

Returns
the current 2D camera.

◆ getCurrentCamera()

Camera * Scene::getCurrentCamera ( ) const

Gets the current camera.

Returns
current camera.

◆ GetCurrentScene()

static Scene* SceneManager::GetCurrentScene ( )
inlinestatic

Gets the current scene.

Returns
the current scene.

◆ getDefault2DCamera()

Camera * Scene::getDefault2DCamera ( ) const

Gets default 2D camera.

Returns
the default 2D camera.

◆ getDefaultCamera()

Camera * Scene::getDefaultCamera ( ) const

Gets the default camera.

Returns
the default camera.

◆ initialize()

virtual void Scene::initialize ( )
privatepure virtual

Initializes this scene.

Implemented in NullScene.

◆ sceneEnd()

virtual void Scene::sceneEnd ( )
privatepure virtual

Ends the scene.

Implemented in NullScene.

◆ setCollisionPair()

template<class UserClass1 , class UserClass2 >
void Scene::setCollisionPair ( )
inlineprotected

Sets collision pair between two user defined classes.

Template Parameters
UserClass1Type of the user class 1.
UserClass2Type of the user class 2.

◆ setCollisionSelf()

template<class UserClass >
void Scene::setCollisionSelf ( )
inlineprotected

Sets collision within a single user defined class.

Template Parameters
UserClassType of the user class.

◆ setCollisionTerrain()

template<class UserClass >
void Scene::setCollisionTerrain ( )
inlineprotected

Sets collision with the terrain.

Template Parameters
UserClassType of the user class.

◆ setCurrent2DCamera()

void Scene::setCurrent2DCamera ( Camera *  p2DCamera)

Sets current 2D camera.

Parameters
p2DCamerapointer to a 2D Camera.

◆ setCurrentCamera()

void Scene::setCurrentCamera ( Camera *  pCamera)

Sets current camera./

Parameters
pCamerapointer to a camera

◆ setDefault2DCameraAsCurrentCamera()

void Scene::setDefault2DCameraAsCurrentCamera ( )

Sets default 2D camera as current camera 2D.

◆ setDefaultCameraAsCurrentCamera()

void Scene::setDefaultCameraAsCurrentCamera ( )

Sets default camera as current camera./

◆ SetNextScene()

static void SceneManager::SetNextScene ( Scene pScene)
inlinestatic

Sets the next scene to change to.

Parameters
pScenepointer to the next scene.

◆ SetStartScene()

static void SceneManager::SetStartScene ( Scene pScene)
inlinestatic

Sets a start scene to begin with.

Parameters
pScenepointer to the start scene.

◆ setTerrain()

void Scene::setTerrain ( const std::string &  terrainObjectName)
protected

Sets the terrain to be used in the scene.

Parameters
terrainObjectNamethe name of the terrain object.