コード例 #1
0
ファイル: Form1.cs プロジェクト: stzbilj/Tetris
        private void MoveObject(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Left:
                mObject.MoveToSide(Position.LEFT);
                break;

            case Keys.Right:
                mObject.MoveToSide(Position.RIGHT);
                break;

            case Keys.Q:
                mObject.Rotate(Position.ROTATEL);
                break;

            case Keys.E:
                mObject.Rotate(Position.ROTATER);
                break;

            case Keys.Down:
                this.Down();
                break;

            case Keys.Up:
                if (mObject.goldenPoints > 0 && mObject.MoveUp())
                {
                    mObject.goldenPoints--;
                    goldenPts.Text = "Golden: " + mObject.goldenPoints.ToString();
                }
                break;

            case Keys.R:
                if (mObject.goldenPoints > 0)
                {
                    TetrisObject tetrisObject = new TetrisObject(listOfObjects[GetRandomNumber()]);
                    while (tetrisObject == mObject.Object)
                    {
                        tetrisObject = new TetrisObject(listOfObjects[GetRandomNumber()]);
                    }
                    mObject.Object = tetrisObject;
                    ShowNextObject();
                    mObject.goldenPoints--;
                    goldenPts.Text = "Golden: " + mObject.goldenPoints.ToString();
                }
                break;

            case Keys.P:
                game.Pause();
                break;
            }
        }
コード例 #2
0
ファイル: ParallelGame.cs プロジェクト: stzbilj/Tetris
        private void MoveObject(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.A)
            {
                if (flag)
                {
                    mObjectFocus    = mObject2;
                    flag            = false;
                    labelFocus.Text = "-->";
                }
                else
                {
                    mObjectFocus    = mObject1;
                    flag            = true;
                    labelFocus.Text = "<--";
                }
            }
            switch (e.KeyCode)
            {
            case Keys.Left:
                mObjectFocus.MoveToSide(Position.LEFT);
                break;

            case Keys.Right:
                mObjectFocus.MoveToSide(Position.RIGHT);
                break;

            case Keys.Q:
                mObjectFocus.Rotate(Position.ROTATEL);
                break;

            case Keys.E:
                mObjectFocus.Rotate(Position.ROTATER);
                break;

            case Keys.Down:
                if (flag)
                {
                    this.Down1();
                }
                else
                {
                    this.Down2();
                }
                break;

            case Keys.P:
                game.Pause();
                break;
            }
        }