static public void PlayGame() { Hud.Score = 0; level = 1; int dropSpeed = 20; isPlaying = true; TetrisBlock activeBlock = new TetrisBlock(); playField = new PlayField(); Engine.ClearScreen(); SetCursorPosition(0, 0); while (isPlaying) { tick++; KeyInputCheck(activeBlock, playField); if (tick % (dropSpeed - level) == 0) { activeBlock.YPos++; tick = 0; } if (playField.CollisionCheck(activeBlock)) { playField.UpdateField(activeBlock); playField.ScoreCheck(); // game over if (playField.CollisionCheck(activeBlock) && isPlaying) { HighScores.CheckHighScore(Hud.Score); isPlaying = false; } } Hud.DrawHud(); playField.DrawPlayField(xOffset, yOffset); activeBlock.DrawBlock(xOffset + activeBlock.XPos, yOffset + activeBlock.YPos); Thread.Sleep(40); } // remove keyboard input glitch Engine.GlitchFix(); }
public static void DrawHud() { Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.Red; Console.SetCursorPosition(0,0); Engine.ClearScreen(); Console.SetCursorPosition(10, 5); Console.WriteLine($"Your score: {Score}"); Console.SetCursorPosition(10, 6); Console.WriteLine($"Your level: {PlayTetris.level}"); Console.SetCursorPosition(53, 5); Console.Write("Next block:"); nextBlock.DrawBlock(55, 8); Console.ResetColor(); }