Table of Contents

Class GameBase

Namespace
OmegaEngine
Assembly
OmegaEngine.dll

Automatically provides an Engine instance with a fullscreen-capable window, render loop, input handling, etc.

public abstract class GameBase : IDisposable
Inheritance
GameBase
Implements
Derived
Inherited Members
Extension Methods

Remarks

By using this class, you don't need to create a window, set up InputProviders, provide access to DebugConsole, etc. yourself.

You should override at least Initialize() and Render(double). This corresponds to the template method pattern.

Constructors

GameBase(string, Icon?, Image?, bool)

Sets up the Form. Call ToWindowed(Size) or ToFullscreen() and Run() afterwards.

protected GameBase(string name, Icon? icon = null, Image? background = null, bool stretch = false)

Parameters

name string

The name of the application for the title bar

icon Icon

The icon of the application for the title bar

background Image

A background image for the window while loading

stretch bool

Stretch background to fit the screen? (false will center it instead)

Fields

Form

The internal form used as the Engine render-targets

protected readonly GameBase.GameForm Form

Field Value

GameBase.GameForm

Properties

Disposed

Has the game been shutdown?

[Browsable(false)]
public bool Disposed { get; }

Property Value

bool

Engine

The Engine instance used by the game. Warning! Only set after Show() has been called

[LuaHide]
public Engine Engine { get; }

Property Value

Engine

Fullscreen

Is the game in fullscreen mode?

public bool Fullscreen { get; }

Property Value

bool

KeyboardInputProvider

A default KeyboardInputProvider hooked up to the Form.

public KeyboardInputProvider KeyboardInputProvider { get; }

Property Value

KeyboardInputProvider

Loading

Indicates the game is currently loading something and the user must wait.

public bool Loading { get; set; }

Property Value

bool

Remarks

On Windows 7 and newer this will cause a neat taskbar animation.

MouseInputProvider

A default MouseInputProvider hooked up to the Form.

public MouseInputProvider MouseInputProvider { get; }

Property Value

MouseInputProvider

TouchInputProvider

A default TouchInputProvider hooked up to the Form.

public TouchInputProvider TouchInputProvider { get; }

Property Value

TouchInputProvider

Methods

AddInputReceiver(IInputReceiver)

public void AddInputReceiver(IInputReceiver receiver)

Parameters

receiver IInputReceiver

The object to receive the commands.

ApplyGraphicsSettings()

Called when graphics settings from an external source need to be applied to the Engine

protected virtual void ApplyGraphicsSettings()

BuildEngineConfig(bool)

Called to generate an EngineConfig based on external settings

protected virtual EngineConfig BuildEngineConfig(bool fullscreen)

Parameters

fullscreen bool

Shall the configuration be generated for fullscreen mode?

Returns

EngineConfig

Crash()

Crashes the game for testing purposes

[LuaGlobal]
public static void Crash()

Debug()

Called when the debug form is to be displayed

[LuaHide]
public virtual void Debug()

Dispose()

Dispose the Engine, the internal windows form, etc.

public void Dispose()

Dispose(bool)

To be called by Dispose() and the object destructor.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true if called manually and not by the garbage collector.

Exit()

Stops the render loop and closes the window

public void Exit()

~GameBase()

protected ~GameBase()

Initialize()

To be called after the window is ready and the Engine needs to be set up

protected virtual bool Initialize()

Returns

bool

true if the initialization worked, false if it failed an the app must be closed

NewLua()

Creates a new LuaInterface.Lua instance with commonly used objects preloaded.

[LuaHide]
public virtual Lua NewLua()

Returns

Lua

RemoveInputReceiver(IInputReceiver)

public void RemoveInputReceiver(IInputReceiver receiver)

Parameters

receiver IInputReceiver

The object to no longer receive the commands.

Render(double)

Called when the next frame needs to be rendered.

protected virtual void Render(double elapsedTime)

Parameters

elapsedTime double

The number of seconds that have passed since this method was last called.

ResetEngine()

Resets the Engine

[LuaGlobal(Description = "Resets the graphics engine")]
protected virtual void ResetEngine()

Run()

Shows the window and runs the render loop until Exit() is called.

[LuaHide]
public virtual void Run()

ToFullscreen()

Sets up the Form for fullscreen display

protected void ToFullscreen()

ToWindowed(Size)

Sets up the Form for normal windowed (non-fullscreen) mode

protected void ToWindowed(Size size)

Parameters

size Size

The window size

UpdateStatus(string)

Updates the current status of the loading process

protected void UpdateStatus(string message)

Parameters

message string

The new message to display