-
Notifications
You must be signed in to change notification settings - Fork 1
Core Systems
The core systems are the foundation of Void Engine. They are the essential building blocks that every game needs.
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.
| 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 |
var settings = GameSettings.Instance
.SetAppCompany("MyStudio")
.SetAppName("MyGame")
.SetWindow(1920, 1080)
.Build();
using var game = new Game(settings);
game.Run();All engine settings are configured through a fluent builder pattern. You chain methods to set values and call Build() when done.
| 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 |
var settings = GameSettings.Instance
.SetAppCompany("MyStudio")
.SetAppName("MyGame")
.SetWindow(1920, 1080)
.SetFullScreen(false)
.SetClearColor("#3e3f3e")
.Build();FrameTime provides timing information for the current frame. It is passed to OnUpdate() and OnDraw().
| 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) |
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
}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/ |
string logPath = Game.Instance.ApplicationLogFolder;
string savePath = Game.Instance.ApplicationSaveFolder;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.
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());| 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 |
| 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 smoothly animate values over time with easing functions.
// 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 | 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 |
| Family | In | Out | InOut | OutIn |
|---|---|---|---|---|
| Linear | ✓ | - | - | - |
| Quadratic | ✓ | ✓ | ✓ | ✓ |
| Cubic | ✓ | ✓ | ✓ | ✓ |
| Quartic | ✓ | ✓ | ✓ | ✓ |
| Quintic | ✓ | ✓ | ✓ | ✓ |
| Sine | ✓ | ✓ | ✓ | ✓ |
| Exponential | ✓ | ✓ | ✓ | ✓ |
| Circular | ✓ | ✓ | ✓ | ✓ |
| Back | ✓ | ✓ | ✓ | ✓ |
| Elastic | ✓ | ✓ | ✓ | ✓ |
| Bounce | ✓ | ✓ | ✓ | ✓ |
float eased = Easing.Ease(EaseType.QuadOut, t);The logging system is asynchronous and supports multiple sinks. Logs are processed in the background so they do not block the game loop.
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");| Level | Description |
|---|---|
Debug |
Development and troubleshooting |
Info |
Normal application operation |
Warning |
Potentially problematic situations |
Error |
Recoverable failures |
Fatal |
Unrecoverable failures |
| Sink | Description |
|---|---|
ConsoleSink |
Writes to console with color coding |
FileSink |
Writes to daily rotating text files |