0.1.0-0-pre.3

This commit is contained in:
2026-09-16 00:46:04 +02:00
parent 8c0252e34e
commit 2c79a05dd6
26 changed files with 589 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/games/game-reflex-poc/src/state.rs
// version: 1
// version: 2
/// Minimal deterministic state used to validate the first game boundary.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
@@ -26,6 +26,15 @@ impl ReflexState {
}
}
impl engine_v1_common::EngineGame for ReflexState {
fn update(&mut self, _frame: engine_v1_common::EngineFrame, input: engine_v1_common::InputState) {
if input.is_active(engine_v1_common::GameAction::Primary) {
self.register_success();
}
return;
}
}
#[cfg(test)]
mod unit_tests {
#[test]
@@ -34,4 +43,16 @@ mod unit_tests {
state.register_success();
assert_eq!(state.score(), 1);
}
#[test]
fn engine_update_maps_primary_action_to_success() {
let mut state = crate::ReflexState::new();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
engine_v1_common::EngineGame::update(
&mut state,
engine_v1_common::EngineFrame::new(0, std::time::Duration::from_millis(16), std::time::Duration::ZERO),
input,
);
assert_eq!(state.score(), 1);
}
}

View File

@@ -1,5 +1,5 @@
// file: crates/games/game-snake-poc/src/state.rs
// version: 1
// version: 2
/// Minimal Snake state used to validate reusable engine dependencies.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -32,6 +32,15 @@ impl SnakeState {
}
}
impl engine_v1_common::EngineGame for SnakeState {
fn update(&mut self, _frame: engine_v1_common::EngineFrame, input: engine_v1_common::InputState) {
if input.is_active(engine_v1_common::GameAction::Primary) {
self.grow();
}
return;
}
}
#[cfg(test)]
mod unit_tests {
#[test]
@@ -40,4 +49,16 @@ mod unit_tests {
state.grow();
assert_eq!(state.length(), 2);
}
#[test]
fn engine_update_maps_primary_action_to_growth() {
let mut state = crate::SnakeState::new();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
engine_v1_common::EngineGame::update(
&mut state,
engine_v1_common::EngineFrame::new(0, std::time::Duration::from_millis(16), std::time::Duration::ZERO),
input,
);
assert_eq!(state.length(), 2);
}
}