Beispiel #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);

            }
        }
Beispiel #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);
        }