Пример #1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Content.RootDirectory = "Content";
            var barTexture  = Content.Load <Texture2D>("PongBar");
            var ballTexture = Content.Load <Texture2D>("PongBall");

            var ballOutSound             = Content.Load <SoundEffect>("ballOutSound");
            var ballCollideWithBarSound  = Content.Load <SoundEffect>("ballBarCollision");
            var ballCollideWithEdgeSound = Content.Load <SoundEffect>("ballEdgeCollision");

            var music = Content.Load <SoundEffect>("music");
            SoundEffectInstance soundEffectInstance = music.CreateInstance();

            soundEffectInstance.IsLooped = true;
            soundEffectInstance.Play();

            var font = Content.Load <SpriteFont>("Score");

            playerBar = new Bar(barTexture, BarToEdgePadding, Height, ballCollideWithBarSound);
            cpuBar    = new Bar(barTexture, Width - BarToEdgePadding, Height, ballCollideWithBarSound);

            var ball = new Ball(ballTexture, Width / 2, Width, Height, ballCollideWithEdgeSound);

            score          = new Score(font);
            ballOutManager = new BallOutMananger(ball, Width, ballOutSound, score);

            cpuController = new CpuController(cpuBar, ball, Height);
        }
Пример #2
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);

            Content.RootDirectory = "Content";
            var barTexture = Content.Load<Texture2D>("PongBar");
            var ballTexture = Content.Load<Texture2D>("PongBall");

            var ballOutSound = Content.Load<SoundEffect>("ballOutSound");
            var ballCollideWithBarSound = Content.Load<SoundEffect>("ballBarCollision");
            var ballCollideWithEdgeSound = Content.Load<SoundEffect>("ballEdgeCollision");

            var music = Content.Load<SoundEffect>("music");
            SoundEffectInstance soundEffectInstance = music.CreateInstance();
            soundEffectInstance.IsLooped = true;
            soundEffectInstance.Play();

            var font = Content.Load<SpriteFont>("Score");

            playerBar = new Bar(barTexture, BarToEdgePadding, Height, ballCollideWithBarSound);
            cpuBar = new Bar(barTexture, Width - BarToEdgePadding, Height, ballCollideWithBarSound);

            var ball = new Ball(ballTexture, Width / 2, Width, Height, ballCollideWithEdgeSound);

            score = new Score(font);
            ballOutManager = new BallOutMananger(ball, Width, ballOutSound, score);

            cpuController = new CpuController(cpuBar, ball, Height);
        }