Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ render = [
]

[dependencies]
tracing = { version = "0.1.37", features = ["release_max_level_debug"]}
log = { version = "0.4.17", features = ["release_max_level_debug"] }
anyhow = "1.0.58"
async-channel = "1.7.1"
base64 = "0.13.0"
Expand All @@ -37,7 +35,7 @@ bevy_ecs_tilemap = { version = "0.7.0", features = ["atlas"] }
bevy_egui = "0.16.1"
bevy_fluent = "0.4.0"
bevy_ggrs = { git = "https://github.com/zicklag/bevy_ggrs.git", branch = "jumpy" }
bevy_kira_audio = { version = "0.12.0", features = ["mp3"] }
bevy_kira_audio = { version = "0.12.0", features = ["ogg"], default-features = false }
bevy_mod_js_scripting = { git = "https://github.com/zicklag/bevy_mod_js_scripting.git", branch = "jumpy" }
bevy_prototype_lyon = "0.6.0"
bevy_tweening = { version = "0.5", default-features = false }
Expand All @@ -56,6 +54,8 @@ getrandom = { version = "0.2", features = ["js"] }
iyes_loopless = "0.8.0"
jumpy-matchmaker-proto = { path = "crates/matchmaker-proto" }
leafwing-input-manager = { version = "0.6.1", default-features = false }
log = { version = "0.4.17", features = ["release_max_level_debug"] }
mimalloc = { version = "0.1.32", default-features = false }
normalize-path = "0.2.0"
numquant = "0.2.0"
once_cell = "1.13.0"
Expand All @@ -66,9 +66,9 @@ serde = { version = "1.0.137", features = ["derive"] }
serde_yaml = "0.9.2"
sys-locale = "0.2.1"
thiserror = "1.0.31"
unic-langid = "0.9.0"
tracing = { version = "0.1.37", features = ["release_max_level_debug"] }
turborand = { version = "0.8.0", features = ["atomic", "serialize"] }
mimalloc = { version = "0.1.32", default-features = false }
unic-langid = "0.9.0"

[dependencies.bevy]
version = "0.8"
Expand Down Expand Up @@ -97,4 +97,5 @@ lto = true
codegen-units = 1 # Improved rapier physics perf, so it might help other stuff, too

[patch.crates-io]
# Fix for https://github.com/bevyengine/bevy/issues/6790
bevy_hierarchy = { git = "https://github.com/zicklag/bevy.git", branch = "dont-error-on-non-mapped-children-entities" }
12 changes: 12 additions & 0 deletions assets/default.game.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ stable_maps:
- map/levels/level2.map.yaml
- map/levels/level3.map.yaml
- map/levels/level4.map.yaml

experimental_maps:
# - map/levels/lev01.map.json # Renamed to Level 1
- map/levels/lev02.map.json
Expand All @@ -33,6 +34,17 @@ experimental_maps:
- map/levels/zyrafa05.map.json
# - map/levels/zyrafa06.map.json # Renamed to Level 2

playlist:
- music/across_the_pond.ogg
- music/ahoy!.ogg
- music/bait_the_hook.ogg
- music/fish_and_ships.ogg
- music/fish_bowl.ogg
- music/fish_tide.ogg
- music/fishsticks.ogg
- music/krill_or_be_krilled.ogg
- music/whale_theme.ogg

scripts:
- map/scripts/kill_out_of_bounds.ts
- ui/menu-background-zoom.ts
Expand Down
Binary file added assets/music/across_the_pond.ogg
Binary file not shown.
Binary file added assets/music/ahoy!.ogg
Binary file not shown.
Binary file added assets/music/bait_the_hook.ogg
Binary file not shown.
Binary file added assets/music/fish_and_ships.ogg
Binary file not shown.
Binary file added assets/music/fish_bowl.ogg
Binary file not shown.
Binary file added assets/music/fish_tide.ogg
Binary file not shown.
Binary file added assets/music/fishsticks.ogg
Binary file not shown.
Binary file added assets/music/krill_or_be_krilled.ogg
Binary file not shown.
Binary file added assets/music/thanks_for_all_the_fished.ogg
Binary file not shown.
Binary file added assets/music/whale_theme.ogg
Binary file not shown.
7 changes: 7 additions & 0 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ impl AssetLoader for GameMetaLoader {
);
dependencies.push(main_menu_background_path);

