AchievementLogic.java
package io.github.some_example_name;
/**
* Core logic for achievements - no LibGDX.
*/
public class AchievementLogic {
private float y;
private final float targetY;
private final float speed;
private boolean visible;
private boolean unlocked;
public AchievementLogic(float startY, float targetY, float speed) {
this.y = startY;
this.targetY = targetY;
this.speed = speed;
this.visible = false;
this.unlocked = false;
}
/** Unlocks achievement once */
public void unlock() {
if (!unlocked) {
unlocked = true;
visible = true;
}
}
/** Updates vertical animation when visible */
public void update(float delta) {
if (!visible) return;
if (y < targetY) {
y += speed * delta;
if (y > targetY) {
y = targetY;
}
}
}
/** Hides achievement */
public void hide() {
visible = false;
}
public boolean isUnlocked() {
return unlocked;
}
public boolean isVisible() {
return visible;
}
public float getY() {
return y;
}
}