Example usage for com.badlogic.gdx.math Vector2 scl

List of usage examples for com.badlogic.gdx.math Vector2 scl

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Vector2 scl.

Prototype

@Override
    public Vector2 scl(Vector2 v) 

Source Link

Usage

From source file:us.notsoserio.ninja.session.server.ServerInputManager.java

License:Apache License

public static void ProcessInput(PlayerBehavior player, Command command) {

    if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT) && !recoil) {
        Vector2 velocity = new Vector2((Gdx.input.getX() - 1280 / 2) / NinjaGame.ZoomFactor,
                ((720 - Gdx.input.getY()) - 720 / 2) / NinjaGame.ZoomFactor);
        velocity.scl(0.4f);
        player.FireProjectile(velocity, Projectiles.Kunai);
        recoil = true;//from  ww  w. ja va2  s .c  om
    } else if (!Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
        recoil = false;
    }

    if (player.isInControl) {
        if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
            player.isWalkingLeft = false;
            player.isWalkingRight = false;
            player.isWalkingUp = false;
            player.isWalkingDown = false;
            player.isJumping = true;
            player.JumpX = (Gdx.input.getX() - 1280 / 2) / NinjaGame.ZoomFactor;
            player.JumpX *= 3f;
            player.JumpY = ((720 - Gdx.input.getY()) - 720 / 2) / NinjaGame.ZoomFactor;
            player.JumpY *= 3f;
        } else if (Gdx.input.isKeyPressed(Input.Keys.A)) {
            player.isWalkingLeft = true;
        } else if (Gdx.input.isKeyPressed(Input.Keys.D)) {
            player.isWalkingRight = true;
        } else if (Gdx.input.isKeyPressed(Input.Keys.W)) {
            player.isWalkingUp = true;
        } else if (Gdx.input.isKeyPressed(Input.Keys.S)) {
            player.isWalkingDown = true;
        } else {
            player.isWalkingLeft = false;
            player.isWalkingRight = false;
            player.isWalkingUp = false;
            player.isWalkingDown = false;
        }
    } else {
        player.isWalkingLeft = false;
        player.isWalkingRight = false;
        player.isWalkingUp = false;
        player.isWalkingDown = false;
    }

}