Пример #1
0
        public bool isPause        = false;        //判断是否暂停游戏,默认不暂停

        private void Btn_start_Click(object sender, EventArgs e)
        {
            myTetris.ConvertorClear();                //清空整个控件
            myTetris.firstPoint = new Point(100, 20); //设置方块的起始位置
            myTetris.LblRow     = lblRow;             //将label3控件加载到Tetris类中
            myTetris.LblScore   = lblScore;           //将label4控件加载到Tetris类中
            timer1.Interval     = 500;                //下移的速度
            timer1.Enabled      = true;               //开始计时
            Random rand = new Random();               //实例化Random

            cakeNO = rand.Next(1, 8);                 //获取随机数
            myTetris.CakeMode(cakeNO);                //设置方块的样式
            myTetris.Protract(panelMain);             //绘制组合方块
            nextGraph();                              //生成下一个方块的样式
            myTetris.PlaceInitialization();           //初始化Random类中的信息
            isBegin        = true;                    //判断是否开始
            isPause        = false;                   //判断是否暂停
            myTetris.timer = timer1;
            Btn_pause.Text = "暂停";
            textBox1.Focus();//获取焦点
        }