Inside Petal.
The world is a 2D map with height, turned into a first-person view by an original software renderer. It follows the broad techniques that made early sector engines work.
A world made of sectors
Convex polygons describe the world in XY. Every sector has a floor height, ceiling height, textures, and light level. Boundary lines hold references to sectors on either side. A line with only one side is solid; a line between two sectors is a portal whose opening depends on both floor and ceiling heights. The map contains steps, indoor ceilings, an opening gate, and a moving lift. There are no stacked rooms or sloping surfaces.
Find the near geometry first
A binary space partition tree divides the map along boundary lines. Polygons that cross a partition are split. Leaves keep their sector and clipped real wall segments; the artificial split edges stay invisible. At each frame, the camera's side determines which child to visit first. Bounding boxes and covered screen columns let the renderer skip geometry that cannot be seen.
Walls in columns, floors in spans
Visible wall segments are clipped against the near plane and projected onto the screen. Reciprocal-depth interpolation determines the correct texture coordinate for every vertical column. The renderer draws a solid wall, or upper/lower pieces around a portal. Each screen column keeps its remaining top/bottom opening, so farther walls are clipped progressively without a per-pixel depth buffer.
Floor and ceiling regions are grouped by height, texture, and light into visplanes. Their visible column ranges become horizontal spans. For a given screen row and plane height, depth is constant, so world texture coordinates advance by a simple step across the span. Shared outdoor sky ceilings form one backdrop; a change in their nominal height does not leave an upper wall floating in the sky.
Sprites, light, and the finished frame
Characters, pickups, and projectiles are camera-facing billboards. They sort from far to near, use generated alpha, and clip against closer wall and plane silhouettes saved per column. Sixteen precomputed color tables combine sector brightness with modest distance shading. A typed RGBA buffer holds the software frame; Canvas 2D displays it. The held weapon is another generated raster sprite drawn in the foreground.
Moving light and directional characters
Colored local lights shade walls, floors, ceilings and characters. Directional sprite views follow the viewer position relative to actor heading. Simulation ticks drive movement, animation, flicker and replay.
One tick at a time
The world updates 35 times per second regardless of display refresh. Keyboard, mouse, and touch input becomes a sequence of movement, turn, fire, and use commands. Acceleration, friction, gravity, circle collision, sliding, and headroom/step limits determine movement. A block grid narrows wall candidates and accelerates visibility and projectile traces. Changing sector heights animates the gate and lift while their XY geometry stays fixed.
Each adventure records commands for deterministic replay. The retained samples have complete route and replay checks.
Simple browser adaptations
The engine uses native JavaScript numbers, typed RGBA arrays, dynamic storage, and browser input APIs. These keep it small without emulating older hardware constraints. It is a new engine, not a source-code port or a WAD-compatible implementation. This sample has horizontal turning, billboard sprites, and a single-player world; it does not include networking, slopes, free vertical look, or a triangle/mesh renderer.
Generated artwork
Original generated atlases, prompts and manifests are preserved for both adventures. Runtime images are resized WebP derivatives. Interface text and controls use HTML and CSS.
Neon Breach: a city under siege
Play Neon Breach to reclaim three relays across neon streets, indoor arcades, a sunken canal and elevated rooftops. Its 33 sectors span 4.5 meters of elevation. Cyan and magenta lights, flicker, pulses, strobes and projectile lights set a different mood from the worlds.
Charging sentries and ranged drones use configurable pursuit and attack windups. The rail pistol fires instant rays; the plasma scattergun fires three swept bolts. Shared engine modules provide health and shields, per-weapon ammo and cooldowns, target collision and pickups. The browser runtime supports game over, restart and deterministic playback of a lost run. White medical canisters, cyan shield batteries and amber ammunition crates replenish your resources. All city artwork was newly generated.
A kingdom beneath the leaves
The Verdant Crown spans 516 × 714 metres of winding valleys, mountain switchbacks and descending caves, built from 3,303 convex sectors. Its 575 scenery placements cluster at terrain edges while the main trails stay clear. Seven creature types, wildlife, sages, merchants and fairies inhabit six surface regions and three underground regions. Recover three ancient sigils and awaken the meadow shrine. Four weapons, treasure, healing springs, a sealed gate and a lift to a raised treasury gallery give the journey its own rules. The mountain lookout stands 52 metres above the valley; drag vertically or use Page Up/Down to look over it.
Four new imagegen atlases and a daylight panorama add 65 varied sprites, textures and sky files to the original artwork. Cave entrances and ruins are actual geometry; arrows are single shafts and defeated creatures retain their adult scale. Four standalone projectile images add a hand-free bomb, arrow rear view and radial magic orbs. Arrows follow their travel direction; fire and magic light the scenery as they pass. Spiders stay small when defeated and ghosts vaporize. Footsteps are softer and four times less frequent. Round braziers switch between matching lit/unlit art and visibly darken their surroundings. An original 96-second score, A Crown Beneath the Leaves, combines modal melody, harp, strings, horns and drums; cave exploration and nearby danger change the arrangement. Wind, birds, water, fire, footsteps and combat effects have positional sound. Press Tab or M for the field journal, use 1–4 to select weapons, Ctrl to attack, Enter to interact, and Space to jump. Touch controls support the same adventure.
The engine supplies concave-outline decomposition, curved terrain authoring, independent sprite widths, camera pitch, axial projection, opacity sequences, attached entity lights and batched fixed-tick playback, alongside spatial queries for dense scenery, clearance-aware civilian patrols, occluded radial damage and explicit projectile-expiry callbacks. World population, quest rules, instrument choices and creature parameters remain sample data. Full desktop and touch journeys verify victory, loss, replay, gate/lift behavior, independent music/effects and real audible audio output.
A foundation for another game
Sound is optional browser presentation driven by simulation events. Positioned cues follow listener direction and distance, and walls muffle them. Ambient sources and distance-driven footsteps use the same world queries. Music has its own volume and transport: reusable scores describe instruments, notes and layers, while the browser player schedules their rhythm on the audio clock. Each game supplies its composition and mixing rules. Neon Breach demonstrates this with Night Circuit, an original 80-second track; Pause provides independent effects and music controls. Pause, restart, outcomes and replay clean up audio resources.
Neon Breach now includes Space jumping and a touch Jump button, with a channel crossing and raised battery cache. Defeated sentries and drones collapse into permanent wreckage. The core supports opt-in jump/air control and reusable tick-based sprite sequences. A collision overlap after dropping beside a raised ledge can now retreat safely. If you get stuck, press F8 or choose Pause → Copy debug state and paste the report into chat; selectable text is available when the browser cannot copy automatically.
Weapon kick, recovery and muzzle flashes use reusable numeric pose timelines and attached foreground artwork. The engine supports configurable animation values, rotation pivots and opacity layers; the sample supplies its two weapon curves and artwork. Animation follows the simulation clock through pause and replay. Shared input bindings accept modifier constraints: Neon Breach uses Ctrl to fire, Enter to interact, and Alt with left/right arrows to strafe. Other games can configure the same capabilities for their own controls and effects.
The engine now separates geometry, world queries, movement, timing, materials and software rendering from game rules and browser presentation. Maps and triggers are validated data. The renderer knows no garden asset names; texture scales, foreground placement and the sunny lighting preset belong to the game. Reused clipping, plane and projection buffers avoid repeated frame allocation, and paused screens have no continuing render loop.
Regression checks cover map validation, sector lookup, wall and vertical ray hits, small-body collision, shared-edge junctions, sprite floor/ceiling clipping, independent visibility references, replay, pause modes and browser back navigation. Both retained games have desktop and mobile browser playthrough checks. Mobile checks use Chromium touch emulation; they do not measure physical phone performance.
Choose an adventure
Neon Breach and The Verdant Crown each provide desktop and touch controls, pause, restart and replay.
Read the original code: public engine API, renderer, world queries, kingdom data, kingdom rules, browser runtime, music scores, music player, second game. Choose a world.