Engine
lynx::Engine coordinates execution. It owns the current level, the object factory, and the game state. The host application provides the delta through ProgressOneFrame(float dt).
Engine* engine = lynx::GetEngine();
engine->StartGame();
engine->ProgressOneFrame(dt);
engine->EndGame();
The window and GLFW belong to the host application; the engine only keeps an opaque handle.
Level
A Level owns the active Actors. SpawnActor() creates an Actor from its class name; DestroyActor() removes it. When an operation happens during an iteration, it can be queued and applied safely afterward.
GetActorFromID(): find an actor by identifier.GetActors(): iterate over actors in the level.CountActorsOfClass(): count a class.SaveToFile(): save the level.
Actor
An Actor is an Object associated with a Lynx ECS entity. It exposes a transform and scripts and can receive components through AddComponent<T>().
struct Health : lynx::Component {
float hp = 100.f;
void Tick(float dt) override {
if (hp <= 0)
lynx::GetEngine()->GetCurrentLevel()
->DestroyActor(GetOwner());
}
};
actor->AddComponent<Health>();
Components and ECS
Each component type is identified automatically by a stable hash of its type name. The internal registry is based on EnTT. An Actor can have at most one component of a given type.
| Stage | When? |
|---|
| OnAttach() | Immediately after the component is added. |
| BeginPlay() | When the game starts, or on the next tick if added during gameplay. |
| Update(dt) | Every frame, even outside gameplay. |
| Tick(dt) | Every game tick when tick_enabled is active. |
| EndPlay() | Game stop, removal, or destruction. |
| ~Component() | Final destruction. |
Factory and game modules
The engine maintains a global factory of Object constructors. A game module can register its classes with LYNX_MODULE_REGISTER and synchronize the factory while a DLL is loaded or unloaded.
LYNX_LINK_MODULE(
LYNX_MODULE_REGISTER(MyPlayer);
LYNX_MODULE_REGISTER(MyEnemy);
);
Integrated systems
Animation
animation, blend_space, and anim_manager handle playback, frame events, parameters, triggers, and transitions.
Audio
AudioSource can play sounds, attach to Actors, and use volume, pitch, looping, and spatialization.
Voxel
Voxel types come from voxels.json. Flags are used for collision and gameplay rules.
A game frame
HOSTprovides dt
ENGINEadvances one frame
LEVELupdates Actors
ECSupdates component systems
SCRIPTSBeginPlay then Update(dt)
DEFERREDspawns and destruction are finalized