@argila/platformer
v0.1.0
Published
Platformer characters for argila: a kinematic body that moves against tile queries, and tunable jumps
Maintainers
Readme
@argila/platformer
Platformer characters for argila, on a tilemap from @argila/tilemap and with no physics engine.
CharacterBody: a kinematic box that moves by its velocity againstTileQuery's answers. Solid tiles stop it from every side, one-way tiles hold it up only from above (and it can drop through them), and it walks slopes and low steps by the middle of its feet, staying on the ground as it runs down them. Its position is its feet, in map pixels; it writes the entity's transform through the map's.Jump: jumps on a character body with coyote time, jump buffering, variable height (stronger gravity while rising with the button let go, not a velocity cut) and air jumps, every part tunable. Heights are in map pixels; the launch speed follows from the body's gravity.
import { World } from "@argila/core";
import { CharacterBody, Jump } from "@argila/platformer";
World.addSystem(world, Jump);
World.addSystem(world, CharacterBody);
const body = CharacterBody.create(hero, { map, width: 10, height: 14, gravity: 900 });
Jump.create(hero, { height: 48, airJumps: 1, coyoteTime: 0.1, bufferTime: 0.12 });
Jump.jumped.on(world, ({ air }) => dust(air));
CharacterBody.landed.on(world, ({ speed }) => thud(speed));
// Every tick, in the game's update:
body.vx = actions.axis("left", "right") * 90;
Jump.input(hero, actions.pressed("jump"), actions.held("jump"));Jump runs in the update phase and CharacterBody in the physics phase; both follow the
world's time, so they hold still in hit-stop and while the world is paused. Each is also its own
entry: @argila/platformer/CharacterBody, @argila/platformer/Jump.
