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

            // Clean the game field
            GameField.Reset();
            // Update to Pocket PC: we must draw the blank screen, instead of simply
            //   invalidating a picture box image
            GameField.Clear();

            // Create and show the current and next blocks
            CurrentBlock = new Block(new Point(GameField.SquareSize * 6, 50), Block.BlockTypes.Undefined);
            CurrentBlock.Show(GameField.GraphBackground);

            NextBlock = new Block(new Point(20, 10), Block.BlockTypes.Undefined);
            NextBlock.Show(GameField.GraphNextBlock);

            PicBackground.Invalidate();
            PicNextBlock.Invalidate();
        }
コード例 #2
0
 private void tmrGameClock_Tick(object sender, System.EventArgs e)
 {
     if (stillProcessing) return;
     stillProcessing = true;
     //Manage the falling block
     if (!CurrentBlock.Down()) {
         //Update to Pocket PC: Update the score value
         score += 5;
         lblScoreValue.Text = score.ToString();
         if (CurrentBlock.Top() == 0) {
             tmrGameClock.Enabled = false;
             CmdStart.Enabled = true;
             //Update to Pocket PC: Changed box icon
             MessageBox.Show("GAME OVER", "NETTrix", MessageBoxButtons.OK, MessageBoxIcon.Hand,MessageBoxDefaultButton.Button1);
             stillProcessing = false;
             return;
         }
         //increase score based on # of deleted lines
         int erasedLines = GameField.CheckLines();
         if (erasedLines > 0) {
             score += 100 * erasedLines;
             lblScoreValue.Text = score.ToString();
             //Update to Pocket PC: Use Clear/Redraw
             GameField.Clear();
             GameField.Redraw();
         }
         //Replace the current block...
         CurrentBlock = new Block(new Point(GameField.SquareSize*6,0), NextBlock.BlockType);
         CurrentBlock.Show(GameField.GraphBackground);
         //Create the Next block
         NextBlock.Hide(GameField.GraphNextBlock);
         NextBlock = new Block(new Point(20,10), Block.BlockTypes.Undefined);
         NextBlock.Show(GameField.GraphNextBlock);
         PicNextBlock.Invalidate();
     }
     PicBackground.Invalidate();
     stillProcessing = false;
 }