About the project

Inspiration

The best Twitch moments happen when chat stops feeling like a sidebar and starts shaping what happens on screen.

We wanted to take that one step further. What if every viewer could enter the game, fight beside the streamer, and leave the run with a story of their own? No extra account. No download. Just type !join and become part of the party.

That idea became Twitch Survivors: a fantasy survival game where the streamer leads and the audience becomes the team.

What it does

The streamer controls one fantasy survivor with a simple Blade Arc attack. Viewers type !join in Twitch chat and enter the run as named autonomous companions.

Each viewer receives one of twelve fantasy combat roles. They might launch firebolts, orbit the host with runeblades, chain lightning through a group, plant mines, channel a beam, or call down meteors. Companions follow the streamer, find targets, and fight on their own, so viewers can join from any device without learning another control scheme.

The streamer chooses how the crowd enters:

  • Level recruitment turns each level gained into one new viewer companion.
  • Join all admits the waiting audience immediately and lets later viewers enter as soon as they join.

Every attack keeps its viewer owner. Pause the run or reach the results screen to see each participant's assigned skill, total damage, active-time DPS, and kills. Viewer roles and statistics reset each run, while the streamer's progression stays saved.

How it works

1. From Twitch chat to the game world

The streamer selects Connect with Twitch and authorizes the game through Twitch OAuth with the chat:read scope. The validated Twitch account provides the channel identity, and the game connects to that channel's chat over Twitch IRC.

When a viewer sends an exact !join message, the Twitch provider converts it into a normalized ViewerJoin event. Stable Twitch identity prevents duplicate entries, even if chat reconnects or delivers the same message again.

2. From viewer to fantasy companion

The audience session places each join in a first-in, first-out queue. The recruitment controller applies the streamer's chosen mode, and the role system combines the run identity with the viewer identity to assign one of twelve skills. The result stays fixed during that run, so duplicate joins cannot reroll a role.

Once recruited, the viewer appears as a named companion. Companion AI handles following, target selection, attack range, cooldowns, and returning to the group if the host moves too far away.

3. From attack to contribution

Every projectile and direct attack carries an explicit viewer owner. That ownership survives projectile pooling, chained hits, delayed meteors, mines, beams, and collision handling. Damage credit is limited to health actually removed from an enemy, and a kill can only be counted once.

This makes the results meaningful. When a viewer sees that their Frost Channeler dealt 2,400 damage and landed the final kill, they know their character changed the run.

4. The same loop without a live stream

A preview-only Local Test mode creates simulated viewers, but it does not use a separate gameplay path. Twitch and Local Test both emit the same event and use the same queue, duplicate protection, recruitment logic, companion system, and contribution tracker.

That let us repeat queue, restart, and load tests without waiting for a live broadcast. Production builds hide the mock controls and expose Twitch as the audience source.

Our biggest engineering challenge

The hardest problem was keeping viewer ownership intact through combat.

A single attack can leave the companion, enter a reusable projectile pool, hit several enemies, trigger a chained effect, and resolve after the original cast has finished. If the owner disappears anywhere in that path, the streamer receives the credit or a kill is counted twice. We added an explicit combat-owner context and carried it through every release viewer attack.

Crowds created another problem. If twenty companions with the same role start from the same clock, they can all attack on one frame. We anchored cooldowns to recruitment time and added a stable phase for each viewer. Local capacity checks held 60 FPS with 10, 20, and 50 companions. Fifty remained mechanically stable but became hard to read, so the MVP supports 20 active companions instead of making an unlimited-crowd promise.

Run cleanup mattered just as much as combat. Starting again must clear viewers, roles, timers, projectiles, listeners, and contribution state while keeping streamer progression. We tested repeated joins, pauses, deaths, reconnects, and restarts to catch state leaking from one run into the next.

How we used OpenAI Codex as a game engineer and tester

Codex worked with us across the whole build. It mapped the Canvas game architecture, traced combat ownership, designed the shared audience boundary, implemented Twitch OAuth and IRC input, built recruitment and companion roles, and reworked the audience-first interface.

The most useful part was watching Codex operate the game instead of stopping after code generation. It launched real browser sessions, joined simulated viewers, switched recruitment modes, inspected contribution data, exercised all twelve attack families, measured crowd performance, and checked the desktop and narrow layouts. When a pull-request review found that late Join all recruits could attack in sync, Codex traced the timing bug to a zero-based cooldown and moved each schedule to recruitment time.

Codex also helped replace the old presentation with a fantasy roster, new terrain palettes, code-drawn attack icons, a Twitch-purple interface, and seven original Web Audio themes. It created release checks for prohibited assets and remote services, kept the product specification and task list current, and built the two-minute demo in Remotion.

The current validation suite has 44 passing tests, plus production build, browser, asset-audit, OAuth, and capacity checks. Codex did not just help us write features. It helped us prove that the viewer loop survives real gameplay conditions.

What we learned

Twitch input works best as a replaceable transport rather than a gameplay dependency. Once Twitch and local simulation produced the same event, we could test the full audience loop repeatedly without changing how live viewers behave.

We also learned that contribution statistics are part of the game. A name above a companion creates recognition, but damage, DPS, and kills create a story the streamer and chat can talk about after the run.

Finally, crowd size is a design problem before it is a performance problem. Fifty companions can run smoothly and still produce a worse stream because names and effects overlap. A readable party of twenty is more valuable than a larger number that viewers cannot follow.

What we're proud of and what's next

We're proud that Twitch Survivors keeps the streamer at the center while giving chat a visible role in every fight. The streamer still moves, survives, and makes the key decisions. The audience becomes the party that can save the run.

Next we want to tune bosses around audience size, add more viewer roles, and explore streamer-controlled crowd presentation for channels that exceed the initial 20-companion limit. The shared audience contract gives us room to add channel events and new companion behaviors without rebuilding the core loop.

Built With

Share this project:

Updates

Submission history