Beispiel #1
0
        private void frmTetris_KeyUp(object sender, KeyEventArgs e)
        {
            if (!pause)
            {
                switch (e.KeyCode)
                {
                case Keys.Up:
                    game.Rotate();
                    break;

                case Keys.Down:
                    game.MoveDown();
                    break;

                case Keys.Left:
                    game.MoveLeft();
                    break;

                case Keys.Right:
                    game.MoveRight();
                    break;

                case Keys.Space:
                    game.PlaceDown();
                    break;

                case Keys.R:
                    if (gameIsOver)
                    {
                        game = new Game();
                        game.addObserver(this);
                        gameIsOver = false;
                        RefreshPictureBoxes();
                        tmrMove.Enabled = true;
                    }
                    break;

                case Keys.C:
                    game.SwitchBank();
                    break;
                }
            }
            if (e.KeyCode == Keys.P)
            {
                pause           = !pause;
                tmrMove.Enabled = !pause;
                //code for a menu
            }
        }