Projektdateien hinzufügen.

This commit is contained in:
Jan Grießhaber
2024-10-24 03:03:13 +02:00
parent ce2ab565e2
commit 73c8cbca39
8 changed files with 774 additions and 0 deletions

77
GameOfLife/Program.cs Normal file
View File

@@ -0,0 +1,77 @@
using GameOfLife;
using System.ComponentModel.Design;
using System.Diagnostics;
public class Program
{
public async static Task Main()
{
Console.WriteLine("Hello");
Game game = new(80, 80);
game.SetRandomStart(80, 80);
//game.GeneraterSwitcher();
Console.Write(game.RenderToDebugString());
Console.WriteLine();
Console.Write(game.RenderToSwapDebugString());
//Console.ReadKey();
int fpsct = 0;
int CurrentFPS = 0;
Stopwatch Start = new();
Start.Start();
PeriodicTimer timer = new(TimeSpan.FromMilliseconds(10));
Console.ForegroundColor = ConsoleColor.DarkGreen;
while (await timer.WaitForNextTickAsync())
{
if (Start.ElapsedMilliseconds > 1000)
{
CurrentFPS = fpsct;
fpsct = 0;
Start.Restart();
}
fpsct++;
game.Update();
Console.Clear();
Console.WriteLine($"FPS: {CurrentFPS}\t Iteration: {game.Iteration}");
Console.Write(game.RenderToString());
if (Console.KeyAvailable)
{
if (Console.ReadKey(true).Key == ConsoleKey.R)
{
game = new(80, 80);
game.SetRandomStart(80, 80);
}
}
//Console.Write(game.RenderToDebugString());
//Console.WriteLine();
//Console.Write(game.RenderToSwapDebugString());
}
}
public static void ColoredWrite(string input)
{
foreach (var ch in input)
{
if (ch == '1')
{
Console.ForegroundColor = ConsoleColor.Black;
Console.Write(ch);
continue;
}
else
{
Console.Write(ch);
}
}
}
}