From 519a373fa8c86ae462a626d576b889239b465ce7 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Fri, 1 Mar 2024 18:05:20 +0000 Subject: [PATCH] Remove (most) stuttering from web build when loading stage sound. --- Adventures in Lestoria/AdventuresInLestoria.cpp | 14 ++++++++++++-- Adventures in Lestoria/AdventuresInLestoria.h | 1 + Adventures in Lestoria/LoadingScreen.cpp | 2 +- Adventures in Lestoria/Warrior.cpp | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index ec8e3e47..5f8608bb 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2008,7 +2008,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ LoadingScreen::Reset(); previousLevel=currentLevel; currentLevel=map; - loadingWaitTime=0.f; + game->loadingWaitTime=0.f; #pragma region Reset all data (Loading phase 1) LoadingScreen::AddPhase([&](){ @@ -2029,7 +2029,6 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ DAMAGENUMBER_LIST.clear(); backgroundEffects.clear(); foregroundEffects.clear(); - ZONE_LIST.clear(); ItemDrop::drops.clear(); GameEvent::events.clear(); Audio::SetBGMPitch(1.f); @@ -2064,6 +2063,15 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ return true; }); #pragma endregion + + #ifdef __EMSCRIPTEN__ + LoadingScreen::AddPhase([&](){ + Audio::muted=true; + Audio::UpdateBGMVolume(); + game->loadingWaitTime+=game->GetElapsedTime(); + return game->loadingWaitTime>=0.4f; + }); + #endif #pragma region Monster Spawn Data Setup (Loading phase 2) LoadingScreen::AddPhase([&](){ @@ -2370,6 +2378,8 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ for(int trackID:track.GetChannelIDs()){ audioEngine.Engine().Play(trackID,true); } + Audio::muted=false; + Audio::UpdateBGMVolume(); return true; }); } diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index e03e7565..7e0d3c69 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -174,6 +174,7 @@ private: ResourcePack gamepack; uint8_t mosaicEffectTransition=1U; float saveGameDisplayTime=0.f; + float loadingWaitTime=0.f; void ValidateGameStatus(); void _PrepareLevel(MapName map,MusicChange changeMusic); diff --git a/Adventures in Lestoria/LoadingScreen.cpp b/Adventures in Lestoria/LoadingScreen.cpp index 1b3bae4a..ecb3c4d2 100644 --- a/Adventures in Lestoria/LoadingScreen.cpp +++ b/Adventures in Lestoria/LoadingScreen.cpp @@ -30,7 +30,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Portions of this software are copyright © 2024 The FreeType +Portions of this software are copyright � 2024 The FreeType Project (www.freetype.org). Please see LICENSE_FT.txt for more information. All rights reserved. */ diff --git a/Adventures in Lestoria/Warrior.cpp b/Adventures in Lestoria/Warrior.cpp index fdd1adcd..97ab9254 100644 --- a/Adventures in Lestoria/Warrior.cpp +++ b/Adventures in Lestoria/Warrior.cpp @@ -84,7 +84,7 @@ bool Warrior::AutoAttack(){ attack_cooldown_timer=ATTACK_COOLDOWN-GetAttackRecoveryRateReduction(); swordSwingTimer="Warrior.Auto Attack.SwordSwingTime"_F; - float dirToEnemy=geom2d::float(GetPos(),closest->GetPos()).vector().polar().y; + float dirToEnemy=geom2d::line(GetPos(),closest->GetPos()).vector().polar().y; SetState(State::SWING_SWORD); SetAnimationBasedOnTargetingDirection(dirToEnemy); SoundEffect::PlaySFX("Warrior Auto Attack",SoundEffect::CENTERED);