Main menu, ZX Spectrum-like font, Death screen, Fixed typo, Game Manager

This commit is contained in:
Иван Кузьменко 2023-08-18 18:57:25 +03:00
parent 602df1ed1d
commit b0caf99373
24 changed files with 497 additions and 17 deletions

38
scripts/GameManager.cs Normal file
View 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++;
}