What it does
EnemyShots moves enemy projectiles over a platform map. A shot spec names the kind, its speed and size, and how it
is aimed: straight ahead, straight down, at the target or lobbed in an arc with its own lift and gravity. It can live
for a time or a distance, rebound off walls instead of breaking, fly back to its thrower after its range, ignore the
map like a laser through floors, or leave a burning patch where it lands. The kind is a free name, so your renderer
and rules decide what a rock, a bottle or a bomb looks like and does.
Chasers handles the enemies the player cannot kill and must keep away from: one that lines up with the target on one
axis and then the other, accelerating to a top speed and tiring after a while; one that flies straight at the target;
and one that drifts and rebounds off the screen's edges, which a player's shot can stun and throw somewhere else.
hazardBehaviours registers seven enemy behaviours with platform-enemies. They return walker intents like the
built-in moves and call your shoot and summon hooks for projectiles and minions, so scoring and objectives stay in
your rules.
Features
- Aimed shots — facing, down, at the target or in an arc, with lift, gravity, lifetime and range.
- Projectile variations — bouncing, boomerang returns, passing through the map, and burning patches on impact.
- Invincible chasers — axis-alternating, homing and wandering movers with acceleration, top speed, tiring, size and a choice of whether touch is deadly.
- A hunter behaviour — walks, turns at walls, decides at edges, jumps up through platforms toward a higher target, takes running jumps, shoots, dashes and drifts toward the target.
- Six more behaviours —
wall-flyer,invader,spring,sentry,perchandboss, the boss holding a side, hopping, summoning minions and firing, or ricocheting when it flies. - Hit tests — which shots or chasers overlap a box, for your rules to act on, and a call to teleport a chaser.
- Deterministic — pure movement over the map, seeded randomness for chasers, and snapshot and restore.
Good for
- Bubble-trapping platformers in the style of Bubble Bobble, with rock-throwers, wall-to-wall flyers and an invincible chaser that lines up axis by axis.
- Snowball platformers in the style of Snow Bros, with a pumpkin head a shot throws aside and homing ghosts.
- Single-screen platform rounds with a boss that guards a side and summons minions.
- Any platform game whose enemies shoot, from straight rocks to lobbed bombs that leave fire behind.
Make it yours
Every number is data. A shot spec sets speed, size, aim, lift, gravity, life, range and the bounce, return, pass-through and burn flags. A chaser spec sets its movement, speed, acceleration, top speed, tiring time, size, deadliness and what a shot does to it. The behaviours read their numbers from each kind's parameters: how often and how far a hunter shoots, whether it dashes, how a boss chooses its side and how often it summons. You can also raise the cap on projectiles in flight.
Two quite different uses: a bubble game whose monsters walk, jump up through floors and throw rocks, with a chaser that lines up axis by axis and tires after thirty seconds; or a snowball game with a wandering pumpkin head that a shot throws elsewhere, homing ghosts and a boss that holds the right side and summons minions.
A quick look
Shots, a chaser and the behaviours registered with the enemy director:
const shots = new PH.EnemyShots(map);
shots.fire(enemyId, { kind: 'rock', speed: 100, w: 4, h: 4 }, x, y, facing);
const chasers = new PH.Chasers(map, game.kernel.rng.fork('chasers'));
chasers.add({ kind: 'baron', move: 'axis', speed: 24, accel: 9, max: 96, tire: 30 }, 128, 16);
const enemies = createEnemies({ world, kinds, behaviours: PH.hazardBehaviours({ shoot: (id, shot, at) => fire(id, shot, at), summon: (id, kind) => spawnNear(id, kind) }) });
Works with
platform-map— required: the map shots fly over and collide with.platform-enemies— the director the behaviours plug into.enemy-capture— builds its bubble and snowball monsters from these behaviours.
Good to know
- Projectiles are boxes moving in lines or arcs, tested against map cells, not against moving platforms.
- Chasers fly over the map and do not find paths.
- At most 128 projectiles are in flight by default; pass a larger limit when you create
EnemyShots. - The pack decides nothing about hits or deaths: your rules ask which shots and chasers overlap the player's box and decide what that means.






