Added a indicator to show when the cooldown between flaps is complete

This commit is contained in:
Sollace 2023-08-13 15:58:08 +01:00
parent 72f6c4ff19
commit 3fcb05de81
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 18 additions and 0 deletions

View file

@ -88,6 +88,16 @@ public class UHud {
MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.translate(scaledWidth / 2, scaledHeight / 2, 0);
float flapCooldown = pony.getPhysics().getFlapCooldown(tickDelta);
if (flapCooldown > 0) {
float angle = MathHelper.TAU * flapCooldown;
DrawableUtil.drawArc(context.getMatrices(), 3, 6, -angle / 2F, angle, 0x888888AF, false);
}
matrices.pop();
matrices.push();
int hudX = ((scaledWidth - 50) / 2) + (104 * xDirection);
int hudY = scaledHeight - 50;

View file

@ -57,6 +57,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
private int ticksDiving;
private float thrustScale = 0;
private float prevThrustScale;
private boolean flapping;
private boolean isCancelled;
@ -97,6 +98,11 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
return super.getGravityModifier();
}
public float getFlapCooldown(float tickDelta) {
float lerpedThrust = MathHelper.lerp(tickDelta, prevThrustScale, thrustScale);
return lerpedThrust <= 0.000001F ? 0 : lerpedThrust;
}
@Override
public float getGravityModifier() {
float modifier = getPersistantGravityModifier();
@ -209,6 +215,8 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
public void tick() {
super.tick();
prevThrustScale = thrustScale;
if (wallHitCooldown > 0) {
wallHitCooldown--;
}