cd /news/artificial-intelligence/one-typescript-codebase-two-engines-… · home › topics › artificial-intelligence › article
[ARTICLE · art-172107] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

One TypeScript Codebase, Two Engines: Building Hook Horizon with Claude Opus for the Epic AI MegaJam

A developer built Hook Horizon, a fishing-line platformer, in four days for the 2026 Epic AI MegaJam using Claude Opus in Claude Code, producing 243 commits and roughly 83,000 lines of TypeScript. The game runs the same engine-agnostic TypeScript core in both a three.js browser build and Unreal Engine 5.8 via the PuerTS V8 plugin, with a small ~2,400-line C++ shell and a generic scene mirror that syncs the shared scene graph into Unreal each frame. The architecture lets new features work in both engines without engine-specific rewrites.

recommendation

Keep engine-specific code behind narrow interfaces like SceneServices and SceneInput, and mirror a shared scene graph generically so new features work in every target without a port.

more in playbook: Designing agent systems
by read7 min views3 publishedNov 18, 2026

Hook Horizon is a fishing-line platformer I built in four days for the 2026 Epic AI MegaJam. The same game runs in a web browser and in Unreal Engine 5.8, and neither one is a port. Both run the same TypeScript.

I wrote it with Claude Opus, working in Claude Code. In those four days it came to 243 commits, about 83,000 lines of TypeScript and a small C++ shell inside Unreal. This post covers how the code is laid out, how TypeScript ends up running inside Unreal, the multiplayer server behind story co-op, Hook Brawl and Party, and how working with an AI pair changed what fits into a jam.

👉 Play it in your browser: hookhorizon.app

⭐ Rate the jam entry: itch.io/jam/2026-epic-ai-megajam/rate/5377909

The Epic AI MegaJam is Epic Games' game jam built around making games with AI tools. The theme and the deadline force you to decide fast, so I set two goals:

You play Bobber, a little fishing float carrying the last spark of the Horizon Lighthouse. A storm put the lighthouse out and the stars fell into the sea. The ghost of the lighthouse keeper guides you as you try to bring the light back.

The core verb is casting. You cast at anything on the horizon and reel it in through the depth layers into your play plane:

From that one mechanic came:

That's a lot for four days. Most of this post is about how the architecture made it possible.

The most important decision was the one I made first. Gameplay code never touches an engine.

src/core/          engine-agnostic gameplay: sim, controller, levels, campaign,
                   AI, versus, party, fishing, story, net, cosmetics
src/scene/         one engine-neutral scene graph
src/platform/web/  three.js renderer, DOM input/UI, WebAudio (built with Vite)
unreal/ts/         the Unreal platform layer, running in PuerTS
unreal/HookHorizon the UE 5.8 C++ shell (~2.4k lines)

src/core is pure simulation: physics, the fishing line, level logic, the campaign, the versus rules, the party board and the AI. It has no imports from three.js or Unreal. That also makes it testable and lets it run headless, which matters later for multiplayer.

src/scene is the scene graph. It uses three.js objects but only as plain data: positions, meshes, materials and hierarchy. Nothing in it draws anything.

A platform only has to implement two interfaces, SceneServices and SceneInput. Everything else is shared.

The web platform is the simple one. three.js renders the scene graph directly, DOM events become SceneInput, WebAudio plays sounds and Vite bundles it. This is where most iteration happened, because a browser reload takes seconds.

This is where it gets interesting. Unreal runs the game through PuerTS, a plugin that embeds V8 and lets TypeScript call Unreal's APIs.

esbuild bundles src/core, src/scene and unreal/ts into one HorizonMain.js in the Unreal project's Content/JavaScript folder. The C++ side is deliberately small, about 2,400 lines. It holds a mesh actor, a networking bridge, an updater and a canvas.

The key piece is the scene mirror (unreal/ts/mirror.ts). Every frame it walks the shared scene graph and keeps Unreal in sync:

ProceduralMeshComponent, then just transformed. M_HH) as parameters, so there are no per-object material assets to hand-author.(x, y, z) → (−z, x, y) × 100. Because the mirror is generic, a new enemy, level prop or boss works in Unreal as soon as it works in the browser. I never wrote "the Unreal version" of a feature.

Particles and sound use the same trick. Each is defined once, as data:

