예제 #1
0
        /// <summary>
        /// Fa scendere di un blocco la figura
        /// </summary>
        private void ScendiGiu()
        {
            if (_gioco.InGioco)
            {
                if (_gioco.FiguraCorrente.Fissata == false)
                {
                    _gioco.MuoviGiu();
                    if (_gioco.FiguraCorrente.Fissata == true)
                    {
                        _tetrisF.Invalidate();
                        _gioco.GeneraFigura();
                    }
                }
            }

            // Aggiorno il livello e il punteggio nella GUI
            _tetrisF.Punteggio.Text = "Punteggio = " + _gioco.Punteggio.ToString();
            _tetrisF.Livello.Text   = "Livello = " + _gioco.Livello.ToString();

            // Aumento la difficolta
            ModificaDifficolta();

            _tetrisF.Invalidate(_fig_corrente);
            _fig_corrente.Y += DIMENSIONE_BLOCCHI;
            _tetrisF.Invalidate(_fig_corrente);
            _tetrisF.Update();
        }
예제 #2
0
        private void Tetris_Form_KeyDown(object sender, KeyEventArgs e)
        {
            if (!onPause)
            {
                switch (e.KeyData)
                {
                // For each button execute the movement and update
                // the position of the piece where it is located and the next one
                case Keys.Up:
                    game.RotatePiece();
                    tView.Invalidate(new Rectangle(game.CurrentPiece.X * blockSize,
                                                   game.CurrentPiece.Y * blockSize,
                                                   game.CurrentPiece.Sprite.Width,
                                                   game.CurrentPiece.Sprite.Height));
                    tView.Invalidate(pieceContainer);
                    tView.Update();
                    break;

                case Keys.Down:
                    MoveDown();
                    break;

                case Keys.Left:
                    game.MoveLeft();
                    tView.Invalidate(pieceContainer);
                    pieceContainer.X -= blockSize;
                    tView.Invalidate(pieceContainer);
                    tView.Update();
                    break;

                case Keys.Right:
                    game.MoveRight();
                    tView.Invalidate(pieceContainer);
                    pieceContainer.X += blockSize;
                    tView.Invalidate(pieceContainer);
                    tView.Update();
                    break;
                }
            }
        }
예제 #3
0
 public void CountForStart()
 {
     for (int i = 3; i > 0; i--)
     {
         tView.TimerLbl.Text = i.ToString();
         Thread.Sleep(500);
         tView.Update();
     }
     tView.TimerLbl.Text = "GO";
     Thread.Sleep(500);
     tView.Update();
     tView.TimerLbl.Text = "";
     StartTimer();
 }