fix screen shake stacking and not resetting, fixes #1

item-info
John Montagu, the 4th Earl of Sandvich 2022-11-25 13:56:38 -08:00
parent 983dfba589
commit ce5789681c
1 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,10 @@ namespace SupaLidlGame.Utils
_timeLeft -= delta; _timeLeft -= delta;
Offset = RandomOffset(_intensity); Offset = RandomOffset(_intensity);
} }
else
{
Offset = Vector2.Zero;
}
if (_intensity > 0) if (_intensity > 0)
{ {
@ -30,8 +34,8 @@ namespace SupaLidlGame.Utils
public void Shake(float intensity, double time) public void Shake(float intensity, double time)
{ {
_intensity += intensity; _intensity = Mathf.Max(_intensity, intensity);
_timeLeft += time; _timeLeft = Math.Max(_timeLeft, time);
} }
private Vector2 RandomOffset(float intensity) private Vector2 RandomOffset(float intensity)