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); } } } }