The gap
In most strategy games the enemies follow a fixed path and the only choice is what to build; enemies that reason about the map take a working pathfinding core.
Game templates
The complete source of Beamhold, a light-and-shadow strategy game: one beam bent into walls that steer shadows through a cost field until dawn, over four fields.
Coming soon
Source code for developers, not the game itself. Not published on its store yet, so there is no buy or download link. PN Scripts does not take payment for it here.
The gap
In most strategy games the enemies follow a fixed path and the only choice is what to build; enemies that reason about the map take a working pathfinding core.
What it is
This template ships a tested cost-field core: change the light and every shadow re-plans its road live, with a road preview the player can read.
How you use it
Unzip, serve the folder and open index.html, then edit game.js; npm test runs the unit tests and plays it again in headless Chrome.
Source code of a real, playable game to reskin and learn from, with a smoke test whose bot plays it.
Use it when
Built for
lightOf() sums the beam and lantern glow per cell; dijkstra() turns it into a cost field per kind of shadow, and nextStep() walks it one cell at a time.
A field is seven strings of rocks, rift, gate and crystal plus a beam direction, so a new field takes a few lines.
Plain JavaScript and Canvas 2D; open index.html through any static server and edit game.js.
Node unit tests cover the beam, the roads, burning, dawn, pieces and saves; headless Chrome tests (Playwright) load the game, play it with keys and taps at desktop and phone sizes, and let the built-in bot play a run to its result screen.
1 of 3
| Platform or runtime | Supported versions | Tested up to |
|---|---|---|
| Node.js | 22.12 or newer | Not stated |
The template is finished and tested. It is not on sale yet; this page will say where to get it when it is.
Coming soon
Source code for developers, not the game itself. Not published on its store yet, so there is no buy or download link. PN Scripts does not take payment for it here.