Ejemplo n.º 1
0
        public Form2(mode MODE)
        {
            color_ = MODE.color();
            InitializeComponent();
            this.NextLabel.Location         = new System.Drawing.Point(MODE.nextLabel_X(), MODE.nextLabel_Y());
            this.label_block_count.Location = new System.Drawing.Point(MODE.label_block_X(), MODE.label_block_Y());
            this.label_score.Location       = new System.Drawing.Point(MODE.label_score_X(), MODE.label_score_Y());
            this.label_level.Location       = new System.Drawing.Point(MODE.label_level_X(), MODE.label_level_Y());


            block_type      = (uint)rander.Next(0, 7) + 1; //亂數決定起始方塊(1-7)
            block_type_pre  = block_type;
            block_type_next = block_type;
            // 產生20*10的labels來作為遊戲區域
            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    grids[i, j]             = new Label();
                    grids[i, j].Width       = 30;
                    grids[i, j].Height      = 30;
                    grids[i, j].BorderStyle = BorderStyle.FixedSingle;
                    grids[i, j].BackColor   = MODE.color();
                    grids[i, j].Left        = MODE.get_grids_Left() + 30 * j; //遊戲畫面的左右位置
                    grids[i, j].Top         = 600 - i * 30;                   //遊戲畫面的上下位置
                    grids[i, j].Visible     = true;
                    this.Controls.Add(grids[i, j]);
                }
            }
            // 產生4*3的labels來作為下一個方塊顯示的區域
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    next[i, j]             = new Label();
                    next[i, j].Width       = 20;
                    next[i, j].Height      = 20;
                    next[i, j].BorderStyle = BorderStyle.FixedSingle;
                    next[i, j].BackColor   = Color.White;
                    next[i, j].Left        = MODE.get_next_Left() + 20 * j;
                    next[i, j].Top         = MODE.get_next_Top() - i * 20;
                    next[i, j].Visible     = true;
                    this.Controls.Add(next[i, j]);
                }
            }
            // 遊戲開始
            init_game();
        }
 public Form2(mode MODE)
 {
     InitializeComponent();
     this.NextLabel.Location = new System.Drawing.Point(MODE.nextLabel_X(), MODE.nextLabel_Y());
     block_type      = (uint)rander.Next(0, 7) + 1;
     block_type_pre  = block_type;
     block_type_next = block_type;
     // generate 20x10 labels for "main" area, dynamically.
     for (int i = 0; i < 20; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             grids[i, j]             = new Label();
             grids[i, j].Width       = 30;
             grids[i, j].Height      = 30;
             grids[i, j].BorderStyle = BorderStyle.FixedSingle;
             grids[i, j].BackColor   = Color.Black;
             grids[i, j].Left        = MODE.get_grids_Left() + 30 * j; //遊戲畫面的左右位置
             grids[i, j].Top         = 600 - i * 30;                   //遊戲畫面的上下位置
             grids[i, j].Visible     = true;
             this.Controls.Add(grids[i, j]);
         }
     }
     // generate 4x3 labels for "next" area, dynamically.
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             next[i, j]             = new Label();
             next[i, j].Width       = 20;
             next[i, j].Height      = 20;
             next[i, j].BorderStyle = BorderStyle.FixedSingle;
             next[i, j].BackColor   = Color.White;
             next[i, j].Left        = MODE.get_next_Left() + 20 * j;
             next[i, j].Top         = MODE.get_next_Top() - i * 20;
             next[i, j].Visible     = true;
             this.Controls.Add(next[i, j]);
         }
     }
     // init variables of the game
     init_game();
 }