Exemple #1
0
        private void button1_Click(object sender, EventArgs e)                                      // new game button
        {
            System.Drawing.Image img = System.Drawing.Image.FromFile(startupPath + fieldImagePath); // to determine dimensions
            fieldWidth = img.Width;

            if (gameOver) // clean-up
            {
                for (int x = 0; x < game.getMapWidth(); x++)
                {
                    for (int y = 0; y < game.getMapHeight(); y++)
                    {
                        this.Controls.Remove(imageMap[x, y]);
                    }
                }
            }


            int bombs = 0;
            int X     = 0;
            int Y     = 0;

            if (levelChosen == 0)
            {
                bombs = 10;
                X     = 10;
                Y     = 8;
            }
            else if (levelChosen == 1)
            {
                bombs = 30;
                X     = 12;
                Y     = 10;
            }
            else if (levelChosen == 2)
            {
                bombs = 70;
                X     = 20;
                Y     = 15;
            }

            game = new Game(bombs, X, Y, this);

            this.SetBounds(this.Left, this.Top, X * fieldWidth + 2 * margin, Y * fieldWidth + 2 * margin + 30);

            imageMap = new Square[game.getMapWidth(), game.getMapHeight()];

            b_newgame.Visible = false;
            b_easy.Visible    = false;
            b_medium.Visible  = false;
            b_hard.Visible    = false;
            l_level.Visible   = false;

            printMap();
            gameOver = false;
        }