Пример #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);
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            //Load the SoundEffect resources
            // Load the SoundEffect resource
            p1 = Content.Load<SoundEffect>("p1m");
            p2 = Content.Load<SoundEffect>("p2m");
            bgm = Content.Load<Song>("bgm");
            ballhit = Content.Load<SoundEffect>("ball");
            win1Scr=Content.Load<Texture2D>("p1win");
            bgi = Content.Load<Texture2D>("bg-Recovered");
            MediaPlayer.IsRepeating = true;

            menuBack = Content.Load<Texture2D>("title");

            menuTxt = Content.Load<Texture2D>("menu1");
            menu = new MenuScreen(this, menuBack, menuTxt);

            Components.Add(menu);
            menu.Show();

            winScrPl = new Win1Screen(this, win1Scr, spriteBatch);
            Font1 = Content.Load<SpriteFont>("Courier New");
            sourceRectpleft = new Rectangle(0, 0, 48, 124);
            sourceRectpright = new Rectangle(0, 0, 48, 124);
            sourceRectBall = new Rectangle(0, 0, 40, 40);
            computer_paddle = new Paddle(Content.Load<Texture2D>("p1"), new Vector2(20,384), new Vector2(42, 124),
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            player_paddle = new Paddle(Content.Load<Texture2D>("p2"), new Vector2(950,384), new Vector2(42, 124),
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            ball = new Ball(Content.Load<Texture2D>("ballsprite"), new Vector2(384, 284), new Vector2(40, 40),
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            newGameSingle1 = new newGameSingle(this, computer_paddle, player_paddle, bgm, p1, p2, ballhit, ball, graphics, spriteBatch, bgi);
            newGameMulti1 = new newGameMulti(this, computer_paddle, player_paddle, bgm, p1, p2, ballhit, ball, graphics, spriteBatch, bgi);
            //  set the speed the objects will move

            // the ball always starts in the middle and moves toward the player
            ball.Reset();
            computer_paddle.velocity = new Vector2(0, 2);
        }
Пример #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);

            //Load the SoundEffect resources
            // Load the SoundEffect resource
            ballhit = Content.Load<SoundEffect>("ballhit");
            killshothit = Content.Load<SoundEffect>("killshot");
            paddlemiss = Content.Load<SoundEffect>("miss");

            Font1 = Content.Load<SpriteFont>("Courier New");

            computer_paddle = new Paddle(Content.Load<Texture2D>("left_paddle"), new Vector2(20f, 268f), new Vector2(24f, 64f),
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            player_paddle = new Paddle(Content.Load<Texture2D>("right_paddle"), new Vector2(756f, 268f), new Vector2(24f, 64f),
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            ball = new Ball(Content.Load<Texture2D>("small_ball"), new Vector2(384f, 284f), new Vector2(32f, 32f),
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            //  set the speed the objects will move
            // the ball always starts in the middle and moves toward the player
            ball.Reset();
            computer_paddle.velocity = new Vector2(0, 2);
        }