0.1.0-0-pre.5

This commit is contained in:
2026-09-16 01:16:56 +02:00
parent e21ab2bc5f
commit 8451d09da0
12 changed files with 248 additions and 125 deletions

View File

@@ -1,21 +1,18 @@
# file: crates/apps/game-reflex-poc-desktop/Cargo.toml
# version: 3
# version: 2
[package]
name = "game-reflex-poc-desktop"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
publish.workspace = true
[dependencies]
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
game-logging-lib = { path = "../../common/game-logging-lib" }
tracing.workspace = true
engine-v1-common = { path = "../../engines/engine-v1-common" }
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
game-reflex-poc = { path = "../../games/game-reflex-poc" }
tracing.workspace = true
[lints]
workspace = true
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"

View File

@@ -1,31 +1,14 @@
// file: crates/apps/game-reflex-poc-desktop/src/main.rs
// version: 3
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
use engine_v1_sdl::SdlRuntime;
use game_reflex_poc::ReflexGame;
//! Desktop development runner for the Reflex POC game library.
//!
//! This binary exercises the platform-independent fixed-step loop. SDL3 windowing and physical input mapping are introduced in the next dedicated delta.
fn main() -> Result<(), String> {
let _guard = game_logging_lib::init_default_tracing("games::runner").map_err(|error| error.to_string())?;
tracing::info!(game = "reflex", "desktop SDL3 runner started");
fn main() {
let _logging_guard = match game_logging_lib::init_console_tracing() {
std::result::Result::Ok(guard) => guard,
std::result::Result::Err(error) => {
eprintln!("failed to initialize tracing: {error}");
return;
},
};
tracing::info!(target: "games::runner", game = "reflex", "desktop POC runner started");
let _monetization = engine_v1_platform_api::MonetizationCapabilities::disabled();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
let mut runner = engine_v1_common::FixedStepRunner::new(std::time::Duration::from_millis(16));
let mut state = game_reflex_poc::ReflexState::new();
for _ in 0..3 {
runner.tick(&mut state, input);
}
tracing::info!(target: "games::runner", game = "reflex", frames = runner.next_frame_index(), "desktop POC runner completed");
println!("Reflex POC desktop runner: score={} frames={}", state.score(), runner.next_frame_index());
return;
let runtime = SdlRuntime::new("Reflex POC", 720, 1280, 16);
let mut game = ReflexGame::default();
return runtime.run(&mut game);
}

View File

@@ -1,21 +1,18 @@
# file: crates/apps/game-snake-poc-desktop/Cargo.toml
# version: 3
# version: 2
[package]
name = "game-snake-poc-desktop"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
publish.workspace = true
[dependencies]
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
game-logging-lib = { path = "../../common/game-logging-lib" }
tracing.workspace = true
engine-v1-common = { path = "../../engines/engine-v1-common" }
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
game-snake-poc = { path = "../../games/game-snake-poc" }
tracing.workspace = true
[lints]
workspace = true
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"

View File

@@ -1,31 +1,14 @@
// file: crates/apps/game-snake-poc-desktop/src/main.rs
// version: 3
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
use engine_v1_sdl::SdlRuntime;
use game_snake_poc::SnakeGame;
//! Desktop development runner for the Snake POC game library.
//!
//! This binary exercises the platform-independent fixed-step loop. SDL3 windowing and physical input mapping are introduced in the next dedicated delta.
fn main() -> Result<(), String> {
let _guard = game_logging_lib::init_default_tracing("games::runner").map_err(|error| error.to_string())?;
tracing::info!(game = "snake", "desktop SDL3 runner started");
fn main() {
let _logging_guard = match game_logging_lib::init_console_tracing() {
std::result::Result::Ok(guard) => guard,
std::result::Result::Err(error) => {
eprintln!("failed to initialize tracing: {error}");
return;
},
};
tracing::info!(target: "games::runner", game = "snake", "desktop POC runner started");
let _monetization = engine_v1_platform_api::MonetizationCapabilities::disabled();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
let mut runner = engine_v1_common::FixedStepRunner::new(std::time::Duration::from_millis(16));
let mut state = game_snake_poc::SnakeState::new();
for _ in 0..3 {
runner.tick(&mut state, input);
}
tracing::info!(target: "games::runner", game = "snake", frames = runner.next_frame_index(), "desktop POC runner completed");
println!("Snake POC desktop runner: length={} frames={}", state.length(), runner.next_frame_index());
return;
let runtime = SdlRuntime::new("Snake POC", 720, 1280, 16);
let mut game = SnakeGame::default();
return runtime.run(&mut game);
}

View File

@@ -1,17 +1,17 @@
# file: crates/engines/engine-v1-sdl/Cargo.toml
# version: 1
# version: 2
[package]
name = "engine-v1-sdl"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
publish.workspace = true
[dependencies]
engine-v1-common = { path = "../engine-v1-common" }
sdl3.workspace = true
tracing.workspace = true
[lints]
workspace = true
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"

View File

@@ -1,15 +1,11 @@
// file: crates/engines/engine-v1-sdl/src/lib.rs
// version: 1
// version: 2
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
//! SDL boundary for engine generation V1.
//!
//! The baseline intentionally contains only the boundary type. The external SDL3 dependency is introduced in the dedicated SDL integration delta.
//! SDL3 integration for engine generation V1.
mod runtime;
/// Re-export of the SDL runtime boundary marker.
pub use self::runtime::SdlRuntimeBoundary;
#[cfg(test)]
mod unit_tests;
pub use crate::runtime::SdlRuntime;

View File

@@ -1,14 +1,84 @@
// file: crates/engines/engine-v1-sdl/src/runtime.rs
// version: 1
/// Marker representing the future SDL3 runtime boundary for engine V1.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct SdlRuntimeBoundary;
use sdl3::event::Event;
use sdl3::keyboard::Keycode;
use sdl3::pixels::Color;
impl SdlRuntimeBoundary {
/// Returns the engine generation served by this boundary.
use engine_v1_common::{Action, EngineGame, FixedStepRunner, InputState};
/// Minimal SDL3 runtime used by Desktop POC runners.
pub struct SdlRuntime {
title: String,
width: u32,
height: u32,
frame_duration_ms: u64,
}
impl SdlRuntime {
/// Creates a minimal SDL3 runtime configuration.
#[must_use]
pub const fn engine_generation() -> u16 {
return 1;
pub fn new(title: impl Into<String>, width: u32, height: u32, frame_duration_ms: u64) -> Self {
return Self {
title: title.into(),
width,
height,
frame_duration_ms,
};
}
/// Runs a game until the user closes the window or presses Escape.
pub fn run<G: EngineGame>(&self, game: &mut G) -> Result<(), String> {
let sdl = sdl3::init().map_err(|error| error.to_string())?;
let video = sdl.video().map_err(|error| error.to_string())?;
let window = video
.window(&self.title, self.width, self.height)
.position_centered()
.build()
.map_err(|error| error.to_string())?;
let mut canvas = window.into_canvas();
let mut events = sdl.event_pump().map_err(|error| error.to_string())?;
let mut runner = FixedStepRunner::new(self.frame_duration_ms);
tracing::info!(
title = %self.title,
width = self.width,
height = self.height,
"SDL3 runtime started"
);
'running: loop {
let mut input = InputState::default();
for event in events.poll_iter() {
match event {
Event::Quit { .. } => {
break 'running;
}
Event::KeyDown {
keycode: Some(Keycode::Escape),
..
} => {
break 'running;
}
Event::KeyDown {
keycode: Some(Keycode::Space),
..
} => {
input.set(Action::Primary, true);
}
_ => {}
}
}
runner.tick(game, &input);
canvas.set_draw_color(Color::RGB(18, 18, 24));
canvas.clear();
canvas.present();
}
tracing::info!("SDL3 runtime stopped");
return Ok(());
}
}

View File

@@ -0,0 +1,5 @@
// file: crates/engines/engine-v1-sdl/src/unit_tests.rs
// version: 1
#[path = "../unit_tests/runtime.rs"]
mod runtime;

View File

@@ -0,0 +1,11 @@
// file: crates/engines/engine-v1-sdl/unit_tests/runtime.rs
// version: 1
//! Unit tests for SDL runtime configuration.
use engine_v1_sdl::SdlRuntime;
#[test]
fn runtime_configuration_constructs() {
let _runtime = SdlRuntime::new("test", 320, 240, 16);
}