diff --git a/Cargo.lock b/Cargo.lock index 91c7935..dfa6872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1074,6 +1074,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "bevy_prototype_lyon" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb09bb9cadacae3238d1bdc856b71a164a17f93e1e94db62011dd969dacbe75b" +dependencies = [ + "bevy", + "lyon_algorithms", + "lyon_tessellation", + "svgtypes", +] + [[package]] name = "bevy_ptr" version = "0.17.3" @@ -1310,7 +1322,10 @@ name = "bevy_stock_photo" version = "0.1.0" dependencies = [ "bevy", + "bevy_prototype_lyon", + "enumset", "rand", + "serde", ] [[package]] @@ -2013,6 +2028,40 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "dasp_sample" version = "0.11.0" @@ -2146,6 +2195,27 @@ dependencies = [ "syn", ] +[[package]] +name = "enumset" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b07a8dfbbbfc0064c0a6bdf9edcf966de6b1c33ce344bdeca3b41615452634" +dependencies = [ + "enumset_derive", +] + +[[package]] +name = "enumset_derive" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43e744e4ea338060faee68ed933e46e722fb7f3617e722a5772d7e856d8b3ce" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -2240,6 +2310,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "float_next_after" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" + [[package]] name = "fnv" version = "1.0.7" @@ -2637,6 +2713,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "image" version = "0.25.9" @@ -2799,6 +2881,17 @@ dependencies = [ "bitflags 2.10.0", ] +[[package]] +name = "kurbo" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62" +dependencies = [ + "arrayvec", + "euclid", + "smallvec", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -2892,6 +2985,48 @@ version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +[[package]] +name = "lyon_algorithms" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c0829e28c4f336396f250d850c3987e16ce6db057ffe047ce0dd54aab6b647" +dependencies = [ + "lyon_path", + "num-traits", +] + +[[package]] +name = "lyon_geom" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e260b6de923e6e47adfedf6243013a7a874684165a6a277594ee3906021b2343" +dependencies = [ + "arrayvec", + "euclid", + "num-traits", +] + +[[package]] +name = "lyon_path" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aeca86bcfd632a15984ba029b539ffb811e0a70bf55e814ef8b0f54f506fdeb" +dependencies = [ + "lyon_geom", + "num-traits", +] + +[[package]] +name = "lyon_tessellation" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f586142e1280335b1bc89539f7c97dd80f08fc43e9ab1b74ef0a42b04aa353" +dependencies = [ + "float_next_after", + "lyon_path", + "num-traits", +] + [[package]] name = "mach2" version = "0.4.3" @@ -4058,6 +4193,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "skrifa" version = "0.37.0" @@ -4174,6 +4315,16 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0193cc4331cfd2f3d2011ef287590868599a2f33c3e69bc22c1a3d3acf9e02fb" +[[package]] +name = "svgtypes" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" +dependencies = [ + "kurbo", + "siphasher", +] + [[package]] name = "swash" version = "0.2.6" diff --git a/Cargo.toml b/Cargo.toml index e7c936b..d24b3d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,7 @@ edition = "2024" [dependencies] bevy = "0.17.3" +bevy_prototype_lyon = "0.15.0" +enumset = "1.1.10" rand = "0.9.2" +serde = { version = "1.0.228", features = ["derive"] } diff --git a/assets/fonts/GloriaHalleluja.ttf b/assets/fonts/GloriaHalleluja.ttf new file mode 100644 index 0000000..82d3874 Binary files /dev/null and b/assets/fonts/GloriaHalleluja.ttf differ diff --git a/src/gameplay/mod.rs b/src/gameplay/mod.rs new file mode 100644 index 0000000..b6b3a32 --- /dev/null +++ b/src/gameplay/mod.rs @@ -0,0 +1,2 @@ +pub mod navi; +pub mod pause; diff --git a/src/gameplay/navi.rs b/src/gameplay/navi.rs new file mode 100644 index 0000000..93ccb24 --- /dev/null +++ b/src/gameplay/navi.rs @@ -0,0 +1,135 @@ +use bevy::{ + camera::visibility::RenderLayers, post_process::bloom::Bloom, prelude::*, sprite::Anchor, +}; +use rand::Rng; + +use crate::{ + GameState, PauseState, + utils::input::{GameInputPlugin, InputButton, InputPressStatus}, +}; + +const PLAYER_SPEED: f32 = 100.; + +pub struct NaviGameplayPlugin; + +impl Plugin for NaviGameplayPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, (setup_scene, spawn_bus, spawn_enemy)) + .add_systems( + Update, + ( + move_player + .run_if(in_state(GameState::Navi).and(in_state(PauseState::Running))), + follow_player, + ), + ); + } +} +#[derive(Component)] +pub struct PlayerVWBus; + +#[derive(Component)] +#[require(Camera2d)] +struct MainCamera; + +pub fn setup_scene( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + commands.spawn(( + Mesh2d(meshes.add(Rectangle::new(1000., 70.))), + MeshMaterial2d(materials.add(Color::srgb(0.2, 0.2, 0.3))), + )); + + commands.spawn(( + MainCamera, + Camera { + order: 1, + // clear_color: ClearColorConfig::None, + ..default() + }, + Bloom::NATURAL, + RenderLayers::layer(0), + )); +} + +pub fn spawn_bus(mut commands: Commands, asset_server: Res) { + let texture = asset_server.load("bus/basicbus.png"); + commands.spawn(( + PlayerVWBus, + Sprite { + image: texture, + custom_size: Some(Vec2::new(192., 133.)), + ..default() + }, + Transform::from_xyz(2., 0., 3.), + Anchor::CENTER, + )); +} + +pub fn spawn_enemy( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + let mut rng = rand::rng(); + for _ in 0..10 { + commands.spawn(( + Mesh2d(meshes.add(Circle::new(10.))), + MeshMaterial2d(materials.add(Color::srgb(1.1, 0.2, 0.3))), + Transform::from_xyz( + rng.random_range(-600..600) as f32, + rng.random_range(-600..600) as f32, + 1., + ), + )); + } +} + +pub fn move_player( + mut player: Single<&mut Transform, With>, + mut player_sprite: Single<&mut Sprite, With>, + time: Res