XNA突破游戏新水平(不能设计新的砖块模式)

时间:2016-12-02 03:52:12

标签: c# xna

我的突破游戏出了问题。我设计了一个单独的级别并创建了一组基本的块。但我不知道如何设置新的块模式。

以下是loadcontent中的代码部分:

background = new Background(Content.Load<Texture2D>("prisonCell"));
            paddle = new Paddle(Content.Load<Texture2D>("bat"), screenBounds);
            ball = new Ball(Content.Load<Texture2D>("baseball"), screenBounds);
            brickTexture = Content.Load<Texture2D>("brick");
            menuScreen = Content.Load<Texture2D>("menuScreen");
            gameOverScreen = Content.Load<Texture2D>("gameOver");
            gill14 = Content.Load<SpriteFont>("Gill14");

            BuildWall();

            startGame();
        }

        public void BuildWall()
        {
            bricks = new Brick[brickRows * brickColumns];
            Color brickColour = Color.White;

            int brickCount = 0;

            int paddingTopViewport = brickTexture.Height/* * 3*/;


            for (int row = 0; row < brickRows; row++)
            {
                switch (row)
                {
                    case 0:
                        brickColour = Color.Red;
                        brickValue = 5;
                        break;
                    case 1:
                        brickColour = Color.Orange;
                        brickValue = 4;
                        break;
                    case 2:
                        brickColour = Color.Gold;
                        brickValue = 3;
                        break;
                    case 3:
                        brickColour = Color.Yellow;
                        brickValue = 2;
                        break;
                    case 4:
                        brickColour = Color.Green;
                        brickValue = 1;
                        break;
                    case 5:
                        brickColour = Color.Blue;
                        brickValue = 1;
                        break;

                }


                brickValue = 1;

                for (int column = 0; column < brickColumns; column++)
                {
                    bricks[brickCount] = new Brick(brickTexture,
                    new Rectangle(column * brickTexture.Width, 
                    paddingTopViewport + row * brickTexture.Height,
                    brickTexture.Width, brickTexture.Height),
                    brickColour, brickValue);

                    brickCount++;
                }
            }
        }



        private void startGame()
        {
            paddle.SetStartPaddlePosition();

            ball.SetStartBallPosition(paddle.Bounds);
            foreach (Brick brick in bricks)
                brick.IsActive = true;
        }

1 个答案:

答案 0 :(得分:0)

如果您想轻松设计关卡,请在文本文件中使用正确的列数定义布局。使用固定空格字体,并为要支持的每种颜色/纹理使用不同的字符。

然后你可以阅读文本文件并构建墙。它比调试不同的墙壁设计更容易调整。