Exemplo n.º 1
0
        /*游戏时钟*/
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!stillRuning)
            {
                return;
            }

            //检测是否还可以下移
            if (!currentBlock.down())
            {
                if (currentBlock.Top() == 0)
                {//如果到顶则游戏结束
                    showMsg("Game Over!");
                    stillRuning = false;
                    timer1.Stop();
                    return;
                }
                //否则计算分数并继续
                int eraseLines = GameField.CheckLines();
                if (eraseLines > 0)
                {
                    score       += GameField.width * eraseLines;
                    t_score.Text = score.ToString();
                    picBackGround.Invalidate();
                    Application.DoEvents();
                    GameField.Redraw();
                }
                if (score > 100)
                {
                    timer1.Interval = (int)speeds.slow;
                    label7.Text     = "Level2";
                }
                if (score > 200)
                {
                    timer1.Interval = (int)speeds.quick;
                    label7.Text     = "Level3";
                }
                if (score > 300)
                {
                    timer1.Interval = (int)speeds.quicker;
                    label7.Text     = "Level4";
                }
                if (score > 400)
                {
                    timer1.Interval = (int)speeds.quickest;
                    label7.Text     = "Level5";
                }
                //产生下一个block
                currentBlock = new Block(startLocation, nextBlock.blockType);
                currentBlock.Draw(GameField.winHandle);
                pic_preView.Refresh();
                nextBlock = new Block(new Point(80, 50), Block.BlockTypes.undefined);
                nextBlock.Draw(pic_preView.Handle);
            }
            currentBlock.down();
        }
Exemplo n.º 2
0
 /*窗口重绘*/
 private void Form1_Activated(object sender, EventArgs e)
 {
     picBackGround.Invalidate();
     Application.DoEvents();
     GameField.Redraw();
 }