static void Main() { SoundPlayer sp = new SoundPlayer(); sp.SoundLocation = Environment.CurrentDirectory + "\\01_Tetris_NES_Music_1.wav"; sp.PlayLooping(); drawBorder(); Console.SetCursorPosition(4, 5); Console.WriteLine("Press any key"); Console.ReadKey(true); sp.Stop(); sp.SoundLocation = Environment.CurrentDirectory + "\\01_Tetris_NES_Music_1.wav"; sp.PlayLooping(); timer.Start(); dropTimer.Start(); long time = timer.ElapsedMilliseconds; Console.SetCursorPosition(25, 0); Console.WriteLine("Level " + level); Console.SetCursorPosition(25, 1); Console.WriteLine("Score " + score); Console.SetCursorPosition(25, 2); Console.WriteLine("LinesCleared " + linesCleared); nexttet = new Tetrominoe(); tet = nexttet; tet.Spawn(); nexttet = new Tetrominoe(); Update(); sp.Stop(); sp.SoundLocation = Environment.CurrentDirectory + "\\08_Tetris_NES_Victory.wav"; sp.Play(); Console.SetCursorPosition(0, 0); Console.WriteLine("Game Over \n Replay? (Y/N)"); string input = Console.ReadLine(); if (input == "y" || input == "Y") { int[,] grid = new int[23, 10]; droppedtetrominoeLocationGrid = new int[23, 10]; timer = new Stopwatch(); dropTimer = new Stopwatch(); inputTimer = new Stopwatch(); dropRate = 300; isDropped = false; isKeyPressed = false; linesCleared = 0; score = 0; level = 1; GC.Collect(); Console.Clear(); Main(); } else { return; } }
private static void Update() { while (true)//Update Loop { dropTime = (int)dropTimer.ElapsedMilliseconds; if (dropTime > dropRate) { dropTime = 0; dropTimer.Restart(); tet.Drop(); } if (isDropped == true) { tet = nexttet; nexttet = new Tetrominoe(); tet.Spawn(); isDropped = false; } int j; for (j = 0; j < 10; j++) { if (droppedtetrominoeLocationGrid[0, j] == 1) { return; } } Input(); ClearBlock(); } //end Update }
static void Main() { SoundPlayer sp = new SoundPlayer(); sp.SoundLocation = Environment.CurrentDirectory + "\\01_-_Tetris_Tengen_-_NES_-_Introduction.wav"; sp.PlayLooping(); Console.CursorVisible = false; drawBorder(); Console.SetCursorPosition(4, 5); Console.WriteLine("Bir Tuşa Basın"); Console.ReadKey(true); sp.Stop(); sp.SoundLocation = Environment.CurrentDirectory + "\\music.wav"; sp.PlayLooping(); timer.Start(); dropTimer.Start(); long time = timer.ElapsedMilliseconds; Console.SetCursorPosition(25, 0); Console.WriteLine("Seviye " + level); Console.SetCursorPosition(25, 1); Console.WriteLine("Puan " + score); Console.SetCursorPosition(25, 2); Console.WriteLine("Satır Silindi " + linesCleared); nexttet = new Tetrominoe(); tet = nexttet; tet.Spawn(); nexttet = new Tetrominoe(); Update(); sp.Stop(); sp.SoundLocation = Environment.CurrentDirectory + "\\08_-_Tetris_Tengen_-_NES_-_Game_Over.wav"; sp.Play(); Console.SetCursorPosition(0, 0); Console.WriteLine("Oyun Bitti \n Yeniden Oyna? (Y/N)"); string input = Console.ReadLine(); if (input == "y" || input == "Y") { int[,] grid = new int[23, 10]; droppedtetrominoeLocationGrid = new int[23, 10]; timer = new Stopwatch(); dropTimer = new Stopwatch(); inputTimer = new Stopwatch(); dropRate = 300; isDropped = false; isKeyPressed = false; linesCleared = 0; score = 0; level = 1; GC.Collect(); Console.Clear(); Main(); } else { return; } }
public static void opneGame() { Console.CursorVisible = false; drawBorder(); Console.SetCursorPosition(4, 5); Console.WriteLine("Press any key"); Console.ReadKey(true); timer.Start(); dropTimer.Start(); long time = timer.ElapsedMilliseconds; Console.SetCursorPosition(25, 0); Console.WriteLine("Level " + level); Console.SetCursorPosition(25, 1); Console.WriteLine("Score " + score); Console.SetCursorPosition(25, 2); Console.WriteLine("LinesCleared " + linesCleared); nexttet = new Tetrominoe(); tet = nexttet; tet.Spawn(); nexttet = new Tetrominoe(); Update(); Console.SetCursorPosition(0, 0); Console.WriteLine("Game Over \n Replay? (Y/N)"); string input = Console.ReadLine(); if (input == "y" || input == "Y") { int[,] grid = new int[HEIGHT_FIELD, WIDTH_FIELD]; droppedtetrominoeLocationGrid = new int[HEIGHT_FIELD, WIDTH_FIELD]; timer = new Stopwatch(); dropTimer = new Stopwatch(); inputTimer = new Stopwatch(); dropRate = 300; isDropped = false; isKeyPressed = false; linesCleared = 0; score = 0; level = 1; GC.Collect(); Console.Clear(); opneGame(); } else { return; } }
static void Main()// adding sound player { SoundPlayer sp = new SoundPlayer(); drawBorder(); Console.SetCursorPosition(4, 5); Console.WriteLine("Press any key"); Console.ReadKey(true); timer.Start(); dropTimer.Start(); long time = timer.ElapsedMilliseconds; Console.SetCursorPosition(25, 0); Console.WriteLine("Level " + level); Console.SetCursorPosition(25, 1); Console.WriteLine("Score " + score); Console.SetCursorPosition(25, 2); Console.WriteLine("LinesCleared " + linesCleared); nexttet = new Tetrominoe(); tet = nexttet; tet.Spawn(); nexttet = new Tetrominoe(); Update(); Console.SetCursorPosition(0, 0); Console.WriteLine("Game Over \n Replay? (Y/N)"); string input = Console.ReadLine(); if (input == "y" || input == "Y") { int[,] grid = new int[23, 10]; droppedtetrominoeLocationGrid = new int[23, 10]; timer = new Stopwatch(); dropTimer = new Stopwatch(); inputTimer = new Stopwatch(); dropRate = 300; isDropped = false; isKeyPressed = false; linesCleared = 0; score = 0; level = 1; GC.Collect(); Console.Clear(); Main(); } return; }
private static void Update() { while (true)//Update Loop { dropTime = (int)dropTimer.ElapsedMilliseconds; if (dropTime > dropRate) { dropTime = 0; dropTimer.Restart(); tet.Drop(); } if (isDropped == true) { tet = nexttet; nexttet = new Tetrominoe(); tet.Spawn(); isDropped = false; } int j; for (j = 0; j < 10; j++) { if (droppedtetrominoeLocationGrid[0, j] == 1) return; } Input(); ClearBlock(); } //end Update }
static void Main() { SoundPlayer sp = new SoundPlayer(); sp.SoundLocation = Environment.CurrentDirectory + "\\01_-_Tetris_Tengen_-_NES_-_Introduction.wav"; sp.PlayLooping(); drawBorder(); Console.SetCursorPosition(4, 5); Console.WriteLine("Press any key"); Console.ReadKey(true); sp.Stop(); sp.SoundLocation = Environment.CurrentDirectory + "\\music.wav"; sp.PlayLooping(); timer.Start(); dropTimer.Start(); long time = timer.ElapsedMilliseconds; Console.SetCursorPosition(25, 0); Console.WriteLine("Level " + level); Console.SetCursorPosition(25, 1); Console.WriteLine("Score " + score); Console.SetCursorPosition(25, 2); Console.WriteLine("LinesCleared " + linesCleared); nexttet = new Tetrominoe(); tet = nexttet; tet.Spawn(); nexttet = new Tetrominoe(); Update(); sp.Stop(); sp.SoundLocation = Environment.CurrentDirectory + "\\08_-_Tetris_Tengen_-_NES_-_Game_Over.wav"; sp.Play(); Console.SetCursorPosition(0, 0); Console.WriteLine("Game Over \n Replay? (Y/N)"); string input = Console.ReadLine(); if (input == "y" || input == "Y") { int[,] grid = new int[23, 10]; droppedtetrominoeLocationGrid = new int[23, 10]; timer = new Stopwatch(); dropTimer = new Stopwatch(); inputTimer = new Stopwatch(); dropRate = 300; isDropped = false; isKeyPressed = false; linesCleared = 0; score = 0; level = 1; GC.Collect(); Console.Clear(); Main(); } else return; }