public static void ubah() { while (true) { { waktuturun = (int)dropTimer.ElapsedMilliseconds; if (waktuturun > dropRate) { { dropTimer.Restart(); t.Drop(); } } if (isDropped == true) { { t = new tetris(); t.Spawn(); isDropped = false; } } for (int j = 0; j < 10; j++) { { if (runtuh[0, j] == 1) { return; } } } Input(); ClearBlock(); } } }
static void Main() { bingkai(); Console.CursorVisible = false; Console.SetCursorPosition(2, 5); Console.WriteLine("Tekan untuk Mulai"); Console.ReadKey(); Console.SetCursorPosition(2, 5); for (int i = 0; i < 23; i++) { Console.Write(" "); } Console.SetCursorPosition(25, 0); Console.WriteLine("Score " + score); Console.SetCursorPosition(25, 1); Console.WriteLine("LinesCleared " + linesCleared); Console.SetCursorPosition(25, 2); Console.WriteLine("Level " + level); Console.SetCursorPosition(25, 3); t = new tetris(); dropTimer.Start(); t.Spawn(); ubah(); Console.SetCursorPosition(25, 7); Console.WriteLine("Game Over"); Console.SetCursorPosition(25, 8); Console.WriteLine("mau mengulang ? (Y/N)"); Console.ResetColor(); Console.SetCursorPosition(25, 9); string cmd = Console.ReadLine(); if (cmd == "y" || cmd == "Y") { int[,] grid = new int[23, 10]; runtuh = new int[23, 10]; dropTimer = new Stopwatch(); dropRate = 300; isDropped = false; isKeyPressed = false; linesCleared = 0; score = 0; level = 1; Console.Clear(); Main(); } else { return; } }