예제 #1
0
        private void CmdStart_Click(object sender, System.EventArgs e)
        {
            tmrGameClock.Enabled = true;
            CmdStart.Enabled = false;
            lblScoreValue.Text = "0";

            PicBackground.Invalidate();
            Application.DoEvents();
            GameField.Reset();
            GameField.Redraw();

            CurrentBlock = new Block(new Point(GameField.SquareSize * 6, 50), Block.BlockTypes.Undefined);
            CurrentBlock.Show(PicBackground.Handle);

            NextBlock = new Block(new Point(20, 10), Block.BlockTypes.Undefined);
            NextBlock.Show(PicNextBlock.Handle);
        }
        private void tmrGameClock_Tick(object sender, System.EventArgs e)
        {
            int erasedLines;

            if (stillProcessing) return;
            stillProcessing = true;

            //Manage the falling block
            if (!CurrentBlock.Down()) {
                if (CurrentBlock.Top() == 0) {
                    tmrGameClock.Enabled = false;
                    CmdStart.Enabled = true;
                    MessageBox.Show("GAME OVER", ".NETTrix", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    stillProcessing = false;
                    return;
                }
                //increase score based on # of deleted lines
                erasedLines = GameField.CheckLines();
                if (erasedLines > 0) {
                    score += 100 * erasedLines;
                    lblScoreValue.Text = score.ToString();
                    //Clear the game field and force the window to re-paint
                    PicBackground.Invalidate();
                    Application.DoEvents();
                    GameField.Redraw();
                }

                //Replace the current block...
                CurrentBlock = new Block(new Point(GameField.SquareSize*6,0), NextBlock.BlockType);
                CurrentBlock.Show(PicBackground.Handle);

                //Create the Next block
                NextBlock.Hide(PicNextBlock.Handle);
                NextBlock = new Block(new Point(20,10), Block.BlockTypes.Undefined);
                NextBlock.Show(PicNextBlock.Handle);
            }
            stillProcessing = false;
        }
예제 #3
0
        private void tmrGameClock_Tick(object sender, System.EventArgs e)
        {
            int erasedLines;

            if (stillProcessing) return;
            stillProcessing = true;

            if (!CurrentBlock.Down()) {
                if (CurrentBlock.Top() == 0) {
                    tmrGameClock.Enabled = false;
                    CmdStart.Enabled = true;
                    MessageBox.Show("GAME OVER", ".NETTrix", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    stillProcessing = false;
                    return;
                }
                erasedLines = GameField.CheckLines();
                if (erasedLines > 0) {
                    score += 100 * erasedLines;
                    lblScoreValue.Text = score.ToString();
                    PicBackground.Invalidate();
                    Application.DoEvents();
                    GameField.Redraw();
                }
                CurrentBlock = new Block(new Point(GameField.SquareSize*6,0), NextBlock.BlockType);
                CurrentBlock.Show(PicBackground.Handle);

                NextBlock.Hide(PicNextBlock.Handle);
                NextBlock = new Block(new Point(20,10), Block.BlockTypes.Undefined);
                NextBlock.Show(PicNextBlock.Handle);
            }
            stillProcessing = false;
        }