Inside Limn Engine: How a 360-Level Raycast FPS Runs in a Single HTML File
When I set out to build NULLPOINT, a retro-style browser FPS with 12 seasons and 360 procedurally generated levels, I had one strict rule: no build tools, no npm, and no complex bundlers. Everything had to run from a single HTML file.

To pull this off, I used Limn Engine (epic.js).
If you look at Limn, you won't find a physics engine, a 3D renderer, or a massive component library. What you will find is a minimalist HTML5 Canvas wrapper built on a single philosophy: common outcomes should be functions. It handles the boring scaffolding—the render loop, input capture, and camera—so you can focus on making the game.
Here is a look under the hood at how Limn works, and how I stretched a 2D framework to build a 360-level first-person shooter.
The Core Architecture: Display and Component
Limn uses a classic, two-part architecture:
-
Display: The main controller. It creates the<canvas>, manages the game loop, handles the camera, and tracks keyboard/mouse input. -
Component: The base class for game objects. It handles drawing rectangles, text, and images, and includes basic physics (gravity, bouncing, bounding).
But the most important feature of Limn is its dual-renderer system located inside the ani() loop.
The Performance Secret: The "Fake" Canvas
Limn uses a hidden, offscreen canvas (appropriately named fake) to cache static elements. When the game starts, display.once is set to true. The engine renders all static components—like tilemaps, backgrounds, and UI frames—to this hidden fake canvas exactly once.
Then, every single frame, the engine simply uses drawImage to paint that cached offscreen canvas onto the visible display canvas.
This is what takes a basic 2D game from 4 FPS to a solid 60 FPS on low-end hardware. Only dynamic elements (like the player, enemies, and bullets) are processed and drawn in real-time on top of that cached background.
How NULLPOINT Bends the Engine
Here is the twist: NULLPOINT ignores 90% of Limn's API.
Because Limn is a 2D engine, it has built-in systems for TileMap, ParticleSystem, and AnimatedSprite. NULLPOINT uses none of them. Instead, it treats Limn as a high-performance bootstrapper.
1. The Bootstrap
NULLPOINT initializes Limn in just six lines of code:
const display = new Display();
display.perform(); // Swaps the engine to requestAnimationFrame
display.start(800, 600); // Sets the internal 800x600 resolution
display.backgroundColor('#000');
display.scene = 0;
The perform() method is a critical prototype patch in epic.js. It ditches the default setInterval loop in favor of a high-performance requestAnimationFrame loop, which provides accurate deltaTime and FPS tracking.
2. The Game Loop
Limn expects a global update() function to exist. NULLPOINT defines this function inside a <script type="text/plain"> tag (to handle Playgama cloud saves before the game starts), and then injects it into the DOM. Limn's loop calls update(dt) automatically, passing in the delta time.
3. Ignoring the Input System
Limn provides basic keyboard and mouse state tracking. NULLPOINT ignores it. Because an FPS needs a virtual joystick, a dedicated fire button, and gesture detection, I attached my own custom touch and mouse listeners directly to display.canvas.
4. Custom Entities
Limn wants you to inherit from Component. NULLPOINT doesn't. Enemies, bullets, and blood particles are plain JavaScript objects. The raycasting math (DDA algorithm) is written from scratch. I simply use the raw display.context (the 2D Context API) to draw vertical slices for walls and sprites for enemies.
What Limn Actually Gives You for Free
Even though NULLPOINT is mostly custom code, Limn saves hours of boilerplate:
- The
display.camera: It automatically tracks world position. I usedisplay.camera.shake()for screen shake when firing heavy weapons. - The Draw Loop: I never have to write
requestAnimationFramemyself. - The Canvas Context: Limn creates the canvas, handles the DOM insertion, and gives me access to the context.
One thing I completely ignored was Limn's built-in SoundManager. For a single-file game, loading external .mp3 files wasn't an option. NULLPOINT uses the raw Web Audio API to synthesize all its sound effects and music procedurally on the fly.
A Minimal Limn Setup
If you want to try Limn for yourself, here is the exact minimal setup that powers NULLPOINT:
<!DOCTYPE html>
<html>
<head>
<script src="epic.js"></script>
</head>
<body style="margin: 0; display: flex; justify-content: center;">
<script>
// 1. Initialize Limn
const display = new Display();
display.perform();
display.start(800, 600);
display.backgroundColor('#000');
display.scene = 0;
// 2. Define the game loop
function update(dt) {
// The raycasting engine runs here
const ctx = display.context;
// Draw a simple crosshair
ctx.strokeStyle = '#fff';
ctx.beginPath();
ctx.moveTo(400, 300); ctx.lineTo(400, 310);
ctx.moveTo(400, 300); ctx.lineTo(410, 300);
ctx.stroke();
}
</script>
</body>
</html>
The Takeaway
Limn is a blank canvas, not a genre-specific engine. It provides the canvas, the camera, and the loop, but it leaves the actual game mechanics up to you.
By ignoring the built-in Component system and writing custom raycasting logic, I was able to maintain 60 FPS on mobile devices while running a massive 3D-style game in a single HTML file. The beauty of Limn is its restraint—it gives you just enough to start, and gets out of your way when you need to build something massive.
You can play NULLPOINT now over at Playgama.
Top comments (2)
The fake offscreen canvas detail really stuck with me — caching the static tilemaps and UI once and then just drawImage-ing them each frame to go from 4 FPS to 60 on low-end hardware is such a clean trade-off. I also liked the honesty about ignoring 90% of Limn's API: no TileMap, ParticleSystem or AnimatedSprite, just using it as a bootstrapper and writing the DDA raycasting with enemies, bullets and blood particles as plain JavaScript objects. Swapping the setInterval loop for requestAnimationFrame with perform() and synthesising all the sound with the Web Audio API instead of loading mp3s fits the single-file rule nicely too. With 360 procedurally generated levels in one HTML file, how do you keep the generation varied without the file getting out of hand — do you seed each level, or generate it on the fly when the player enters it?
Thanks! The offscreen canvas trick really is the unsung hero of the whole project — it's such a simple concept, but it completely changes the performance ceiling on mobile.
To answer your question about level generation: it's generated on the fly, but deterministically. There are no pre-baked level files. The entire 360-level campaign is created by a single generateMap() function that takes two arguments: seasonIdx and levelIdx.
The magic is in the seeding. I use a tiny mulberry32 PRNG. Every level's seed is just:
Because the seed is derived from the level's index in the campaign (not the player's session), Level 5 of Season 3 will always look exactly the same, whether you play it today, tomorrow, or on a different device. The map itself is never stored — only the 360 boolean flags of which levels you've completed. The file stays tiny because the math is the content.
How I keep the generation varied:
Inside generateMap(), the seed controls three things. First, map size scales with difficulty: w = 16 + Math.floor(diff * 12) (16×16 at the start, up to 28×28 at the end). Second, the map is carved by spawning 6 + Math.floor(diff * 24) rectangular clusters of wall types, each with randomized center, size, and shape. Higher difficulty means more blobs and tighter corridors. Third, 4 + Math.floor(diff * 20) scattered pillars break up open areas.
Because the PRNG drives every random call, the same seed produces the same map every time, but different levels feel genuinely different because the difficulty ramp and the seed interact. Early levels are sparse and open; late-game levels feel like mazes.
The connectivity problem: Random blobs have a nasty side effect — they can seal off pockets of the map. So after generation, generateMap() runs a flood-fill to find the largest connected open region. Every other disconnected pocket gets sealed off with solid walls. The player and every enemy always share the same reachable space.
Enemy spawn layout: Enemy positions aren't re-rolled at runtime. They're also generated during generateMap() using the same seed and stored on the map object as enemySpots. When a wave spawns, it pulls from that array first, and only falls back to findFreeSpot() (which runs a wall check at spawn time) when the wave has more enemies than pre-planned spots.
The trade-off is that the file remains small (no level data at all), but the first time you enter a level, the map is generated in a few milliseconds. It's a nice middle ground between "generate once and store" and "generate every frame."