Fixed critical oversight in timer management and implimented global timer system
This commit is contained in:
@@ -6,6 +6,11 @@ public partial class CommonData : Node
|
||||
{
|
||||
public bool Muted = true;
|
||||
|
||||
// Game Information
|
||||
public const float FPS = 90.0f; // Max game fps
|
||||
public float GlobalTimer = 0.0f; // Seconds elapsed since game start
|
||||
int NumFramesElapsed = 0;
|
||||
|
||||
// Level information
|
||||
public string CurrentLevel;
|
||||
|
||||
@@ -38,6 +43,11 @@ public partial class CommonData : Node
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
// Frame Counter
|
||||
NumFramesElapsed += 1;
|
||||
GlobalTimer = NumFramesElapsed / FPS;
|
||||
GlobalTimer = (float)Convert.ToDouble(GlobalTimer.ToString("0.##")); // Truncates seconds elapsed to hundreds place (0.00)
|
||||
|
||||
if (Input.IsActionJustPressed("quit_game"))
|
||||
{
|
||||
GetTree().Quit();
|
||||
|
||||
Reference in New Issue
Block a user