Experience, levelling and skill trees. XP curves (linear, power, exponential) and how they feel, levelling up with carry-over and several levels at once, max level, XP sources and pacing, stat growth per level, skill trees with prerequisites, ranks, exclusive choices, respec and validation, level-up feedback, and saving progress. Includes tested progression.js. Use for "add XP / levels / skill ...
Download skill (.zip) Files on GitHubLevel progression
Drop-in: assets/progression.js (tests: multi-level gains with carry-over, progress fraction, max-level cap, skill
prerequisites by rank, exclusive choices, respec refunds, tree validation catches loops and missing nodes).
import { Level, xpCurve, statAt, SkillTree } from "./core/progression.js";
const lvl = new Level(xpCurve.power(100, 1.5), { maxLevel: 30, onLevelUp: (L) => { points++; celebrate(L); } });
lvl.add(enemy.xp); // returns levels gained; lvl.progress → 0..1 for the XP bar
player.maxHp = statAt(100, 12, lvl.level);
const tree = new SkillTree({
toughness: { cost: 1, maxRank: 3, mods: { maxHp: 10 } },
dash: { cost: 2, requires: ["toughness"], requiresRank: { toughness: 2 } },
fire: { cost: 1, excludes: ["ice"], mods: { fireDmg: 5 } }, ice: { cost: 1, excludes: ["fire"], mods: { slow: 0.2 } },
});
console.assert(tree.validate().length === 0, tree.validate());
tree.unlock("toughness", wallet /* { points, level } */); const mods = tree.mods();
Pacing
| Curve | Feel | Use |
|---|---|---|
linear |
Steady | Short games, arcade |
power (exp 1.3–1.8) |
Classic RPG: fast early, slower later | Most games |
exponential (×1.1–1.3) |
Very steep late | Idle games (with growing income) |
- First level-up in 1–3 minutes, then roughly every 5–10 minutes in the mid game.
- Plot the time per level: XP per minute (from sources) against
curve(L). Avoid sudden walls (game-balance-testing). - Every level gives something visible: a point, a stat jump, a new ability, a cosmetic.
Skill trees
- 2–3 branches with an identity each (tank, damage, utility). Early nodes cheap and useful; capstones transformative.
- Exclusive choices create builds; respec (free or cheap) lets people experiment.
- Show locked nodes with what they need.
available(wallet)lists what can be bought now. - Validate the tree in tests so typos don’t create unreachable nodes.
Feedback
Level-up: sound, burst, a short banner (“Level 5!”), and a clear “+1 skill point” with a button that opens the tree. Don’t interrupt combat with menus; queue them.
Roguelites
Separate run progression (resets each run) from meta progression (saved). Meta upgrades should widen options more than they raise raw power.