Ejemplo n.º 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);

            texturePlayer     = Content.Load <Texture2D>(@"Images\john");
            texturePong       = Content.Load <Texture2D>(@"Images\pong");
            bgTexture         = Content.Load <Texture2D>(@"Images\background");
            buttonTexture     = Content.Load <Texture2D>(@"Images\button");
            texturePaddleWash = Content.Load <Texture2D>(@"Images\paddleWash");
            textureBox        = Content.Load <Texture2D>(@"Images\box");
            textureColor      = Content.Load <Texture2D>(@"Images\boxGrey");
            arial             = Content.Load <SpriteFont>(@"Fonts\Arial");
            arialBold         = Content.Load <SpriteFont>(@"Fonts\Arial Bold");
            system            = Content.Load <SpriteFont>(@"Fonts\System");

            // Creates the player character.
            player = new Player(new Vector2(100, graphics.PreferredBackBufferHeight - 50), 2, Keys.W, Keys.S, Keys.A, Keys.D, Keys.Q, Keys.E);
            // Creates the player animations
            player.addAnimations(texturePlayer);

            pongDefaultposition = new Vector2((windowSize.X - texturePong.Width) / 2, ((windowSize.Y - 100 - texturePong.Height) / 2) + 100);

            paddleLeft = new PaddleLeft(texturePaddleWash, new Vector2(25, (windowSize.Y - texturePaddleWash.Height) / 2), paddleLeftColor, this, Keys.W, Keys.S);

            paddleRight = new PaddleRight(texturePaddleWash, new Vector2((windowSize.X - 75), (windowSize.Y - texturePaddleWash.Height) / 2), paddleRightColor, this, Keys.None, Keys.None);

            paddleRightPlayer    = new PaddleRight(texturePaddleWash, new Vector2((windowSize.X - 75), (windowSize.Y - texturePaddleWash.Height) / 2), paddleRightColor, this, Keys.Up, Keys.Down);
            paddleRightPlayer.ai = false;

            startGameInst = new Label(new Vector2(windowSize.X, 100), system, 0.5f, Color.White, "Press (Space) to start");

            pong = new Pong(texturePong, new Vector2((windowSize.X - texturePong.Width) / 2, ((windowSize.Y - 100 - texturePong.Height) / 2) + 100), pongColor, this);

            debugLabel = new Label(new Vector2(5, 5), arial, 0.5f, Color.White, "");

            // Creates the score text
            score = new Label(new Vector2(windowSize.X, 25), arial, 1.0f, Color.White, scoreLeft.ToString() + "     " + scoreRight.ToString());

            bgColorRedUp     = new Button(buttonTexture, new Vector2(50, 100), arial, 1f, Color.Black, "Red +", Color.White);
            bgColorRedDown   = new Button(buttonTexture, new Vector2(168, 100), arial, 1f, Color.Black, "Red -", Color.White);
            bgColorGreenUp   = new Button(buttonTexture, new Vector2(50, 128), arial, 1f, Color.Black, "Green +", Color.White);
            bgColorGreenDown = new Button(buttonTexture, new Vector2(168, 128), arial, 1f, Color.Black, "Green -", Color.White);
            bgColorBlueUp    = new Button(buttonTexture, new Vector2(50, 156), arial, 1f, Color.Black, "Blue +", Color.White);
            bgColorBlueDown  = new Button(buttonTexture, new Vector2(168, 156), arial, 1f, Color.Black, "Blue -", Color.White);

            pLColorRedUp     = new Button(buttonTexture, new Vector2(278, 100), arial, 1f, Color.Black, "Red +", Color.White);
            pLColorRedDown   = new Button(buttonTexture, new Vector2(396, 100), arial, 1f, Color.Black, "Red -", Color.White);
            pLColorGreenUp   = new Button(buttonTexture, new Vector2(278, 128), arial, 1f, Color.Black, "Green +", Color.White);
            pLColorGreenDown = new Button(buttonTexture, new Vector2(396, 128), arial, 1f, Color.Black, "Green -", Color.White);
            pLColorBlueUp    = new Button(buttonTexture, new Vector2(278, 156), arial, 1f, Color.Black, "Blue +", Color.White);
            pLColorBlueDown  = new Button(buttonTexture, new Vector2(396, 156), arial, 1f, Color.Black, "Blue -", Color.White);

            pRColorRedUp     = new Button(buttonTexture, new Vector2(50, 264), arial, 1f, Color.Black, "Red +", Color.White);
            pRColorRedDown   = new Button(buttonTexture, new Vector2(168, 264), arial, 1f, Color.Black, "Red -", Color.White);
            pRColorGreenUp   = new Button(buttonTexture, new Vector2(50, 292), arial, 1f, Color.Black, "Green +", Color.White);
            pRColorGreenDown = new Button(buttonTexture, new Vector2(168, 292), arial, 1f, Color.Black, "Green -", Color.White);
            pRColorBlueUp    = new Button(buttonTexture, new Vector2(50, 320), arial, 1f, Color.Black, "Blue +", Color.White);
            pRColorBlueDown  = new Button(buttonTexture, new Vector2(168, 320), arial, 1f, Color.Black, "Blue -", Color.White);

            pColorRedUp     = new Button(buttonTexture, new Vector2(278, 264), arial, 1f, Color.Black, "Red +", Color.White);
            pColorRedDown   = new Button(buttonTexture, new Vector2(396, 264), arial, 1f, Color.Black, "Red -", Color.White);
            pColorGreenUp   = new Button(buttonTexture, new Vector2(278, 292), arial, 1f, Color.Black, "Green +", Color.White);
            pColorGreenDown = new Button(buttonTexture, new Vector2(396, 292), arial, 1f, Color.Black, "Green -", Color.White);
            pColorBlueUp    = new Button(buttonTexture, new Vector2(278, 320), arial, 1f, Color.Black, "Blue +", Color.White);
            pColorBlueDown  = new Button(buttonTexture, new Vector2(396, 320), arial, 1f, Color.Black, "Blue -", Color.White);

            applyButton  = new Button(buttonTexture, new Vector2(((windowSize.X - buttonTexture.Width) / 2) + 15, windowSize.Y - 28), arial, 1.0f, Color.Black, "Apply", Color.White);
            cancelButton = new Button(buttonTexture, new Vector2(((windowSize.X - buttonTexture.Width) / 2) + ((buttonTexture.Width / 2) + 15), windowSize.Y - 28), arial, 1.0f, Color.Black, "Cancel", Color.White);

            backgoundLabel   = new Label(new Vector2(80, 75), arial, 1.0f, Color.White, "Background");
            paddleLeftLabel  = new Label(new Vector2(600, 75), arial, 1.0f, Color.White, "Paddle Left");
            paddleRightLabel = new Label(new Vector2(80, 239), arial, 1.0f, Color.White, "Paddle Right");
            pongLabel        = new Label(new Vector2(650, 239), arial, 1.0f, Color.White, "Pong");

            endText = new Label(new Vector2(windowSize.X, ((windowSize.Y - 23) / 2) - 28), arial, 1.0f, Color.White, "");

            resetButton = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, (windowSize.Y - 23) / 2), arial, 1.0f, Color.Black, "Reset", Color.White);

            mainMenuButton2 = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, ((windowSize.Y - 23) / 2) + 28), arial, 1f, Color.Black, "Menu", Color.White);

            pauseButton    = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, ((windowSize.Y - 23) / 2)), arial, 1.0f, Color.Black, "Resume", Color.White);
            mainMenuButton = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, ((windowSize.Y - 23) / 2) + 28), arial, 1.0f, Color.Black, "Menu", Color.White);
            pausedLabel    = new Label(new Vector2(windowSize.X, ((windowSize.Y - 20) / 2) - 48), arial, 1f, Color.White, "Paused");

            playButton = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, 150), arial, 1.0f, Color.Black, "Play", Color.White);

            pvpPlayButton = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, 178), arial, 1.0f, Color.Black, "Play PvP", Color.White);

            optionsButton = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, 206), arial, 1.0f, Color.Black, "Options", Color.White);

            exitButton = new Button(buttonTexture, new Vector2((windowSize.X - 85) / 2, 243), arial, 1.0f, Color.Black, "Exit", Color.White);


            dummyPaddleLeft        = new PaddleLeft(texturePaddleWash, new Vector2(25, (windowSize.Y - texturePaddleWash.Height) / 2), new Color(0, 1f, 0), this, Keys.None, Keys.None);
            dummyPaddleLeft.dummy  = true;
            dummyPaddleRight       = new PaddleRight(texturePaddleWash, new Vector2((windowSize.X - 75), (windowSize.Y - texturePaddleWash.Height) / 2), Color.Red, this, Keys.None, Keys.None);
            dummyPaddleRight.dummy = true;
            dummyPong       = new Pong(texturePong, new Vector2((windowSize.X - texturePong.Width) / 2, ((windowSize.Y - 100 - texturePong.Height) / 2) + 100), new Color(1, 0.80f, 0), this);
            dummyPong.move  = true;
            dummyPong.dummy = true;
            // TODO: use this.Content to load your game content here
        }