Main menu, ZX Spectrum-like font, Death screen, Fixed typo, Game Manager
This commit is contained in:
parent
602df1ed1d
commit
b0caf99373
24 changed files with 497 additions and 17 deletions
38
scripts/GameManager.cs
Normal file
38
scripts/GameManager.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using Godot;
|
||||
|
||||
public partial class GameManager : Node
|
||||
{
|
||||
public static bool IsPlaying = true;
|
||||
|
||||
public ulong GameStart = 0;
|
||||
public ulong GameEnd = 0;
|
||||
public int Attempts = 0;
|
||||
public Node2D Checkpoint = null;
|
||||
|
||||
[Signal]
|
||||
public delegate void GameOverEventHandler();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (!IsPlaying)
|
||||
{
|
||||
IsPlaying = true;
|
||||
}
|
||||
|
||||
StartGame();
|
||||
}
|
||||
|
||||
public void StartGame() => GameStart = Time.GetTicksMsec();
|
||||
|
||||
public void EndGame()
|
||||
{
|
||||
GameEnd = Time.GetTicksMsec();
|
||||
|
||||
EmitSignal(SignalName.GameOver);
|
||||
}
|
||||
|
||||
public string GetFormattedTimeElapsed() => TimeSpan.FromMilliseconds(GameEnd - GameStart).ToString(@"hh\:mm\:ss.fff");
|
||||
|
||||
public void OnPlayerDied() => Attempts++;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue