diff --git a/CMakeLists.txt b/CMakeLists.txt index c5ad878..96d08e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,3 +13,4 @@ file(GLOB_RECURSE GMTK_SOURCES LIST_DIRECTORIES FALSE "${CMAKE_CURRENT_SOURCE_DI file(GLOB_RECURSE GMTK_HEADERS LIST_DIRECTORIES FALSE "${CMAKE_CURRENT_SOURCE_DIR}/include/*") psemek_add_application(color-fractory ${GMTK_SOURCES} ${GMTK_HEADERS}) +psemek_package_files(color-fractory sounds) diff --git a/sounds/click_high.mp3 b/sounds/click_high.mp3 new file mode 100644 index 0000000..53d9eac Binary files /dev/null and b/sounds/click_high.mp3 differ diff --git a/sounds/click_low.mp3 b/sounds/click_low.mp3 new file mode 100644 index 0000000..f4efb86 Binary files /dev/null and b/sounds/click_low.mp3 differ diff --git a/sounds/error.mp3 b/sounds/error.mp3 new file mode 100644 index 0000000..559008f Binary files /dev/null and b/sounds/error.mp3 differ diff --git a/sounds/gears.mp3 b/sounds/gears.mp3 new file mode 100644 index 0000000..3cf1425 Binary files /dev/null and b/sounds/gears.mp3 differ diff --git a/sounds/key_click.mp3 b/sounds/key_click.mp3 new file mode 100644 index 0000000..4b74b53 Binary files /dev/null and b/sounds/key_click.mp3 differ diff --git a/sounds/machine.mp3 b/sounds/machine.mp3 new file mode 100644 index 0000000..7343fc3 Binary files /dev/null and b/sounds/machine.mp3 differ diff --git a/sounds/pop.mp3 b/sounds/pop.mp3 new file mode 100644 index 0000000..b54d6d7 Binary files /dev/null and b/sounds/pop.mp3 differ diff --git a/source/application.cpp b/source/application.cpp index 5940724..b121981 100644 --- a/source/application.cpp +++ b/source/application.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include +#include #include #include @@ -28,6 +30,7 @@ #include #include #include +#include #include #include @@ -1345,6 +1348,16 @@ namespace gmtk volume_ = audio::volume(mixer_); audio_->output()->stream(audio::compressor(volume_)); + auto sounds_root = util::executable_path().parent_path() / "sounds"; + + click_low_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "click_low.mp3"})); + click_high_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "click_high.mp3"})); + key_click_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "key_click.mp3"})); + gears_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "gears.mp3"})); + machine_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "machine.mp3"})); + pop_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "pop.mp3"})); + error_ = audio::load_mp3(io::read_full(io::file_istream{sounds_root / "error.mp3"})); + context_.windowed(is_windowed_); set_start_menu(); } @@ -1629,7 +1642,10 @@ namespace gmtk if (!map_.world->get(t).contains()) { if (!map_.world->get(t).get().belts_to.empty()) + { s.animate += 1.f; + item_produced_sound(); + } auto i = map_.world->create( item{s.type, p} @@ -1763,8 +1779,23 @@ namespace gmtk } if (crafted) + { t.animate += 1.f; + switch (t.type) + { + case transformer_type::mixer: + mixer_sound(); + break; + case transformer_type::hue_shifter: + shifter_sound(); + break; + case transformer_type::reshaper: + reshaper_sound(); + break; + } + } + if (!crafted && !has_inputs.empty()) { return; @@ -1817,9 +1848,11 @@ namespace gmtk map_.resource_count += 1; l->animate += 1.f; map_.world->destroy(entity); + item_received_sound(); } else { + item_error_sound(); l->animate_error += 1.f; map_.world->destroy(entity); } @@ -1952,6 +1985,7 @@ namespace gmtk map_.world->detach(map_.world->index().get(i.start)); map_.world->destroy(*selected_item_); selected_item_ = std::nullopt; + item_removed_sound(); } { @@ -2389,6 +2423,14 @@ namespace gmtk audio::mixer_ptr mixer_; std::shared_ptr volume_; + audio::track_ptr click_low_; + audio::track_ptr click_high_; + audio::track_ptr key_click_; + audio::track_ptr gears_; + audio::track_ptr machine_; + audio::track_ptr pop_; + audio::track_ptr error_; + bool running_ = true; bool in_start_menu_ = true; @@ -2581,6 +2623,48 @@ namespace gmtk pitch->pitch(0.666f); mixer_->add(audio::volume(pitch, 0.25f)); } + + void item_received_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(click_high_->stream(), 0.25f)); + } + + void item_produced_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(click_low_->stream(), 0.5f)); + } + + void mixer_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(machine_->stream(), 0.125f)); + } + + void shifter_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(gears_->stream(), 0.5f)); + } + + void reshaper_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(key_click_->stream(), 0.25f)); + } + + void item_removed_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(pop_->stream(), 0.5f)); + } + + void item_error_sound() + { + if (in_start_menu_) return; + mixer_->add(audio::volume(error_->stream(), 0.25f)); + } }; }