Beispiel #1
0
        private void Down(ref BrickFactory brickFactory, Label Score_label, Label gameOver,
                          Timer timer, Image i, Panel p, Image i_next, Panel p_next)
        {
            if (brickFactory.IsDown())
            {
                brickFactory.Y++;
            }
            else
            {
                if (brickFactory.Y == 0)
                {
                    timer.Stop();
                    gameOver.Visible = true;
                    return;
                }

                for (int y = 0; y < 4; y++)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        if (brickFactory.Brick._Brick[y, x] == 1)
                        {
                            brickFactory.BackGround[brickFactory.Y + y, brickFactory.X + x].N     = brickFactory.Brick._Brick[y, x];
                            brickFactory.BackGround[brickFactory.Y + y, brickFactory.X + x].Color = brickFactory.Brick.Color;
                        }
                    }
                }
                Score_label.Text = brickFactory.CalculateScore().ToString();
                brickFactory.init(1);
                timer.Start();
            }
            Draw(i, i_next, p, p_next, ref brickFactory);
        }
Beispiel #2
0
        /// <summary>
        /// 开始游戏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            for (int y = 0; y < 20; y++)
            {
                for (int x = 0; x < 14; x++)
                {
                    backGround[y, x] = 0;
                }
            }
            timer1.Interval = 1000;
            score           = 0;

            brickFactory = new BrickFactory();
            brickFactory.CreateBrick(this);
            comboBox1.Enabled = false;
            timer1.Start();
            this.Focus();
        }
Beispiel #3
0
        /// <summary>
        /// 开始游戏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            label3.Visible = false;
            label4.Visible = false;

            brickFactory1       = new BrickFactory();
            label_1P_Score.Text = brickFactory1.Score.ToString();
            label_1P_Level.Text = brickFactory1.Level.ToString();
            brickFactory1.init(0);
            brickFactory2       = new BrickFactory();
            label_2P_Score.Text = brickFactory2.Score.ToString();
            label_2P_Level.Text = brickFactory2.Level.ToString();
            brickFactory2.init(0);

            timer1.Interval = Constant.interval;
            timer2.Interval = Constant.interval;
            timer1.Start();
            timer2.Start();
            this.Focus();
        }
Beispiel #4
0
        private void Draw(Image image, Image image_next, Panel panel, Panel panel_next, ref BrickFactory brickFactory)
        {
            Graphics graphics      = Graphics.FromImage(image);
            Graphics graphics_next = Graphics.FromImage(image_next);

            graphics.Clear(this.BackColor);
            graphics_next.Clear(this.BackColor);
            if (brickFactory != null)
            {
                for (int bgy = 0; bgy < 20; bgy++)
                {
                    for (int bgx = 0; bgx < 14; bgx++)
                    {
                        if (brickFactory.BackGround[bgy, bgx].N == 1)
                        {
                            graphics.FillRectangle(new SolidBrush(brickFactory.BackGround[bgy, bgx].Color), bgx * 20, bgy * 20, 20, 20);
                            graphics.DrawRectangle(new Pen(Color.Black), bgx * 20, bgy * 20, 20, 20);
                        }
                    }
                }
                for (int row = 0; row < 4; row++)
                {
                    for (int col = 0; col < 4; col++)
                    {
                        if (brickFactory.Brick._Brick[row, col] == 1)
                        {
                            graphics.FillRectangle(new SolidBrush(brickFactory.Brick.Color), (col + brickFactory.X) * 20, (row + brickFactory.Y) * 20, 20, 20);
                            graphics.DrawRectangle(new Pen(Color.Black), (col + brickFactory.X) * 20, (row + brickFactory.Y) * 20, 20, 20);
                        }
                        if (brickFactory.Next_Brick._Brick[row, col] == 1)
                        {
                            graphics_next.FillRectangle(new SolidBrush(brickFactory.Next_Brick.Color), col * 20, row * 20, 20, 20);
                        }
                    }
                }
            }
            Graphics graphics1 = panel.CreateGraphics();
            Graphics graphics2 = panel_next.CreateGraphics();

            graphics1.DrawImage(image, 0, 0);
            graphics2.DrawImage(image_next, 0, 0);
        }