Skip to content
Snippets Groups Projects
Commit 9f597260 authored by Evy Storozhenko's avatar Evy Storozhenko
Browse files

Merge branch 'denaudio' into 'main'

Adding Music

See merge request smjlstor/bevyjam!17
parents 392d1945 31ca1bc4
No related branches found
No related tags found
1 merge request!17Adding Music
Pipeline #103496 passed
...@@ -7,6 +7,16 @@ Code for the bevy jam 2022 ...@@ -7,6 +7,16 @@ Code for the bevy jam 2022
cargo run --release cargo run --release
``` ```
Copyright:
Song: Desmeon - Back From The Dead NCS Release
\
Music provided by NoCopyrightSounds
\
Free Download/Stream: [link](http://ncs.io/bftd)
\
Watch: [link](http://youtu.be/OFWT4yfPdjo)
## Latest snapshot build ## Latest snapshot build
[download](https://gitlab.fachschaften.org/smjlstor/bevyjam/-/jobs/artifacts/main/raw/bevyjam?job=build) [download](https://gitlab.fachschaften.org/smjlstor/bevyjam/-/jobs/artifacts/main/raw/bevyjam?job=build)
File added
use bevy::prelude::*;
pub struct AudioAssets {
pub theme_handle: Handle<AudioSource>,
}
pub struct AudioPlugin;
impl Plugin for AudioPlugin {
fn build(&self, app: &mut App) {
app.add_startup_system_to_stage(StartupStage::PostStartup, play_theme_system);
}
}
fn play_theme_system(audio: Res<Audio>, audio_assets: Res<AudioAssets>) {
audio.play(audio_assets.theme_handle.as_weak());
}
mod audio;
mod components; mod components;
mod error; mod error;
mod grid; mod grid;
...@@ -7,6 +8,7 @@ mod machine; ...@@ -7,6 +8,7 @@ mod machine;
mod power; mod power;
use crate::{ use crate::{
audio::{AudioAssets, AudioPlugin},
components::GridPos, components::GridPos,
grid::{GridPlugin, GridTextures}, grid::{GridPlugin, GridTextures},
gridcursor::{GridCursorPlugin, GridCursorTexture}, gridcursor::{GridCursorPlugin, GridCursorTexture},
...@@ -67,6 +69,18 @@ impl<'a> TextureAtlasInfo<'a> { ...@@ -67,6 +69,18 @@ impl<'a> TextureAtlasInfo<'a> {
} }
} }
pub const THEME_AUDIO: AudioInfo = AudioInfo::new("theme.ogg");
pub struct AudioInfo<'a> {
pub path: &'a str,
}
impl<'a> AudioInfo<'a> {
pub const fn new(path: &'a str) -> Self {
Self { path }
}
}
pub const RENDER_ORDER: RenderOrder = RenderOrder { pub const RENDER_ORDER: RenderOrder = RenderOrder {
grid: 0.0, grid: 0.0,
machine: 1.0, machine: 1.0,
...@@ -98,6 +112,7 @@ fn main() { ...@@ -98,6 +112,7 @@ fn main() {
.add_plugin(GridCursorPlugin) .add_plugin(GridCursorPlugin)
.add_plugin(LightingPlugin) .add_plugin(LightingPlugin)
.add_plugin(PowerPlugin) .add_plugin(PowerPlugin)
.add_plugin(AudioPlugin)
.run(); .run();
} }
...@@ -131,6 +146,12 @@ fn main_setup_system( ...@@ -131,6 +146,12 @@ fn main_setup_system(
}; };
commands.insert_resource(marker_texture); commands.insert_resource(marker_texture);
// audio assets
let audio_assets = AudioAssets {
theme_handle: asset_server.load("theme.ogg"),
};
commands.insert_resource(audio_assets);
commands commands
.spawn() .spawn()
.insert(LightEmitter { .insert(LightEmitter {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment