Skip to content

Commit

Permalink
aa
Browse files Browse the repository at this point in the history
  • Loading branch information
rewin123 committed Dec 11, 2023
1 parent d9edc02 commit 51e3656
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dev = [
"bevy/dynamic_linking",
"dep:bevy-inspector-egui"
]
default = ["dev"]

# All of Bevy's default features exept for the audio related ones (bevy_audio, vorbis), since they clash with bevy_kira_audio
# and android_shared_stdcxx, since that is covered in `mobile`
Expand Down
Binary file added assets/audio/torch.ogg
Binary file not shown.
Binary file added bevy_game.rar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/level_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ fn create_level_ui_system(
parent.spawn((
NodeBundle {
style: Style {
width: Val::Percent(80.0),
width: Val::Percent(60.0),
flex_direction: FlexDirection::Column,
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
min_height: Val::Px(150.0),
min_height: Val::Px(80.0),
..default()
},
background_color: BackgroundColor(Color::rgba(0.0, 0.0, 0.0, 0.5)),
Expand Down
2 changes: 1 addition & 1 deletion src/storyteller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn level_timer(
let time = format!("{:02}:{:02}", dur.as_secs() / 60, dur.as_secs() % 60);
let score_text = format!("Score: {:.1}", score.0);

timer.sections[0].value = format!("{}\n{}", time, score_text);
timer.sections[0].value = format!("{} {}", time, score_text);
} else {
timer.sections[0].value = format!("{:02}:{:02}", 0, 0);
next_state.set(GameState::Finish);
Expand Down
45 changes: 43 additions & 2 deletions src/torch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, audio::{PlaybackMode, Volume}};

use crate::{
common_storage::CommonStorage,
Expand All @@ -21,7 +21,48 @@ impl Plugin for TorchPlugin {
.add_systems(Startup, setup_material)
.add_systems(Update, spawn_torch)
.add_event::<IgniteTorch>()
.add_systems(Update, ignite_torch.in_set(GameSet::Playing));
.add_systems(Update, ignite_torch.in_set(GameSet::Playing))
.add_systems(FixedUpdate, torch_audio.in_set(GameSet::Playing));
}
}

#[derive(Component)]
pub struct TorchSound;

fn torch_audio(
mut commands: Commands,
torches : Query<&TorchBase>,
torh_sound : Query<Entity, With<TorchSound>>,
asset_server : Res<AssetServer>
) {
let mut is_lites = false;
for torch in torches.iter() {
if torch.lit {
is_lites = true;
break;
}
}

if is_lites {
if torh_sound.is_empty() {
commands.spawn((
AudioSourceBundle::<AudioSource> {
source : asset_server.load("audio/torch.ogg"),
settings : PlaybackSettings {
mode : PlaybackMode::Loop,
volume : Volume::new_relative(0.5),
..default()
}
},
TorchSound
));
}
} else {
if !torh_sound.is_empty() {
for sound in torh_sound.iter() {
commands.entity(sound).despawn_recursive();
}
}
}
}

Expand Down

0 comments on commit 51e3656

Please sign in to comment.