public void RunGame() { // Game loop while (this.gameRunning) { // Process user's input this.controller.ProcessInput(); // Update creature's position and size this.creature.Update(); // Handle collisions collisionHandler.HandleCollisions(this.creature, this.eatables, this.renderer); // Game over if creature is dead (stops the loop) if (this.creature.IsDestroyed) { this.GameOver(); continue; } // Enqueue the creature for rendering this.renderer.EnqueueForRendering(this.creature); // If there is a eatable eated - add new one if (this.eatables.Any(food => food.IsEaten)) { this.AddFood(); } // Remove eaten eatables this.eatables.RemoveAll(food => food.IsEaten); // Enqueue eatables for rendering for (int food = 0; food < this.eatables.Count; food++) { this.renderer.EnqueueForRendering(this.eatables[food]); } // Render all objects this.renderer.RenderAll(); if (this.gameSpeed > 1) { this.gameSpeed -= 0.1M; } StatsCalculator.CalculateLevel(); // Slow down the game loop so it is playable Thread.Sleep((int)this.gameSpeed); } // Sleep on Game over so the user won't accidently close the game screen Thread.Sleep(2000); Console.Write("Press any key to exit"); while (Console.KeyAvailable) { Console.ReadKey(false); } Console.ReadKey(); }