feat: engine skeleton (Build Order step 1) and siege_tests
Engine: - SdlContext and Window: RAII, throwing constructors, non-movable - FrameClock (real time, clamped dt) and SimClock (fixed 1/60 s steps, speed 0 = planning phase, backlog capped per frame) - Application owns them in lifetime order, exposes EngineContext, and runs the fixed-timestep loop; AppConfig::FromArgs parses --frames, --seed and --fullscreen - Temporary window-surface fill so Wayland maps the window until RenderDevice lands in step 2 Build: - Split into the siege_engine static lib and the siege_deck exe - check_engine_deps fails the build if Engine/ includes Game/ - ctest smoke test: siege_deck --frames 30 on the offscreen driver - siege_tests on Catch2 v3.15.3 (nixpkgs + CPM pin), with SimClock, FrameClock and AppConfig tests Docs: - Decision Log: error handling split, Catch2 for unit tests - Build Order step 1 done; Engine Overview, Main Loop and Time and README updated to match - AGENTS.md with build, conventions and gotchas for coding agents - .gitignore: .mcp.json (local CLion MCP port) and Obsidian's workspace.json (tab/pane state), now untracked Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Created by darman on 9/24/26.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace SiegeDeck::Engine
|
||||
{
|
||||
|
||||
// Real (wall-clock) time between frames. Drives UI, the card hand, menus, the camera
|
||||
// and UI tweens: things that keep moving while the simulation is paused.
|
||||
// Not pausable and not scaled by game speed; see SimClock for that.
|
||||
class FrameClock
|
||||
{
|
||||
public:
|
||||
// A frame longer than this (window drag, breakpoint, loading hitch) counts as this long,
|
||||
// so nothing driven by Dt() jumps across the screen afterwards.
|
||||
static constexpr double kMaxDt = 0.25;
|
||||
|
||||
FrameClock();
|
||||
|
||||
// Call once at the start of every frame. The first call yields Dt() == 0.
|
||||
void Tick();
|
||||
|
||||
// Seconds since the previous Tick(), clamped to kMaxDt.
|
||||
[[nodiscard]] double Dt() const { return dt; }
|
||||
// Sum of all clamped Dt()s: time the game has seen, not wall-clock uptime.
|
||||
[[nodiscard]] double Time() const { return time; }
|
||||
[[nodiscard]] uint64 FrameCount() const { return frameCount; }
|
||||
|
||||
private:
|
||||
uint64 frequency;
|
||||
uint64 lastCounter;
|
||||
|
||||
double dt = 0.0;
|
||||
double time = 0.0;
|
||||
uint64 frameCount = 0;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user