This commit is contained in:
Rendo 2026-01-24 17:01:47 +05:00
commit dcca424406
5 changed files with 28 additions and 4 deletions

7
Cargo.lock generated
View file

@ -2753,6 +2753,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "hound"
version = "3.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f"
[[package]] [[package]]
name = "image" name = "image"
version = "0.25.9" version = "0.25.9"
@ -3975,6 +3981,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1" checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1"
dependencies = [ dependencies = [
"cpal", "cpal",
"hound",
"lewton", "lewton",
] ]

View file

@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
bevy = { version = "0.18.0"} bevy = { version = "0.18.0", features = ["wav"] }

BIN
assets/music/glorx.wav Normal file

Binary file not shown.

View file

@ -44,6 +44,13 @@ fn test_card_setup(
Card, Card,
ChildOf(hand.entity()), 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( fn card_arrange(
@ -58,8 +65,8 @@ fn card_arrange(
continue; continue;
} }
let size = assets.get(&sprite.image).unwrap().size_f32(); let size = assets.get(&sprite.image).unwrap().size_f32();
let left_boundary = -size.x * (cards_amount as f32) / 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 + size.x / 2.0; transform.translation.x = left_boundary + size.x * card_id;
transform.translation.y = size.y / 2.0; transform.translation.y = size.y / 2.0;
card_id += 1.0; card_id += 1.0;

View file

@ -1,4 +1,4 @@
use bevy::prelude::*; use bevy::{audio::Volume, prelude::*};
mod card; mod card;
mod turns; mod turns;
@ -12,6 +12,7 @@ fn main() {
fn setup(asset_server: Res<AssetServer>, mut commands: Commands) { fn setup(asset_server: Res<AssetServer>, mut commands: Commands) {
let background = asset_server.load::<Image>("sprites/field.png"); let background = asset_server.load::<Image>("sprites/field.png");
let music = asset_server.load("music/glorx.wav");
commands.spawn(Camera2d); commands.spawn(Camera2d);
@ -19,4 +20,13 @@ fn setup(asset_server: Res<AssetServer>, mut commands: Commands) {
Sprite::from_image(background), Sprite::from_image(background),
Transform::from_xyz(0., 0., -100.), Transform::from_xyz(0., 0., -100.),
)); ));
commands.spawn((
AudioPlayer::new(music),
PlaybackSettings {
volume: Volume::Linear(0.2),
mode: bevy::audio::PlaybackMode::Loop,
..default()
},
));
} }