Ejemplo n.º 1
0
        /// <summary>
        /// Timer 1 that controles game
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void timer1_Tick(object sender, EventArgs e)
        {
            if (moving())
            {
                tetromino.move();
                // move tetromino down
                pictureBox1.Invalidate();
            }
            else
            {
                reachedCeiling();  // check if tetrominos filled the board

                foreach (Point p in tetromino.figureOnBoard)
                {
                    pL.Add(p);
                    Board[p.X / boxSize, p.Y / boxSize] = 1;
                }

                check(); // check line if filled

                if (c > 0)
                {
                    if (c % 10 == 0)
                    {
                        speed = (int)((double)speed * 0.75); // After each 10 cleared row speed up by 25%

                        timer1.Interval = speed;             // speed control
                        c = 0;
                        Level++;                             // increase levels
                        level.Text = "" + Level;             // display level on board
                    }
                }

                randomTetromino(); // generate random tetromino
                pictureBox1.Invalidate();
            }
        }