← Back to the portfolio
How it works

Ultra Brawl

There's no game server. In an online match, two browsers run the same fight side by side and only swap what buttons each player is pressing.

Ultra Brawl is a platform fighter written in plain JavaScript and drawn on a canvas 60 times a second. Everything from the physics to the computer opponents runs on your own device.

Play Ultra Brawl

The big picture

The internet
Game filesServed by Cloudflare
Room codesA public PeerJS server introduces two players
Your browser
ControlsKeyboard, gamepad or touch
EnginePhysics, hits, knockback, 60 frames a second
Computer playersNine difficulty levels
Your friend's browser
Same engineRuns the identical fight
Their inputsSent straight to you every frame

Once two players are connected, their browsers talk directly. The room code server steps out of the way.

Step by step

  1. Pick fighters and a stage Your browser

    23 original fighters, each with their own attacks, specials, throws, costumes and a finishing move, across 8 stages. You can play alone against the computer, with a friend on the same keyboard, or online.

  2. Read the controls Your browser

    Each frame, the game reads the keyboard, any gamepads, or the on-screen buttons on a phone. Presses are buffered for a few frames, so an attack pressed slightly early still comes out.

  3. Run the physics Your browser

    The engine moves every fighter, checks which attacks connect, and works out damage and knockback. The numbers are tuned against measurements from Smash Ultimate, so a hit at 100% sends you about as far as you'd expect.

  4. Let the computer fight back Your browser

    Computer players choose moves from each attack's frame data: how fast it comes out and how far it reaches. Higher levels guard the edge, punish mistakes and recover back to the stage. A 506-game round robin checks they rarely fall off by themselves.

  5. Connect with a room code The internet

    For an online match, one player creates a room and shares a short code. PeerJS uses it to connect the two browsers directly over WebRTC, and both check they're running exactly the same version of the game.

  6. Swap inputs, not the game Both browsers

    Each frame, each browser sends only the buttons its player is pressing. Both wait for the other's input, then advance one frame. The fight is deterministic, so both screens stay identical, and they compare a fingerprint of the match every two seconds to catch any drift.

The pieces

Canvas and plain JavaScript

Every fighter, effect and menu is drawn by code. No game engine or framework.

It loads instantly in any browser, and I control every frame.

Combat engine

Hitboxes, knockback, hitstun, shields, ledges and throws, modelled on how Smash Ultimate works.

The feel of the hits is the whole game.

Computer opponents

Pick moves from frame data, guard the ledge and steer their recovery.

You can play alone and still get a real fight.

Lockstep netcode

Only inputs cross the internet, with a seeded random generator so both sides make the same "random" choices.

Tiny messages, and no server to pay for or run.

PeerJS and WebRTC

Connects two browsers directly using a short room code.

Online play without accounts or a game server.

Automated test suite

A headless browser plays scripted inputs and checks 56 rules, from double jumps to parries.

Tuning one move can't quietly break another.

Trade-offs I chose