示例#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);

            // create ball and paddle objects
            pongBall = new Ball(Content, new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2), 10);
            pongBall.GiveRandomVelocity();

            leftPaddle = new Paddle(Content, 100, 20, "left", GraphicsDevice);
            rightPaddle = new Paddle(Content, 100, 20, "right", GraphicsDevice);

            // load audio components
            audioEngine = new AudioEngine(@"Content/Pong.xgs");
            waveBank = new WaveBank(audioEngine, @"Content/Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, @"Content/Sound Bank.xsb");

            // set the board rectangle to the size of the window, load the board texture
            boardRectangle = new Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
            boardTexture = Content.Load<Texture2D>("board");

            playerOneScore = new Score(Content, new Vector2(WINDOW_WIDTH / 4, 25), 39, 75);
            playerTwoScore = new Score (Content, new Vector2 ((3 * (WINDOW_WIDTH / 4)), 25), 39, 75);
        }