0.1.0-0-pre.1
This commit is contained in:
14
crates/engines/engine-v1-common/Cargo.toml
Normal file
14
crates/engines/engine-v1-common/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
# file: crates/engines/engine-v1-common/Cargo.toml
|
||||
# version: 1
|
||||
|
||||
[package]
|
||||
name = "engine-v1-common"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
21
crates/engines/engine-v1-common/src/action.rs
Normal file
21
crates/engines/engine-v1-common/src/action.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
// file: crates/engines/engine-v1-common/src/action.rs
|
||||
// version: 1
|
||||
|
||||
/// Logical game actions independent from physical input devices.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum GameAction {
|
||||
/// Move or select left.
|
||||
Left,
|
||||
/// Move or select right.
|
||||
Right,
|
||||
/// Move or select upward.
|
||||
Up,
|
||||
/// Move or select downward.
|
||||
Down,
|
||||
/// Trigger the primary game action.
|
||||
Primary,
|
||||
/// Trigger the secondary game action.
|
||||
Secondary,
|
||||
/// Pause or resume the game.
|
||||
Pause,
|
||||
}
|
||||
13
crates/engines/engine-v1-common/src/lib.rs
Normal file
13
crates/engines/engine-v1-common/src/lib.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// file: crates/engines/engine-v1-common/src/lib.rs
|
||||
// version: 1
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! Common, platform-independent primitives for engine generation V1.
|
||||
|
||||
mod action;
|
||||
|
||||
/// Re-export of the canonical logical input action used by engine V1 games.
|
||||
pub use self::action::GameAction;
|
||||
14
crates/engines/engine-v1-platform-api/Cargo.toml
Normal file
14
crates/engines/engine-v1-platform-api/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
# file: crates/engines/engine-v1-platform-api/Cargo.toml
|
||||
# version: 1
|
||||
|
||||
[package]
|
||||
name = "engine-v1-platform-api"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
13
crates/engines/engine-v1-platform-api/src/lib.rs
Normal file
13
crates/engines/engine-v1-platform-api/src/lib.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// file: crates/engines/engine-v1-platform-api/src/lib.rs
|
||||
// version: 1
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! Platform service contracts shared by engine generation V1.
|
||||
|
||||
mod service;
|
||||
|
||||
/// Re-export of the minimal platform service capability enumeration.
|
||||
pub use self::service::PlatformCapability;
|
||||
17
crates/engines/engine-v1-platform-api/src/service.rs
Normal file
17
crates/engines/engine-v1-platform-api/src/service.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
// file: crates/engines/engine-v1-platform-api/src/service.rs
|
||||
// version: 1
|
||||
|
||||
/// Platform capabilities that may have different implementations per target.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum PlatformCapability {
|
||||
/// Advertising integration.
|
||||
Advertising,
|
||||
/// In-app billing integration.
|
||||
Billing,
|
||||
/// Native share integration.
|
||||
Sharing,
|
||||
/// Haptic feedback integration.
|
||||
Haptics,
|
||||
/// Online leaderboard integration.
|
||||
Leaderboard,
|
||||
}
|
||||
17
crates/engines/engine-v1-sdl/Cargo.toml
Normal file
17
crates/engines/engine-v1-sdl/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
# file: crates/engines/engine-v1-sdl/Cargo.toml
|
||||
# version: 1
|
||||
|
||||
[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" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
15
crates/engines/engine-v1-sdl/src/lib.rs
Normal file
15
crates/engines/engine-v1-sdl/src/lib.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
// file: crates/engines/engine-v1-sdl/src/lib.rs
|
||||
// version: 1
|
||||
|
||||
#![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.
|
||||
|
||||
mod runtime;
|
||||
|
||||
/// Re-export of the SDL runtime boundary marker.
|
||||
pub use self::runtime::SdlRuntimeBoundary;
|
||||
14
crates/engines/engine-v1-sdl/src/runtime.rs
Normal file
14
crates/engines/engine-v1-sdl/src/runtime.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
// 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;
|
||||
|
||||
impl SdlRuntimeBoundary {
|
||||
/// Returns the engine generation served by this boundary.
|
||||
#[must_use]
|
||||
pub const fn engine_generation() -> u16 {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
19
crates/games/game-reflex-poc/Cargo.toml
Normal file
19
crates/games/game-reflex-poc/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
# file: crates/games/game-reflex-poc/Cargo.toml
|
||||
# version: 1
|
||||
|
||||
[package]
|
||||
name = "game-reflex-poc"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
engine-v1-common = { path = "../../engines/engine-v1-common" }
|
||||
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
|
||||
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
13
crates/games/game-reflex-poc/src/lib.rs
Normal file
13
crates/games/game-reflex-poc/src/lib.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// file: crates/games/game-reflex-poc/src/lib.rs
|
||||
// version: 1
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! Structural POC for a one-button reflex game using engine generation V1.
|
||||
|
||||
mod state;
|
||||
|
||||
/// Re-export of the Reflex POC state.
|
||||
pub use self::state::ReflexState;
|
||||
37
crates/games/game-reflex-poc/src/state.rs
Normal file
37
crates/games/game-reflex-poc/src/state.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
// file: crates/games/game-reflex-poc/src/state.rs
|
||||
// version: 1
|
||||
|
||||
/// Minimal deterministic state used to validate the first game boundary.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub struct ReflexState {
|
||||
score: u64,
|
||||
}
|
||||
|
||||
impl ReflexState {
|
||||
/// Creates a fresh Reflex state.
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
return Self { score: 0 };
|
||||
}
|
||||
|
||||
/// Returns the current score.
|
||||
#[must_use]
|
||||
pub const fn score(self) -> u64 {
|
||||
return self.score;
|
||||
}
|
||||
|
||||
/// Registers one successful reflex action.
|
||||
pub const fn register_success(&mut self) {
|
||||
self.score = self.score.saturating_add(1);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod unit_tests {
|
||||
#[test]
|
||||
fn success_increments_score() {
|
||||
let mut state = crate::ReflexState::new();
|
||||
state.register_success();
|
||||
assert_eq!(state.score(), 1);
|
||||
}
|
||||
}
|
||||
19
crates/games/game-snake-poc/Cargo.toml
Normal file
19
crates/games/game-snake-poc/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
# file: crates/games/game-snake-poc/Cargo.toml
|
||||
# version: 1
|
||||
|
||||
[package]
|
||||
name = "game-snake-poc"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
engine-v1-common = { path = "../../engines/engine-v1-common" }
|
||||
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
|
||||
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
13
crates/games/game-snake-poc/src/lib.rs
Normal file
13
crates/games/game-snake-poc/src/lib.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// file: crates/games/game-snake-poc/src/lib.rs
|
||||
// version: 1
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! Structural POC for a Snake-style game using engine generation V1.
|
||||
|
||||
mod state;
|
||||
|
||||
/// Re-export of the Snake POC state.
|
||||
pub use self::state::SnakeState;
|
||||
43
crates/games/game-snake-poc/src/state.rs
Normal file
43
crates/games/game-snake-poc/src/state.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
// file: crates/games/game-snake-poc/src/state.rs
|
||||
// version: 1
|
||||
|
||||
/// Minimal Snake state used to validate reusable engine dependencies.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct SnakeState {
|
||||
length: u32,
|
||||
}
|
||||
|
||||
impl Default for SnakeState {
|
||||
fn default() -> Self {
|
||||
return Self::new();
|
||||
}
|
||||
}
|
||||
|
||||
impl SnakeState {
|
||||
/// Creates a fresh Snake state.
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
return Self { length: 1 };
|
||||
}
|
||||
|
||||
/// Returns the current snake length.
|
||||
#[must_use]
|
||||
pub const fn length(self) -> u32 {
|
||||
return self.length;
|
||||
}
|
||||
|
||||
/// Registers one consumed growth item.
|
||||
pub const fn grow(&mut self) {
|
||||
self.length = self.length.saturating_add(1);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod unit_tests {
|
||||
#[test]
|
||||
fn growth_increments_length() {
|
||||
let mut state = crate::SnakeState::new();
|
||||
state.grow();
|
||||
assert_eq!(state.length(), 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user