src/scene/particles.ts`` unreal/ts/fx.ts and a commandlet build real src/scene/sounds.ts`` unreal/ts/audio.ts builds voices with the So the Unreal build gets native Niagara and MetaSounds, and nobody hand-builds an effect in the editor.

Every online mode runs on one Colyseus server with four room types: brawl, coop, party and fishing. All of them reuse the same src/core code the clients run. Two players with the same room code always land in the same room, and an empty code drops you into matchmaking.

Inputs are tiny. Every input is a 7-number array: a sequence number, movement, ten button bits and aim. A protocol version check turns away an outdated client with "update required" instead of letting it desync.

The server runs the versus sim headless at 120 Hz and sends exact deltas 20 times a second, each carrying the last input it applied for every player. The client predicts everything: it restores the server snapshot, drops the inputs the server has acknowledged, and re-simulates the rest. Small errors are smoothed out visually; big ones snap. If a player's inputs stall, the server holds their buttons for a quarter of a second before letting go.

Quickplay searches for about 25 seconds, then server-side CPUs fill the empty seats. A human who joins late takes over a CPU's seat mid-match, keeping its score. If you drop out, you have 20 seconds to reconnect before a bot takes your seat.

The campaign's LevelSim was written for one player on one machine, not for netcode. Instead of rewriting it, the server runs the real LevelSim with every player in it, and a generic object-graph mirror diffs the whole sim into JSON deltas while keeping shared references intact. Game-feel effects are recorded on the server and replayed on each client, so hits and splashes still feel instant. Each client predicts its own float and eases toward the server's position.

The lobby is the world map itself. Everyone walks their own token, anyone can propose a level, and the crew votes on a ten-second countdown. Players can drop in mid-level, and the team shares hearts and checkpoints.

The server owns the board: turns, rolls, items, and the CPU players that fill empty seats or replace someone who leaves. When a minigame starts, the server picks a random seed and every client builds the same minigame from it. From there it runs on the same predicted, acknowledged-input model as Hook Brawl.

For Couch Party, the TV opens a private room and shows a QR code. Phones open a small controller page and join that room as pads. They draw nothing and simulate nothing; they just stream inputs. One message moves every phone from Party to Hook Brawl to story co-op, keeping the same room code. Phones get three minutes to reconnect, because screens lock.

The lagoon is lighter. Each player fishes locally, and the server owns the shared vibe: the time of day and the DJ set.

The server ships as a Docker image and redeploys automatically whenever server code or shared game code changes. Profiles and leaderboards live in Postgres. On a benchmark using a single CPU core, it handled 720 co-op players across 180 rooms.

On the client side, browsers already have WebSocket and fetch. PuerTS inside Unreal doesn't, so a small C++ bridge (HHNet) provides both. With that in place, the same @colyseus/sdk client runs unchanged inside Unreal. There is no second network implementation and no protocol drift between the two builds.

There's a nice bonus to having the game logic in JavaScript: you can update it without shipping a new binary.

The Unreal build checks an update endpoint for ed25519-signed JS bundles and applies them on the next launch. Only JS and data paks are ever downloaded, never native code. If an update crashes on boot, a guard falls back to the JS that shipped with the build. During a jam, that means a balance tweak or bug fix reaches players in minutes.

Here's the honest version of what building a game with Claude Opus in Claude Code was like.

The numbers: 243 commits over four days, from the first browser prototype on November 12 to a packaged, signed Unreal build on November 15. That's roughly 83k lines of TypeScript. The busiest day had 126 commits.

What worked:

What still needed a human:

The code wasn't the only AI-assisted part:

The jam's web export can't run PuerTS, so the official MegaJam entry is the packaged Unreal build. The browser version at hookhorizon.app runs the same game code, so it's the quickest way to try it.

More platforms are on the roadmap. The platform contract is small, and the Unreal layer already handles touch input. The shared-core approach means each new target is a platform layer, not a rewrite.

If you made it this far, I'd love for you to try Hook Horizon and rate it for the jam:

Questions about the PuerTS setup, the scene mirror, or building with Claude Opus? Ask in the comments. I'm happy to go deeper on any of it.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @claude opus 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/one-typescript-codeb…] indexed:0 read:7min 2026-11-18 · —