Time.Freeze

This commit is contained in:
Matt Thorson 2020-05-07 19:10:54 -07:00
parent e21106ccca
commit d08d48147e
3 changed files with 16 additions and 22 deletions

View File

@ -159,11 +159,16 @@ namespace Strawberry
scene.Started();
}
if (scene != null)
scene.Update();
if (Time.Freeze > 0)
Time.Freeze -= Time.RawDelta;
else
{
if (scene != null)
scene.Update();
Time.PreviousElapsed = Time.Elapsed;
Time.Elapsed += Time.Delta;
Time.PreviousElapsed = Time.Elapsed;
Time.Elapsed += Time.Delta;
}
}
public void Render()

View File

@ -105,23 +105,8 @@ namespace Strawberry
// Time
public float TimeElapsed
{
[Inline]
get
{
return Time.Elapsed - TimeStarted;
}
}
public float PreviousTimeElapsed
{
[Inline]
get
{
return Time.PreviousElapsed - TimeStarted;
}
}
public float TimeElapsed => Time.Elapsed - TimeStarted;
public float PreviousTimeElapsed => Time.PreviousElapsed - TimeStarted;
public bool TimeOnInterval(float interval, float offset = 0)
{

View File

@ -4,7 +4,11 @@ namespace Strawberry
{
static public float Elapsed;
static public float PreviousElapsed;
static public float Delta = 1 / 60f;
static public float Rate = 1f;
static public float Freeze;
static public float RawDelta => (1 / 60f);
static public float Delta => RawDelta * Rate;
static public bool OnInterval(float interval, float offset = 0)
{