示例#1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys key = e.KeyCode;

            //Gracz Alpha
            if (key == Keys.W)
            {
                pictureBox1.Refresh();
                game.Rotate();
                Draw();
            }
            if (key == Keys.A)
            {
                pictureBox1.Refresh();
                game.Move(Towards.LEFT);
                Draw();
            }
            if (key == Keys.D)
            {
                pictureBox1.Refresh();
                game.Move(Towards.RIGHT);
                Draw();
            }
            if (key == Keys.S)
            {
                pictureBox1.Refresh();
                game.Move(Towards.DOWN);
                Draw();
            }

            //Gracz Beta
            if (key == Keys.Up)
            {
                pictureBox2.Refresh();
                game2.Rotate();
                Draw();
            }
            if (key == Keys.Left)
            {
                pictureBox2.Refresh();
                game2.Move(Towards.LEFT);
                Draw();
            }
            if (key == Keys.Right)
            {
                pictureBox2.Refresh();
                game2.Move(Towards.RIGHT);
                Draw();
            }
            if (key == Keys.Down)
            {
                pictureBox2.Refresh();
                game2.Move(Towards.DOWN);
                Draw();
            }
        }
示例#2
0
文件: Form1.cs 项目: wertasy/Tetris
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys key = e.KeyCode;

            if (key == Keys.Up)
            {
                pictureBox1.Refresh();
                //game.Move(Towards.UP);
                game.Rotate();
                Draw();
            }
            if (key == Keys.Left)
            {
                pictureBox1.Refresh();
                game.Move(Towards.LETF);
                Draw();
            }
            if (key == Keys.Right)
            {
                pictureBox1.Refresh();
                game.Move(Towards.RIGHT);
                Draw();
            }
            if (key == Keys.Down)
            {
                pictureBox1.Refresh();
                game.Move(Towards.DOWN);
                Draw();
            }
            if (key == Keys.Space)
            {
                game.Rotate();
            }
            if (key == Keys.P)
            {
                game.Pause();
            }
        }
示例#3
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys key = e.KeyCode;

            if (key == Keys.Up)
            {
                pictureBox1.Refresh();
                //game.Move(Towards.UP);
                game.Rotate();
                Draw();
            }
            if (key == Keys.Left)
            {
                pictureBox1.Refresh();
                game.Move(Towards.LETF);
                Draw();
            }
            if (key == Keys.Right)
            {
                pictureBox1.Refresh();
                game.Move(Towards.RIGHT);
                Draw();
            }
            if (key == Keys.Down)
            {
                pictureBox1.Refresh();
                game.Move(Towards.DOWN);
                Draw();
            }
            if (key == Keys.Space)
            {
                game.Rotate();
            }
            if (key == Keys.P)
            {
                game.Pause();
            }

            if (key == Keys.Q)
            {
                if (game.speed2.Enabled == true)
                {
                    game.speed2.Enabled = false;
                }
                else
                {
                    game.speed2.Enabled = true;
                }
            }


            if (key == Keys.N)
            {
                game.speed.Interval += 2;
            }

            if (key == Keys.M)
            {
                if (game.speed.Interval - 5 > 0)
                {
                    game.speed.Interval -= 5;
                }
                else if (game.speed.Interval - 1 > 0)
                {
                    game.speed.Interval -= 1;
                }
            }


            if (key == Keys.X)
            {
                if (ifSuggest == false)
                {
                    fresh.Tick -= new System.EventHandler(fresh_Tick);
                    fresh.Tick += new System.EventHandler(fresh_Tick2);
                    ifSuggest   = true;
                }
                else
                {
                    fresh.Tick -= new System.EventHandler(fresh_Tick2);
                    fresh.Tick += new System.EventHandler(fresh_Tick);
                    ifSuggest   = false;
                }
            }



            //if (key == Keys.Q)
            //{
            //    display1();
            //}
            //label3.Text = game.curBrick.Pos.X.ToString() + "," + game.curBrick.Pos.Y.ToString();
        }