Example #1
0
  public void update() {
    Vector3f playerDistance = transform.getPosition().sub(Transform.getCamera().getPos());

    Vector3f orientation = playerDistance.normalized();
    float distance = playerDistance.length();

    float angle = (float) Math.toDegrees(Math.atan(orientation.getZ() / orientation.getX()));

    if (orientation.getX() > 0) angle = 180 + angle;

    transform.setRotation(0, angle + 90, 0);

    if (distance < PICKUP_THRESHHOLD && Level.getPlayer().getHealth() < 100) {
      Level.getPlayer().damage(-HEAL_AMOUNT);
      Level.removeMedkit(this);
      AudioUtil.playAudio(pickupNoise, 0);
    }
  }
Example #2
0
 public void render() {
   Game.updateShader(
       transform.getTransformation(), transform.getPerspectiveTransformation(), material);
   mesh.draw();
 }