Exemple #1
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);
            font        = Content.Load <SpriteFont>("Score"); // Use the name of your sprite font file here instead of 'Score'.

            var gameBoundaries   = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);
            var paddleContent    = Content.Load <Texture2D>("paddle");
            var opponentLocation = new Vector2(gameBoundaries.Width - paddleContent.Width, 0);

            score          = new GameScore(font, gameBoundaries);
            playerPaddle   = new Paddle(paddleContent, Vector2.Zero, gameBoundaries, PlayerType.Human);
            opponentPaddle = new Paddle(paddleContent, opponentLocation, gameBoundaries, PlayerType.Computer);

            ball = new Ball(Content.Load <Texture2D>("ball"), Vector2.Zero, gameBoundaries);
            ball.AttachTo(playerPaddle);

            gameObjects = new GameObjects
            {
                Ball           = ball,
                PlayerPaddle   = playerPaddle,
                ComputerPaddle = opponentPaddle,
                Score          = score
            };
        }
Exemple #2
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            var gameBoundaries = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);

            combodogPaddleTexture = Content.Load <Texture2D>("graphics/combo_dog");
            plaindogPaddleTexture = Content.Load <Texture2D>("graphics/plain_hotdog");
            ballTexture           = Content.Load <Texture2D>("graphics/weiner");

            playerPaddle = new Paddle(combodogPaddleTexture, Vector2.Zero, gameBoundaries, PlayerTypes.Human);
            var computerPaddleLocation = new Vector2(gameBoundaries.Width - plaindogPaddleTexture.Width, 0);

            computerPaddle = new Paddle(plaindogPaddleTexture, computerPaddleLocation, gameBoundaries, PlayerTypes.Computer);

            ball        = new Ball(ballTexture, Vector2.Zero, gameBoundaries);
            ball.Origin = new Vector2(ball.Texture.Width / 2, ball.Texture.Height / 2);
            ball.AttachTo(playerPaddle);

            score = new Score(Content.Load <SpriteFont>("fonts/HighScoreFont"), gameBoundaries);

            gameObjects = new GameObjects {
                PlayerPaddle = playerPaddle, ComputerPaddle = computerPaddle, Ball = ball, Score = score
            };
        }
Exemple #3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            var gameBoundaries = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);
            var paddleTexture = Content.Load<Texture2D>("Paddle");

            playerPaddle = new Paddle(paddleTexture, Vector2.Zero, gameBoundaries, PlayerTypes.Human);
            computerPaddle = new Paddle(paddleTexture, new Vector2(gameBoundaries.Width - paddleTexture.Width, 0), gameBoundaries, PlayerTypes.Computer);
            ball = new Ball(Content.Load<Texture2D>("Ball"), Vector2.Zero, gameBoundaries);
            ball.AttachTo(playerPaddle);

            score = new Score(Content.Load<SpriteFont>("GameFont"), gameBoundaries);

            gameObjects = new GameObjects { PlayerPaddle = playerPaddle, ComputerPaddle = computerPaddle, Ball = ball, Score=score };
        }
Exemple #4
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);

            var paddle = Content.Load <Texture2D>("Pong paddle");

            playerPaddle   = new Paddle(paddle, Vector2.Zero, Color.Black, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height), PlayerTypes.Human);
            computerPaddle = new Paddle(paddle, new Vector2(Window.ClientBounds.Width - paddle.Width, 0), Color.Black, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height), PlayerTypes.Computer);
            ball           = new Ball(Content.Load <Texture2D>("Pong Ball"), Vector2.Zero, Color.Blue, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height));
            ball.AttachTo(playerPaddle);


            score = new Score(Content.Load <SpriteFont>("Gamefont"), new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height));

            gameObjects = new GameObjects {
                PlayerPaddle = playerPaddle, ComputerPaddle = computerPaddle, Ball = ball, Score = score
            };
        }