aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
index 834aeb1..d8d672d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
@@ -3,10 +3,10 @@ package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
public abstract class Animation {
- private final int duration;
+ private final float duration;
private final float start;
private final float change;
- private long timePassed = 0;
+ private float timePassed = 0;
/**
* @param duration The duration of the animation
@@ -14,7 +14,7 @@ public abstract class Animation {
* @param end The end of the animation
* @param reverse Reverse the animation
*/
- public Animation(int duration, float start, float end, boolean reverse) {
+ public Animation(float duration, float start, float end, boolean reverse) {
this.duration = duration;
this.start = start;
if (!reverse) this.change = end - start;
@@ -25,12 +25,10 @@ public abstract class Animation {
* @param deltaTime The time since the last frame
* @return The new value
*/
- public float get(long deltaTime) {
+ public float get(float deltaTime) {
timePassed += deltaTime;
- if (timePassed >= duration) return start + change;
- float value = animate(timePassed, duration, start, change);
- System.out.println(value);
- return value;
+ if (timePassed >= duration) timePassed = duration;
+ return animate(timePassed, duration, start, change);
}
/**
@@ -47,5 +45,5 @@ public abstract class Animation {
return timePassed >= duration;
}
- protected abstract float animate(long timePassed, int duration, float start, float change);
+ protected abstract float animate(float timePassed, float duration, float start, float change);
}