Пример #1
0
        private SpriteBatch spriteBatch;  //allows us to write on backbuffer when we need to draw self

        public Paddle(float x, float y, float screenWidth, SpriteBatch spriteBatch, GameContent gameContent)
        {
            X                = x;
            Y                = y;
            imgPaddle        = gameContent.imgPaddle;
            Width            = imgPaddle.Width;
            Height           = imgPaddle.Height;
            this.spriteBatch = spriteBatch;
            ScreenWidth      = screenWidth;
        }
Пример #2
0
        private SpriteBatch spriteBatch;  //allows us to write on backbuffer when we need to draw self

        public Brick(float x, float y, Color color, SpriteBatch spriteBatch, GameContent gameContent)
        {
            X                = x;
            Y                = y;
            imgBrick         = gameContent.imgBrick;
            Width            = imgBrick.Width;
            Height           = imgBrick.Height;
            this.spriteBatch = spriteBatch;
            Visible          = true;
            this.color       = color;
        }
Пример #3
0
        public Wall(float x, float y, SpriteBatch spriteBatch, GameContent gameContent)
        {
            BrickWall = new Brick[7, 10];
            float brickX = x;
            float brickY = y;
            Color color  = Color.White;

            for (int i = 0; i < 7; i++)
            {
                switch (i)
                {
                case 0:
                    color = Color.Red;
                    break;

                case 1:
                    color = Color.Orange;
                    break;

                case 2:
                    color = Color.Yellow;
                    break;

                case 3:
                    color = Color.Green;
                    break;

                case 4:
                    color = Color.Blue;
                    break;

                case 5:
                    color = Color.Indigo;
                    break;

                case 6:
                    color = Color.Violet;
                    break;
                }
                brickY = y + i * (gameContent.imgBrick.Height + 1);

                for (int j = 0; j < 10; j++)
                {
                    brickX = x + j * (gameContent.imgBrick.Width);
                    Brick brick = new Brick(brickX, brickY, color, spriteBatch, gameContent);
                    BrickWall[i, j] = brick;
                }
            }
        }
Пример #4
0
 public Ball(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameContent gameContent)
 {
     X                = 0;
     Y                = 0;
     XVelocity        = 0;
     YVelocity        = 0;
     Rotation         = 0;
     imgBall          = gameContent.imgBall;
     Width            = imgBall.Width;
     Height           = imgBall.Height;
     this.spriteBatch = spriteBatch;
     this.gameContent = gameContent;
     ScreenWidth      = screenWidth;
     ScreenHeight     = screenHeight;
     Visible          = false;
     Score            = 0;
     bricksCleared    = 0;
     UseRotation      = true;
 }
Пример #5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // TODO: use this.Content to load your game content here
            gameContent = new GameContent(Content);

            screenWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            //set game to 502x700 or screen max if smaller
            if (screenWidth >= 502)
            {
                screenWidth = 502;
            }
            if (screenHeight >= 700)
            {
                screenHeight = 700;
            }
            graphics.PreferredBackBufferWidth  = screenWidth;
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.ApplyChanges();

            //create game objects
            int paddleX = (screenWidth - gameContent.imgPaddle.Width) / 2;                    //we'll center the paddle on the screen to start
            int paddleY = screenHeight - 100;                                                 //paddle will be 100 pixels from the bottom of the screen

            paddle     = new Paddle(paddleX, paddleY, screenWidth, spriteBatch, gameContent); // create the game paddle
            wall       = new Wall(1, 50, spriteBatch, gameContent);
            gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent);
            ball       = new Ball(screenWidth, screenHeight, spriteBatch, gameContent);

            staticBall             = new Ball(screenWidth, screenHeight, spriteBatch, gameContent);
            staticBall.X           = 25;
            staticBall.Y           = 25;
            staticBall.Visible     = true;
            staticBall.UseRotation = false;
        }
Пример #6
0
        private SpriteBatch spriteBatch;  //allows us to write on backbuffer when we need to draw self

        public GameBorder(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameContent gameContent)
        {
            Width            = screenWidth;
            Height           = screenHeight;
            imgPixel         = gameContent.imgPixel;
            this.spriteBatch = spriteBatch;
        }