Skip to content

Commit

Permalink
Add music (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
necrashter committed Dec 8, 2023
1 parent 5140fa3 commit 01218db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Binary file added assets/music/ingame.ogg
Binary file not shown.
2 changes: 2 additions & 0 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub struct AudioAssets {
pub upgrade0: Handle<AudioSource>,
#[asset(path = "audio/upgrade1.ogg")]
pub upgrade1: Handle<AudioSource>,
#[asset(path = "music/ingame.ogg")]
pub music: Handle<AudioSource>,
}

impl AudioAssets {
Expand Down
6 changes: 6 additions & 0 deletions src/state/editor_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ mod upgrade_panel;
use bevy::prelude::*;
use bevy::ui::Val::*;
use bevy_asset_loader::prelude::*;
use bevy_kira_audio::prelude::*;
use serde::Deserialize;
use serde::Serialize;

use crate::audio::AudioAssets;
use crate::config::Config;
pub use crate::state::editor_screen::code_panel::spawn_code_panel;
use crate::state::editor_screen::code_panel::spawn_light_code_panel;
Expand Down Expand Up @@ -114,13 +116,17 @@ fn enter_editor_screen(
root: Res<AppRoot>,
config: Res<Config>,
time: Res<Time>,
audio: Res<Audio>,
audio_assets: Res<AudioAssets>,
) {
let config = &config.editor_screen;
commands.insert_resource(ClearColor(config.scene_view_background_color));
commands.insert_resource(EditorScreenStartTime(time.elapsed_seconds_f64()));

let screen = spawn_editor_screen(&mut commands, config.light_theme.clone(), true);
commands.entity(screen).set_parent(root.ui);

audio.play(audio_assets.music.clone()).looped();
}

pub fn spawn_editor_screen(
Expand Down

0 comments on commit 01218db

Please sign in to comment.