Esempio n. 1
0
        // Checks input
        //Gameworld as argument is JUST FOR TESTING-PURPOSES
        public void checkInput(GameTime gameTime, InputHandler inputHandler, Gameworld gameWorld)
        {
            Vector2 tempVector = inputHandler.getMovementInputFromPlayer();
            playerObject.update(tempVector);

            //playerObject.update(inputHandler.getMovementInputFromPlayer());

            //Temp input
            inputHandler.updateInput();

            if (inputHandler.KeyDown(Keys.X))
            {
                gameWorld.getCamera().Zoom += (float)0.01;
            }

            if (inputHandler.KeyDown(Keys.Z))
            {
                gameWorld.getCamera().Zoom -= (float)0.01;
            }
            if (inputHandler.KeyDown(Keys.D))
            {
                playerObject.updatePosition(1, 0);

            }

            if (inputHandler.KeyDown(Keys.A))
            {
                playerObject.updatePosition(-1, 0);

            }

            if (inputHandler.KeyDown(Keys.S))
            {
                playerObject.updatePosition(0, 1);
            }

            if (inputHandler.KeyDown(Keys.W))
            {
                playerObject.updatePosition(0, -1);

            }
        }
Esempio n. 2
0
        // Checks input during gameplay
        //Gameworld as argument is JUST FOR TESTING-PURPOSES
        public void checkInput(GameTime gameTime, InputHandler inputHandler, Gameworld gameWorld)
        {
            // Controller input
            Vector2 movementVector = inputHandler.getLeftStickMovement();
            Vector2 rightStick = inputHandler.getRightStickMovement();
            //playerObject.update(movementVector, rightStick, gameTime);

            if (inputHandler.ButtonDown(Buttons.RightTrigger) || inputHandler.KeyDown(Keys.LeftShift))
            {
                updateGravityWell(gameWorld, inputHandler.getRightTrigger());
            }
            else
            {
                gameWorld.setDrawGravityWell(false, 0);
            }

            if (inputHandler.ButtonDown(Buttons.LeftTrigger) || inputHandler.KeyDown(Keys.Space))
            {
                gameWorld.getPlayer().ShootingRockets = true;
            }
            if (inputHandler.ButtonReleased(Buttons.LeftTrigger) || inputHandler.KeyReleased(Keys.Space))
            {
                gameWorld.getPlayer().ShootingRockets = false;
            }

            #if DEBUG
            if (inputHandler.ButtonPressed(Buttons.LeftShoulder) && inputHandler.ButtonPressed(Buttons.RightShoulder))
                gameWorld.setDebug();
            #endif

            // Temp Keyboardinput
            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // !USING A KEYBOARD WILL BREAK THE SPEED OF THE PLAYER. THIS IS NOT TO BE INCLUDED IN THE FINAL GAME! //
            // !IT ALSO SCREWS WITH PROJECTILE VELOCITY/DIRECTION!                                                 //
            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            inputHandler.updateInput();

            // Zooming
            if (inputHandler.KeyDown(Keys.X))
            {
                gameWorld.getCamera().Zoom += 0.01f;
            }
            if (inputHandler.KeyDown(Keys.Z))
            {
                gameWorld.getCamera().Zoom -= 0.01f;
            }
            if (inputHandler.KeyDown(Keys.C))
            {
                gameWorld.getCamera().Zoom = 1.0f;
            }

            // Movement
            if (inputHandler.KeyDown(Keys.D))
                movementVector.X = 1;

            if (inputHandler.KeyDown(Keys.A))
                movementVector.X = -1;

            if (inputHandler.KeyDown(Keys.S))
                movementVector.Y = -1;

            if (inputHandler.KeyDown(Keys.W))
                movementVector.Y = 1;

            // Shooting
            if (inputHandler.KeyDown(Keys.Right))
                rightStick.X = 1;

            if (inputHandler.KeyDown(Keys.Left))
                rightStick.X = -1;

            if (inputHandler.KeyDown(Keys.Down))
                rightStick.Y = -1;

            if (inputHandler.KeyDown(Keys.Up))
                rightStick.Y = 1;
            // Other keys
            #if DEBUG
            if (inputHandler.KeyReleased(Keys.F1))
                gameWorld.setDebug();
            #endif

            physicsEngine.collisionDetection(ref gameWorld, movementVector, rightStick, gameTime);
        }
Esempio n. 3
0
        public void updateMenu(Gameworld gameWorld, InputHandler inputHandler, GameTime gameTime, Highscores highscores)
        {
            inputHandler.updateInput();

            Vector2 movementVector = inputHandler.getLeftStickMovement();

            bool aButton = false;                       // flagged if A button, or Enter, is pressed
            bool bButton = false;                       // flagged if B button, or backspace, is pressed

            int movementY = 0;                           // Tells the menu where to move next (-1 is up, 1 is down)
            int movementX = 0;

            if (inputHandler.ButtonPressed(Buttons.DPadDown) || movementVector.Y < 0 || inputHandler.KeyReleased(Keys.Down))
                movementY = 1;
            if (inputHandler.ButtonPressed(Buttons.DPadUp) || movementVector.Y > 0 || inputHandler.KeyReleased(Keys.Up))
                movementY = -1;

            if (inputHandler.ButtonPressed(Buttons.DPadLeft) || movementVector.X < 0 || inputHandler.KeyReleased(Keys.Left))
                movementX = -1;
            if (inputHandler.ButtonPressed(Buttons.DPadRight) || movementVector.X > 0 || inputHandler.KeyReleased(Keys.Right))
                movementX = 1;

            if (inputHandler.ButtonPressed(Buttons.A) || inputHandler.KeyDown(Keys.Enter))
                aButton = true;
            if (inputHandler.ButtonPressed(Buttons.B) || inputHandler.KeyDown(Keys.Back))
                bButton = true;

            if (menuHandler.ElapsedSinceLastInput > menuHandler.AllowedTimeBetweenInputs)
            {
                if (movementY != 0 || movementX != 0 || aButton || bButton)
                {
                    menuHandler.update(movementY, movementX, aButton, bButton);
                    menuHandler.ElapsedSinceLastInput = 0;
                }
            }

            menuHandler.ElapsedSinceLastInput += gameTime.ElapsedGameTime.Milliseconds;

            if (menuHandler.sendScore)
            {
                sendScore(gameWorld);

                menuHandler.ExitGame = true;
            }
        }