diff --git a/Adventures in Lestoria/ItemDrop.cpp b/Adventures in Lestoria/ItemDrop.cpp index 19fa15a1..281109dd 100644 --- a/Adventures in Lestoria/ItemDrop.cpp +++ b/Adventures in Lestoria/ItemDrop.cpp @@ -110,7 +110,7 @@ void ItemDrop::UpdateDrops(float fElapsedTime){ if(drop.zSpeed==0&&drop.OnUpperLevel()==game->GetPlayer()->OnUpperLevel()){ geom2d::linelineTo=geom2d::line(drop.pos,game->GetPlayer()->GetPos()); float dist=lineTo.length(); - if(dist<="ItemDrop.Item Drop Suction Range"_F){ + if(dist<="ItemDrop.Item Drop Suction Range"_F&&dist>0){ vf2d pointVel=lineTo.vector().norm(); float moveDistance=(1.f/std::min(48.f,dist))*"ItemDrop.Item Drop Suction Strength"_F*fElapsedTime; if(moveDistance>dist){ diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 6300b0a7..e966efe7 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -208,7 +208,8 @@ bool Monster::_SetX(float x,const bool monsterInvoked){ return true; }else if(monsterInvoked){ //If player invoked, we'll try the smart move system. - vf2d pushDir=geom2d::line(collision.middle(),pos).vector().norm(); + vf2d pushDir{vf2d{1.f,util::random(2*PI)}.cart()}; + if(collision.middle()!=pos)pushDir=geom2d::line(collision.middle(),pos).vector().norm(); newPos={newPos.x,pos.y+pushDir.y*12}; if(NoEnemyCollisionWithTile()){ return _SetY(pos.y+pushDir.y*game->GetElapsedTime()*12,false); @@ -247,7 +248,8 @@ bool Monster::_SetY(float y,const bool monsterInvoked){ return true; }else if(monsterInvoked){ //If player invoked, we'll try the smart move system.{ - vf2d pushDir=geom2d::line(collision.middle(),pos).vector().norm(); + vf2d pushDir{vf2d{1.f,util::random(2*PI)}.cart()}; + if(collision.middle()!=pos)pushDir=geom2d::line(collision.middle(),pos).vector().norm(); newPos={pos.x+pushDir.x*12,newPos.y}; if(NoEnemyCollisionWithTile()){ return _SetX(pos.x+pushDir.x*game->GetElapsedTime()*12,false); diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 7e2ed347..3006249c 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -199,7 +199,8 @@ bool Player::_SetX(float x,MoveFlag::MoveFlag flags,const bool playerInvoked){ return true; }else if(playerInvoked){ //If player invoked, we'll try the smart move system. - vf2d pushDir=geom2d::line(collision.middle(),pos).vector().norm(); + vf2d pushDir=vf2d{1.f,util::random(2*PI)}.cart(); + if(collision.middle()!=pos)pushDir=geom2d::line(collision.middle(),pos).vector().norm(); newPos={newPos.x,pos.y+pushDir.y*12}; if(NoPlayerCollisionWithTile()){ return _SetY(pos.y+pushDir.y*game->GetElapsedTime()*12,flags,false); @@ -232,7 +233,8 @@ bool Player::_SetY(float y,MoveFlag::MoveFlag flags,const bool playerInvoked){ return true; }else if(playerInvoked){ //If player invoked, we'll try the smart move system.{ - vf2d pushDir=geom2d::line(collision.middle(),pos).vector().norm(); + vf2d pushDir=vf2d{1.f,util::random(2*PI)}.cart(); + if(collision.middle()!=pos)geom2d::line(collision.middle(),pos).vector().norm(); newPos={pos.x+pushDir.x*12,newPos.y}; if(NoPlayerCollisionWithTile()){ return _SetX(pos.x+pushDir.x*game->GetElapsedTime()*12,flags,false); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 43d1194c..3f60b679 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 11621 +#define VERSION_BUILD 11633 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcPGEX_MiniAudio.h b/Adventures in Lestoria/olcPGEX_MiniAudio.h index fb1679fa..e06d668e 100644 --- a/Adventures in Lestoria/olcPGEX_MiniAudio.h +++ b/Adventures in Lestoria/olcPGEX_MiniAudio.h @@ -262,14 +262,28 @@ namespace olc { if(sound != nullptr) { + ma_sound_stop(sound); + ma_sound_uninit(sound); + delete sound; + } + } + for(auto sound : vecOneOffSounds) + { + if(sound != nullptr) + { + ma_sound_stop(sound); ma_sound_uninit(sound); delete sound; } } - ma_resource_manager_uninit(&resourceManager); + ma_engine_stop(&engine); + ma_engine_uninit(&engine); - ma_engine_uninit(&engine); + ma_resource_manager_uninit(&resourceManager); + + ma_device_stop(&device); + ma_device_uninit(&device); } bool MiniAudio::OnBeforeUserUpdate(float& fElapsedTime) diff --git a/Adventures in Lestoria/olcUTIL_Geometry2D.h b/Adventures in Lestoria/olcUTIL_Geometry2D.h index d617d159..78204461 100644 --- a/Adventures in Lestoria/olcUTIL_Geometry2D.h +++ b/Adventures in Lestoria/olcUTIL_Geometry2D.h @@ -594,7 +594,7 @@ namespace olc::utils::geom2d // Given a real distance, get point along line inline constexpr olc::v_2d rpoint(const T& distance) const { - if(abs(distance)<0.01f){ + if(start==end){ return start; }else{ return start + vector().norm() * distance; diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 97bb1a6f..9852696a 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