Example #1
0
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     puto        = Content.Load <SpriteFont>("Puntuacion");
     road1       = Content.Load <Texture2D>("Road");
     road2       = Content.Load <Texture2D>("Road");
     Win         = Content.Load <Texture2D>("You Win");
     Lose        = Content.Load <Texture2D>("Game Over");
     P1          = new Player(Content.Load <Texture2D>("spaceship1"), 330, 900);
     P2          = new Player(Content.Load <Texture2D>("spaceship1"), 1480, 900);
     world1      = new LevelMap(Content.Load <Texture2D>("spikeballlj3"));
     song        = Content.Load <Song>("Dream Chaser");
     MediaPlayer.Play(song);
     MediaPlayer.IsRepeating = true;
 }
Example #2
0
        protected override void Update(GameTime gameTime)
        {
            controllerPlayer1 = GamePad.GetState(PlayerIndex.One);
            controllerPlayer2 = GamePad.GetState(PlayerIndex.Two);
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit(); // se sale del juego
            }


            if (controllerPlayer1.Buttons.A == ButtonState.Pressed && paused == true || controllerPlayer2.Buttons.A == ButtonState.Pressed && paused == true)// Hacer Start el juego y animacion de salida
            {
                paused  = false;
                started = true;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.P) && started == true)
            {
                paused  = true;
                started = false;
            }

            if (controllerPlayer1.Buttons.B == ButtonState.Pressed || controllerPlayer2.Buttons.B == ButtonState.Pressed && paused == true)
            {
                //metodo que rezetea todo el juego
                endGame = false;
                paused  = true;
                started = false;
                P1      = new Player(Content.Load <Texture2D>("spaceship1"), 330, 900);
                P2      = new Player(Content.Load <Texture2D>("spaceship1"), 1480, 900);
                world1  = new LevelMap(Content.Load <Texture2D>("spikeballlj3"));
            }

            if (started)
            {
                controllerPlayer1 = GamePad.GetState(PlayerIndex.One);
                controllerPlayer2 = GamePad.GetState(PlayerIndex.Two);

                if (controllerPlayer1.IsConnected && controllerPlayer2.IsConnected)
                {
                    P1.placeHolder.Update();
                    P2.placeHolder.Update();

                    world1.updata(P1);
                    world1.updato(P2);



                    // level map update adentro se hace update de map objects
                    P1.Input(controllerPlayer1);
                    P2.Input(controllerPlayer2);
                }

                else
                {
                    paused  = true;
                    started = false;
                }

                if (P1.monkaS == 0)
                {
                    started = false;
                    endGame = true;
                }
                if (P2.monkaS == 0)
                {
                    started = false;
                    endGame = true;
                }

                P1.Puntuacion += gameTime.ElapsedGameTime.Milliseconds * P1.factorVelocity;
                P2.Puntuacion += gameTime.ElapsedGameTime.Milliseconds * P2.factorVelocity;
            }

            frameRate = 1 / (float)gameTime.ElapsedGameTime.TotalSeconds;

            base.Update(gameTime);
        }