示例#1
0
 private Vector3f getTranslation(Vector3f dir, float amt) {
   return (dir.mul(amt));
 }
示例#2
0
  public void input() {
    float movAmt = (float) (speed * Time.getDelta());
    Vector3f rightVec = getTransform().getRotation().getRight().normalized();
    moving = false;
    if (Input.getKey(forward)) {
      movementVector.set(movementVector.add(getTranslation(rightVec.cross(Y_AXIS), movAmt)));
      moving = true;
    }
    if (Input.getKey(backward)) {
      movementVector.set(movementVector.add(getTranslation(rightVec.cross(Y_AXIS), -movAmt)));
      moving = true;
    }
    if (Input.getKey(right)) {
      movementVector.set(movementVector.add(getTranslation(rightVec, movAmt)));
      moving = true;
    }
    if (Input.getKey(left)) {
      movementVector.set(movementVector.add(getTranslation(rightVec, -movAmt)));
      moving = true;
    }
    if (Input.getKeyDown(reloadButton)) {
      reloading = true;
    }

    if (Input.getKeyDown(jumpButton)) {
      movementVector.set(movementVector.add(getTranslation(Y_AXIS, JUMP_HEIGHT * movAmt)));
      moving = true;
      //            jumping = true;
    }

    // template!
    //        if(Input.getKeyDown(Input.KEY_U)){
    //            movementVector.set(movementVector.add(getTranslation(Y_AXIS, 9 * movAmt)));
    //            moving = true;
    //        }
    //
    //        if(Input.getKey(Input.KEY_J)){
    //            movementVector.set(movementVector.add(getTranslation(Y_AXIS, -movAmt)));
    //            moving = true;
    //        }

    if (!moving) {
      movementVector = new Vector3f(0, 0, 0);
    }
  }
示例#3
0
 private void move(Vector3f dir, float amt) {
   getTransform().setPosition(getTransform().getPosition().add(dir.mul(amt)));
 }