module charge.game.scene.scene

Source file for Scene base class and Manager interface.

Code Map

//! Source file for Scene base class and Manager interface.
module charge.game.scene.scene;


//! A interface back to the main controller, often the main game loop.
interface Manager
{
public:
	//! Push this scene to top of the stack.
	fn push(Scene);
	//! Remove this scene from the stack.
	fn remove(Scene);
	//! The given scene wants to be deleted.
	fn closeMe(Scene);
}

//! A scene often is a level, menu overlay or a loading screen.
class Scene
{
public:
	enum Flag
	{
		TakesInput,
		Transparent,
		Blocker,
		AlwaysOnTop,
	}

	enum Type
	{
		Background,
		Game,
		Menu,
		Overlay,
	}


public:
	flags: Flag;


public:
	this(m: Manager, type: Type) { }
	//! Shutdown this scene, this is called by the Manager.
	fn close();
	//! Called every time actions should be updated, timepoint given is when
	//! next frame is to be displayed.
	fn updateActions(timepoint: i64);
	//! Step the game logic one step.
	fn logic();
	//! Render view of this scene into target.
	fn render(gfx.Target, gfx.ViewInfo);
	//! Install all input listeners.
	fn assumeControl();
	//! Uninstall all input listeners.
	fn dropControl();


protected:
	mManager: Manager;
}
class Scene

A scene often is a level, menu overlay or a loading screen.

fn close()

Shutdown this scene, this is called by the Manager.

And should not be called by other code.

fn updateActions(timepoint: i64)

Called every time actions should be updated, timepoint given is when next frame is to be displayed.

fn logic()

Step the game logic one step.

fn render(gfx.Target, gfx.ViewInfo)

Render view of this scene into target.

fn assumeControl()

Install all input listeners.

fn dropControl()

Uninstall all input listeners.

interface Manager

A interface back to the main controller, often the main game loop.

fn push(Scene)

Push this scene to top of the stack.

fn remove(Scene)

Remove this scene from the stack.

fn closeMe(Scene)

The given scene wants to be deleted.