// Load the music playlist
for song in &meta.playlist {
let (path, handle) = get_relative_asset(load_context, self_path, song);
dependencies.push(path.clone());
meta.playlist_handles.push(handle.typed());
}

// Load UI border images
let mut load_border_image = |border: &mut BorderImageMeta| {
let (path, handle) = get_relative_asset(load_context, self_path, &border.image);
Expand Down
64 changes: 64 additions & 0 deletions src/audio.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use std::time::Duration;

use bevy_kira_audio::{
AudioApp, AudioChannel, AudioControl, AudioInstance, AudioSource, PlaybackState,
};
use rand::{seq::SliceRandom, thread_rng};

use crate::{metadata::GameMeta, prelude::*};

pub struct AudioPlugin;

impl Plugin for AudioPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(bevy_kira_audio::AudioPlugin)
.init_resource::<CurrentMusic>()
.init_resource::<ShuffledPlaylist>()
.add_audio_channel::<MusicChannel>()
.add_system(music_system.run_if_resource_exists::<GameMeta>());
}
}

pub struct MusicChannel;

#[derive(Clone, Debug, Default)]
pub struct CurrentMusic {
pub instance: Handle<AudioInstance>,
pub idx: usize,
}

#[derive(Deref, DerefMut, Clone, Debug, Default)]
pub struct ShuffledPlaylist(pub Vec<Handle<AudioSource>>);

/// Loops through all the game music as the game is on.
fn music_system(
game: Res<GameMeta>,
mut playlist: ResMut<ShuffledPlaylist>,
mut current_music: ResMut<CurrentMusic>,
audio_instances: Res<Assets<AudioInstance>>,
music: Res<AudioChannel<MusicChannel>>,
) {
if playlist.is_empty() {
let mut songs = game.playlist_handles.clone();
songs.shuffle(&mut thread_rng());
**playlist = songs;
}

if let Some(instance) = audio_instances.get(&current_music.instance) {
if let PlaybackState::Stopped = instance.state() {
current_music.idx += 1;
current_music.idx %= playlist.len();

current_music.instance = music
.play(playlist[current_music.idx].clone())
.linear_fade_in(Duration::from_secs_f32(0.5))
.handle();
}
} else if let Some(song) = playlist.get(0) {
current_music.instance = music
.play(song.clone())
.linear_fade_in(Duration::from_secs_f32(0.5))
.handle();
current_music.idx = 0;
}
}
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static GLOBAL: MiMalloc = MiMalloc;

pub mod animation;
pub mod assets;
pub mod audio;
pub mod camera;
pub mod config;
pub mod damage;
Expand Down Expand Up @@ -55,6 +56,7 @@ pub mod workarounds;
use crate::{
animation::AnimationPlugin,
assets::AssetPlugin,
audio::AudioPlugin,
camera::CameraPlugin,
damage::DamagePlugin,
debug::DebugPlugin,
Expand Down Expand Up @@ -211,6 +213,7 @@ pub fn main() {
.add_plugin(UiPlugin);

app.add_plugin(bevy_tweening::TweeningPlugin)
.add_plugin(AudioPlugin)
.add_plugin(UtilsPlugin)
.add_plugin(MetadataPlugin)
.add_plugin(PlatformPlugin)
Expand Down
4 changes: 4 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::prelude::*;

use bevy::{reflect::TypeUuid, utils::HashMap};
use bevy_has_load_progress::HasLoadProgress;
use bevy_kira_audio::AudioSource;
use bevy_mod_js_scripting::JsScript;

mod localization;
Expand Down Expand Up @@ -47,6 +48,9 @@ pub struct GameMeta {
pub main_menu: MainMenuMeta,
pub default_settings: settings::Settings,
pub physics: PhysicsMeta,
pub playlist: Vec<String>,
#[serde(skip)]
pub playlist_handles: Vec<Handle<AudioSource>>,

/// Scripts that run on both the server and the client
#[serde(default)]
Expand Down