Skip to content

Core Systems

Shmellyorc edited this page Aug 30, 2026 · 1 revision

Core Systems

The core systems are the foundation of Void Engine. They are the essential building blocks that every game needs.


Game Class

The Game class is the entry point for your application. It manages the game loop, window, timing, and application lifecycle. You create an instance with your settings and call Run() to start.

Lifecycle Methods

Method When It Is Called
OnEnter() Once, before the game loop starts
OnUpdate(FrameTime) Every frame, for game logic
OnDraw(FrameTime) Every frame, for rendering
OnExit() Once, when the game closes

Example

var settings = GameSettings.Instance
    .SetAppCompany("MyStudio")
    .SetAppName("MyGame")
    .SetWindow(1920, 1080)
    .Build();

using var game = new Game(settings);
game.Run();

GameSettings (Fluent Builder)

All engine settings are configured through a fluent builder pattern. You chain methods to set values and call Build() when done.

Common Settings

Setting Method Default
Application Name SetAppName() Required
Company Name SetAppCompany() Required
Window Title SetAppTitle() "Game"
Window Size SetWindow() 1280x720
Internal Resolution SetViewport() 320x180
Fullscreen SetFullScreen() false
VSync SetVsync() true
Fixed Timestep SetFixedTimeStep() true
Target FPS SetTargetFPS() 60
Clear Color SetClearColor() Cornflower Blue
Log Level SetLogMinLevel() Info
Audio Limit SetAudioLimit() 128

Example

var settings = GameSettings.Instance
    .SetAppCompany("MyStudio")
    .SetAppName("MyGame")
    .SetWindow(1920, 1080)
    .SetFullScreen(false)
    .SetClearColor("#3e3f3e")
    .Build();

FrameTime

FrameTime provides timing information for the current frame. It is passed to OnUpdate() and OnDraw().

Properties

Property Description
DeltaTime The time since the last frame (scaled)
UnscaledDeltaTime The time since the last frame (unscaled)
Alpha Interpolation value for smooth rendering (0 to 1)
FPS Current frames per second
TotalTime Total elapsed time since game start
IsFixedTimeStep Whether fixed timestep is enabled
TimeScale Global time multiplier (1 = normal)

Example

protected override void OnUpdate(FrameTime time)
{
    float speed = 100f * time.DeltaTime;
    position.X += speed;
}

protected override void OnDraw(FrameTime time)
{
    float renderX = MathHelper.Lerp(prevX, currentX, time.Alpha);
    // Draw at renderX for smooth movement
}

Application Folders

Void Engine automatically creates and manages these folders for your application:

Folder Purpose Default Path
ApplicationFolder Root application data %APPDATA%/Company/Game or local
ApplicationLogFolder Log files Logs/
ApplicationSaveFolder Save games Saves/
ApplicationConfigFolder Configuration Config/
ApplicationTempFolder Temporary files Temp/

Example

string logPath = Game.Instance.ApplicationLogFolder;
string savePath = Game.Instance.ApplicationSaveFolder;

Coroutine System

Coroutines let you write sequential code that happens over time. Instead of using complex state machines, you write code that looks like it is running in order but can pause and resume.

Basic Usage

IEnumerator MyCoroutine()
{
    // Wait 2 seconds
    yield return new WaitForSeconds(2f);
    
    // Do something
    Console.WriteLine("2 seconds passed!");
    
    // Wait 0.5 seconds
    yield return new WaitForSeconds(0.5f);
    
    // Run another coroutine
    yield return AnotherCoroutine();
}

// Run it
CoroutineManager.Instance.Run(MyCoroutine());

Yield Instructions

Type Description
WaitForSeconds Wait for a number of seconds (scaled)
WaitForSecondsRealtime Wait for a number of seconds (unscaled)
WaitForFrames Wait for a number of frames
WaitForNextFrame Wait for the next frame
WaitUntil Wait until a condition becomes true
WaitWhile Wait while a condition is true

Compositions

Type Description
Sequence Run coroutines one after another
Concurrent Run coroutines at the same time
Repeat Repeat a coroutine
Timeout Wrap a coroutine with a timeout

Tweens (Animations)

Tweens smoothly animate values over time with easing functions.

Example

// Animate from 0 to 100 over 1 second
var tween = new Tween<float>(
    from: 0f,
    to: 100f,
    duration: 1f,
    type: EaseType.QuadOut,
    lerpFunc: (a, b, t) => MathHelper.Lerp(a, b, t),
    onUpdate: value => position.X = value
);

CoroutineManager.Instance.Run(tween);

Tween Types

Tween Description
Tween<T> Basic tween from A to B
CallbackTween<T> Tween with completion callback
DelayedTween<T> Tween with initial delay
LoopTween<T> Tween that repeats
PingPongTween<T> Tween that bounces back and forth
PulseTween<T> Tween that pulses like a heartbeat
SpeedTween<T> Tween with speed multiplier

Easing Functions (33 Types)

Family In Out InOut OutIn
Linear - - -
Quadratic
Cubic
Quartic
Quintic
Sine
Exponential
Circular
Back
Elastic
Bounce

Example with Easing

float eased = Easing.Ease(EaseType.QuadOut, t);

Logging System

The logging system is asynchronous and supports multiple sinks. Logs are processed in the background so they do not block the game loop.

Usage

var logger = Logger.Instance;

// Set minimum log level
logger.SetLevel(LogLevel.Info);

// Add sinks
logger.AddSink(new ConsoleSink());
logger.AddSink(new FileSink("Logs/", 10, 10));

// Log messages
logger.Debug("Debug message");
logger.Info("Game started");
logger.Warning("Low memory warning");
logger.Error("Failed to load texture", exception);
logger.Fatal("Critical error, shutting down");

// Category logging
logger.InfoWithCategory("Network", "Connected to server");

Log Levels

Level Description
Debug Development and troubleshooting
Info Normal application operation
Warning Potentially problematic situations
Error Recoverable failures
Fatal Unrecoverable failures

Log Sinks

Sink Description
ConsoleSink Writes to console with color coding
FileSink Writes to daily rotating text files

Back to Home

Clone this wiki locally