diff --git a/Cargo.lock b/Cargo.lock index 6ad05cd..0302996 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2753,6 +2753,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" +[[package]] +name = "hound" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" + [[package]] name = "image" version = "0.25.9" @@ -3975,6 +3981,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1" dependencies = [ "cpal", + "hound", "lewton", ] diff --git a/Cargo.toml b/Cargo.toml index bc5f4fe..dc19326 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2024" [dependencies] -bevy = { version = "0.18.0"} +bevy = { version = "0.18.0", features = ["wav"] } diff --git a/assets/music/glorx.wav b/assets/music/glorx.wav new file mode 100644 index 0000000..75f418b Binary files /dev/null and b/assets/music/glorx.wav differ diff --git a/src/card.rs b/src/card.rs index 80bbfc9..3382135 100644 --- a/src/card.rs +++ b/src/card.rs @@ -44,6 +44,13 @@ fn test_card_setup( Card, ChildOf(hand.entity()), )); + + commands.spawn(( + Sprite::from_image(card_image.0.clone()), + Transform::from_xyz(0., 0., 0.), + Card, + ChildOf(hand.entity()), + )); } fn card_arrange( @@ -58,8 +65,8 @@ fn card_arrange( continue; } let size = assets.get(&sprite.image).unwrap().size_f32(); - let left_boundary = -size.x * (cards_amount as f32) / 2.0; - transform.translation.x = left_boundary + size.x * card_id + size.x / 2.0; + let left_boundary = -size.x * (cards_amount as f32) / 2.0 + size.x / 2.0; + transform.translation.x = left_boundary + size.x * card_id; transform.translation.y = size.y / 2.0; card_id += 1.0; diff --git a/src/main.rs b/src/main.rs index 9280543..1185bd1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use bevy::prelude::*; +use bevy::{audio::Volume, prelude::*}; mod card; mod turns; @@ -12,6 +12,7 @@ fn main() { fn setup(asset_server: Res, mut commands: Commands) { let background = asset_server.load::("sprites/field.png"); + let music = asset_server.load("music/glorx.wav"); commands.spawn(Camera2d); @@ -19,4 +20,13 @@ fn setup(asset_server: Res, mut commands: Commands) { Sprite::from_image(background), Transform::from_xyz(0., 0., -100.), )); + + commands.spawn(( + AudioPlayer::new(music), + PlaybackSettings { + volume: Volume::Linear(0.2), + mode: bevy::audio::PlaybackMode::Loop, + ..default() + }, + )); }