/// <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(); }
private void Tetris_Form_KeyDown(object sender, KeyEventArgs e) { //while (!Start) { } //CountForStart(); if (!onPause) { udp.SendGrid(game.GridP1); switch (e.KeyData) { // Для каждой кнопки выполнить движение и обновить // положение фрагмента, где он находится, и следующий 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; } } }
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; } } }