Esempio n. 1
0
        public static void Update()
        {
            while (true)
            {
                time = (int)timerC.ElapsedMilliseconds;
                if (time > speed)
                {
                    time = 0;
                    timerC.Restart();
                    tetrimino.Solve();
                }
                if (letFall == true)
                {
                    tetrimino     = nextTetrimino;
                    nextTetrimino = new Tetrimino();
                    tetrimino.Appeareance();

                    letFall = false;
                }
                int j;
                for (j = 0; j < 10; j++)
                {
                    if (positionOnGrid[0, j] == 1)
                    {
                        return;
                    }
                }

                Pulse();
                BlockMover();
            }
        }
Esempio n. 2
0
        static void Main()
        {
            GameArea();
            Console.SetCursorPosition(4, 5);
            Console.WriteLine("Press Any Key");
            Console.ReadKey(true);
            SoundPlayer sp = new SoundPlayer();

            sp.SoundLocation = Environment.CurrentDirectory + "\\Tetris.wav";
            sp.PlayLooping();
            timer.Start();
            timerC.Start();
            _ = timer.ElapsedMilliseconds;
            Console.SetCursorPosition(25, 0);
            Console.WriteLine("Level: " + level);
            Console.SetCursorPosition(25, 1);
            Console.WriteLine("Points: " + points);
            Console.SetCursorPosition(25, 2);
            Console.WriteLine("Score: " + lineScore);
            nextTetrimino = new Tetrimino();
            tetrimino     = nextTetrimino;
            tetrimino.Appeareance();
            nextTetrimino = new Tetrimino();

            Update();
            sp.Stop();
            sp.SoundLocation = Environment.CurrentDirectory + "\\Retro-game-over-sound-effect.wav";
            sp.Play();
            Console.SetCursorPosition(0, 0);
            Console.WriteLine("Game Over \n Start New Game? (Y/N)");
            string teclaPulsada = Console.ReadLine();

            if (teclaPulsada.ToUpper() == "Y")
            {
                int[,] area    = new int[23, 10];
                positionOnGrid = new int[23, 10];
                timer          = new Stopwatch();
                timerC         = new Stopwatch();
                timerE         = new Stopwatch();
                speed          = 300;
                letFall        = false;
                keyPulse       = false;
                lineScore      = 0;
                points         = 0;
                level          = 1;
                GC.Collect();
                Console.Clear();
                Main();
            }
            else
            {
                return;
            }
        }