| name | fxgl-idle-clicker |
| description | Build an incremental idle or clicker game in FXGL — click for resources, buy auto-producers, scale costs exponentially, show passive income in the HUD, unlock upgrades by milestones, calculate capped offline progress on load, format very large numbers, and implement prestige resets with permanent bonuses.
|
| triggers | ["idle game","clicker","incremental","passive income","offline progress","prestige","big number formatting","auto producer"] |
| compatibility | Java 17+, FXGL 21.x. Pairs naturally with fxgl-save-load, fxgl-progression, and fxgl-ui-scenes.
|
| category | fxgl/game-types |
| tags | ["fxgl","java","javafx","game-types","idle","clicker"] |
| metadata | {"author":"fxgl-skills","version":"1.0","fxgl-version":"21.1"} |
| allowed-tools | ["Read","Write","Edit","Bash"] |
FXGL Idle / Clicker Game
Core Variables
@Override
protected void initGameVars(Map<String, Object> vars) {
vars.put("coins", 0.0);
vars.put("clickValue", 1.0);
vars.put("passivePerSecond", 0.0);
vars.put("prestigeBonus", 1.0);
}
Track producers separately in a model rather than scattering values across many globals.
public record Producer(String id, double baseRate, double baseCost, IntegerProperty owned) {
public double currentCost() {
return baseCost * Math.pow(1.15, owned.get());
}
}
Click Loop
private void onMainClick() {
double gain = getd("clickValue") * getd("prestigeBonus");
set("coins", getd("coins") + gain);
}
Bind the main click to a large button or main resource sprite in initUI().
Passive Income
private final List<Producer> producers = List.of(
new Producer("cursor", 0.2, , ()),
(, , , ()),
(, , , ())
);
{
run(() -> {
set(, getd() + getd());
}, Duration.seconds());
}
{
producers.stream()
.mapToDouble(p -> p.owned().get() * p.baseRate())
.sum();
set(, rate * getd());
}