diff --git a/Cargo.lock b/Cargo.lock index 34e8cbf..ac84336 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.3", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -1161,7 +1161,7 @@ dependencies = [ "critical-section", "foldhash 0.2.0", "futures-channel", - "getrandom 0.3.3", + "getrandom", "hashbrown 0.16.0", "js-sys", "portable-atomic", @@ -2508,9 +2508,10 @@ dependencies = [ "indoc", "itertools 0.14.0", "lipsum", - "rand 0.8.5", + "rand 0.9.2", "serde", "thiserror 2.0.12", + "toml", "walkdir", ] @@ -2524,17 +2525,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.1+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.3.3" @@ -2545,7 +2535,7 @@ dependencies = [ "js-sys", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasi", "wasm-bindgen", ] @@ -3064,7 +3054,7 @@ version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ - "getrandom 0.3.3", + "getrandom", "libc", ] @@ -4243,8 +4233,6 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "libc", - "rand_chacha 0.3.1", "rand_core 0.6.4", ] @@ -4283,9 +4271,6 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.16", -] [[package]] name = "rand_core" @@ -4293,7 +4278,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom", ] [[package]] @@ -4638,6 +4623,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +dependencies = [ + "serde_core", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -4952,6 +4946,21 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "toml" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime 0.7.3", + "toml_parser", + "toml_writer", + "winnow", +] + [[package]] name = "toml_datetime" version = "0.6.11" @@ -4999,6 +5008,12 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_writer" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" + [[package]] name = "tracing" version = "0.1.41" @@ -5185,7 +5200,7 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" dependencies = [ - "getrandom 0.3.3", + "getrandom", "js-sys", "serde", "wasm-bindgen", @@ -5230,12 +5245,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - [[package]] name = "wasi" version = "0.14.2+wasi-0.2.4" diff --git a/Cargo.toml b/Cargo.toml index 26b4d3b..274f470 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ hide_debug = [] [dependencies] itertools = "*" thiserror = "2.0.12" +toml = "0.9.8" [dependencies.serde] version = "1.0.219" diff --git a/src/bin/tetris/blocks.rs b/src/bin/tetris/blocks.rs new file mode 100644 index 0000000..9eaa88f --- /dev/null +++ b/src/bin/tetris/blocks.rs @@ -0,0 +1,53 @@ +use super::*; + +/// Create tetris game with camera that renders to subset of viewport +/// +/// Focus on a single piece and making it really tight mechanically +/// A single piece with movement, rotation, jump-to-end, line clearing, etc. +/// +/// Once done, make pieces a data input so we can add arbitrary metadata to them +pub struct BlocksPlugin; + +impl Plugin for BlocksPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, init_blocks); + } +} + +/// Shape asset +/// Stores shape data in an asset file, likely toml +#[derive(Asset, TypePath, Debug, Deserialize)] +struct ShapeAsset { + layout: Vec> +} + +#[derive(Default)] +struct ShapeAssetLoader; + +impl AssetLoader for ShapeAssetLoader { + type Asset = ShapeAsset; + type Settings = (); + type Error = (); + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, + ) -> Result { + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await.unwrap_or(()); + let shape_asset = toml::from_slice::(bytes.into()).unwrap_or(()); + Ok(shape_asset) + } + + fn extension(&self) -> &[str] { + &["shape.toml"] + } +} + +/// Initialize camera and block game area +fn init_blocks( + mut commands: Commands, +) { + commands.spawn((Camera2d, Camera::default())); +} diff --git a/src/bin/tetris/debug.rs b/src/bin/tetris/debug.rs new file mode 100644 index 0000000..a787799 --- /dev/null +++ b/src/bin/tetris/debug.rs @@ -0,0 +1,13 @@ +use super::*; + +/// Debug UI for Tetris +/// Some overlap with more general purpose debug tools, +/// but built one-off because of the changse to UI in Bevy 0.17 + +struct DebugPlugin; + +impl Plugin for DebugPlugin { + fn build(&self, app: &mut App) { + app; + } +} diff --git a/src/bin/tetris/fighter.rs b/src/bin/tetris/fighter.rs new file mode 100644 index 0000000..93d092b --- /dev/null +++ b/src/bin/tetris/fighter.rs @@ -0,0 +1,13 @@ +use super::*; + +/// Create figher game that renders to another subset of the viewport +/// +/// Focus on a single fighter class with a single enemy (blob) to start with +/// Once damage both ways is tight, add multiple enemies as assets +pub struct FighterPlugin; + +impl Plugin for FighterPlugin { + fn build(&self, app: &mut App) { + app; + } +} diff --git a/src/bin/tetris/main.rs b/src/bin/tetris/main.rs index 0ee5166..1ad97df 100644 --- a/src/bin/tetris/main.rs +++ b/src/bin/tetris/main.rs @@ -1,26 +1,16 @@ +mod blocks; +mod debug; +mod fighter; + use games::*; +use blocks::*; +use debug::*; +use fighter::*; + fn main() { App::new() - .add_plugins(( - BaseGamePlugin { - title: "Battle Tetris".into(), - name: "battle tetris".into(), - game_type: GameType::Two, - target_resolution: (360, 640).into(), - }, - )) + .add_plugins((DefaultPlugins, BlocksPlugin, FighterPlugin)) .run(); } -// Create tetris game with camera that renders to subset of viewport -// -// Focus on a single piece and making it really tight mechanically -// A single piece with movement, rotation, jump-to-end, line clearing, etc. -// -// Once done, make pieces a data input so we can add arbitrary metadata to them - -// Create figher game that renders to another subset of the viewport -// -// Focus on a single fighter class with a single enemy (blob) to start with -// Once damage both ways is tight, add multiple enemies as assets