@magmacrunch/adenosine-rpg
v0.2.3
Published
Lightweight 2D tile-based RPG engine
Maintainers
Readme
@magmacrunch/adenosine-rpg
Lightweight 2D tile-based RPG engine — game loop, movement, camera, collision, dialogue, inventory and entities. No runtime dependencies.
npm install @magmacrunch/adenosine-rpgUse
import {
initCanvas, player, createGameLoop, initInput,
updateCamera, renderWorld, setCurrentMap, setMap,
setGameStarted, handleMovement,
} from '@magmacrunch/adenosine-rpg';
initCanvas(document.getElementById('gameCanvas'));
player.x = 10;
player.y = 10;
const map = [
[2,2,2,2,2],
[2,0,0,0,2],
[2,0,0,0,2],
[2,2,2,2,2],
];
setCurrentMap('level1');
setMap(map);
initInput();
const loop = createGameLoop({
update: (dt) => {
updateCamera({ target: player, tileSize: 16, mapWidth: 5, mapHeight: 4 });
handleMovement(player, { speed: 0.4, dt, collisionOpts: { map, solidTiles: [2] } });
},
render: () => renderWorld({
map, tileSize: 16,
renderTile: (ctx, x, y, id) => {
ctx.fillStyle = { 0: '#7cb342', 2: '#5d4037' }[id] || '#000';
ctx.fillRect(x, y, 16, 16);
},
layers: [{ sortY: player.y, render: (ctx) => { /* draw player */ } }],
}),
fps: 30,
});
setGameStarted(true);
loop.start();API.md documents every export, with parameters and return shapes.
Without a bundler
Straight from a CDN — no npm, no build step:
<script src="https://cdn.jsdelivr.net/npm/@magmacrunch/[email protected]/dist/index.global.js"></script>The IIFE build exposes window.AdRPG. The version is pinned to a minor here on purpose:
an unpinned URL follows latest and will cross a major without warning.
Installed from npm instead, the same file is dist/index.global.js.
Note
State lives in module-level singletons, so one page runs one RPG. That suits the game it was extracted from; a second concurrent instance would need the state module reworked.
Module format
ESM only. The exports map declares no require condition, so this cannot be
require()d from CommonJS — use import, or the IIFE build above.
License
Apache-2.0 — Copyright 2026 Magma Crunch Media.
Part of adenosine, a collection
of lightweight web game engines by magmacrunch media.
Keep the NOTICE file with any copy you distribute.
