wololo中文

What makes a hit land in Meme Brawl

Reading Meme Brawl's source to see how hit-stop, screen shake, juggle decay, combo buffers, attack tokens and boss stagger make its hits feel good.

Meme Brawl is a pixel beat 'em up for one player, or two sharing a computer. It has no design document, so we read the source to find out which numbers make a punch feel like a punch. The game runs at a fixed 60 updates per second, so a "frame" below is 1/60 of a second.

What happens in a single hit

Every hit that lands calls one function, hitFx. It sprays sparks (5 for light hits, 8 for anything heavier), draws a 6-frame cross-shaped flash that turns from white to yellow, plays a sound and sets hit-stop, while the victim's silhouette blinks white for 10 frames.

Hit-stop scales with the move: by default 2 frames for light hits and 4 for heavier ones, 8 or 9 for combo finishers, and 10 for Chad's ground-slam special. The freeze is global, so the whole world stops:

if (this.cutin) {
  if (++this.cutin.t >= this.cutin.dur) this.cutin = null;
  return;
}
if (this.hitstop > 0) {
  this.hitstop--;
  return;
}
if (this.slow > 0 && --this.slow % 3) return;

Screen shake decays just above this block, before the early return, so a frozen frame keeps shaking instead of becoming a still image. Only non-light hits shake the camera: 4 pixels for knockdowns and launches, 2 for other heavy hits, none for jabs. Sound is layered too: a whoosh when a swing starts, an impact only on contact, all synthesized with WebAudio as the game runs.

Some trade-offs hide in the details. Hit-stop takes the larger value rather than adding up, so catching three enemies freezes no longer than catching one; our guess is that this keeps crowd fights moving. Projectiles skip hit-stop, which matters for a Boba Minigun firing every 6 frames. And because attack is read only on the frame the key goes down, while the freeze pauses the player's update too, a press made during a freeze is never seen.

There are no damage numbers. Captions do that job: YEET, YES or POP on finishers, a 22% chance of a word like BAM or BRUH on other heavy hits, and titles from the hit counter at 6, 12, 20, 30 and 50.

Combo strings and their timing windows

Doge's string has four hits (jab, jab, hook, spinning kick), Chad's three (jab, straight, uppercut) and Pop Cat's five. A jab is 14 frames long, active on frames 3 to 5 and cancellable from frame 6.

Press attack once the active frames have started and the press is buffered; at the cancel frame the next move begins at once. Earlier presses are ignored. Miss that, and you still have 24 frames after the move ends. Finishers have no cancel frame, so the string restarts after one.

With buffered jabs a hit lands about every 6 frames, while a light hit stuns an enemy for 16, so good timing leaves no gap to strike back. The hook, straight and spinning kick also carry the fighter forward 1 to 1.4 pixels per frame, which looks like a way to close the gap knockback opens. Whiffs advance the string too.

A dash is a double-tap within 15 frames. Attacking mid-dash with empty hands gives a dash attack with a long active window (Doge's headbutt: frames 2 to 14) while the fighter moves 3 to 3.8 pixels per frame, a hitbox that travels. Jump attacks come once per jump, stay active until landing and knock ordinary enemies down.

Knockback and juggles: enemies as weapons

Light and heavy hits only cause hitstun; "down" and "launch" hits send enemies flying. Chad's uppercut launches at an upward speed of 6.2, about 41 frames of airtime. An airborne enemy can still be hit, but each extra hit lifts it less:

if (this.state === 'fall') {
  this.vz = Math.max(this.vz, 2.4 - this.juggle * 0.3);
  this.vx = dir * 1.2;
  this.juggle++;
  break;
}

The launch counts as one, so the first follow-up adds 2.1, then 1.8, then 1.5, and the eighth air hit adds nothing. Past a count of 4, anything that knocks the enemy upward keeps only 45% of its force. There is no hard cap; the juggle just winds down. A fast landing bounces once for one more chance, but an enemy on the floor can't be hit, and it stands up with 18 frames of invulnerability.

Doge's spinning kick has a kind of its own, "yeet". For up to 40 frames, while still flying sideways at 2 pixels per frame or more, the kicked enemy deals 10 base damage to any enemy it hits and knocks it down, and each collision feeds the player's hit counter and meter.

Taking turns, and invulnerability

To stop a crowd from swarming, an enemy needs a token before stepping in to swing:

takeToken() {
  if (this.token) return true;
  if (world.tokens.size >= Game.diff.atk + (world.players.length > 1 ? 1 : 0)) return false;
  world.tokens.add(this);
  this.token = true;
  return true;
}

Easy allows 2 attackers at once, Normal 3 and Hell 4, plus one with a second player. The rest hang back 52 to 82 pixels away at 60% speed. Tokens return when an attack ends, when the holder is hit or when it dies, so interrupting a wind-up in effect passes the turn on. Only melee needs a token; the Keyboard Warrior's flying letters and Dat Boi's charge don't queue, so the pressure stays, just not all at arm's length.

Wind-ups show a blinking red exclamation mark: 22 frames for an NPC, 14 for a Troll, and shorter on harder settings (an NPC's drops to 19 on Hell).

On the player's side, a fourth hit in a row, each within 70 frames of the last, knocks you down instead of keeping you stunlocked, though you drop your weapon. Standing up gives 50 frames of invulnerability, against an enemy's 18. Your hitstun is 14 frames for light hits and 20 for heavy ones, 2 shorter than an enemy's. Respawns give 160 frames, and nothing can hit you during a special.

Bosses: no flinching, but stagger builds up

Bosses don't flinch. Each hit fills a stagger value instead, with knockdown and launch hits counting 1.5 times, and at 15% of max HP the boss staggers and its current move is cancelled. Stagger drains 0.05 per frame, so damage has to come in bursts. Solo on Normal, the Troll King's 620 HP sets the threshold at 93.

HP thresholds queue set moves such as summons or a second phase (for the Troll King: faster movement, shorter wind-ups, a double dash). Telegraphs are louder: the exclamation mark grows from font size 9 to 16, a flashing ring marks the floor under a leaping boss, and stock-chart lanes, coin drops and fire pillars give at least 40 frames of warning. When a boss falls, the world runs one step in three for 120 frames, two seconds of slow motion, and every other enemy on screen is cleared.

Specials and weapons: two resources that run out

The meme meter holds 200 and a special costs 100, so you can bank two. Hits add 3.6 (2.4 on bosses), finishing off an enemy adds 5 (60 for a boss), and taking damage adds 0.6 per point. Short on meter but above 15% HP, a special costs 10% of max HP instead, so it can never kill you. Specials freeze the world for a 34-frame cut-in, or 16 frames when paid for in HP.

A melee weapon loses one durability per swing that connects, however many enemies it hits; we read that as a nudge to swing into groups. Its three-swing string ends with 1.4 times damage and an 8-frame freeze. Getting knocked down drops it, remaining uses intact, for 10 seconds, and throwing it always deals 14 base damage, whatever durability is left.

Two players and a phone

A second player can join at any time with the comma key, dropping in with 120 frames of invulnerability. There is no friendly fire, boss HP is multiplied by 1.45, the token cap rises by one, and the camera won't scroll the trailing player off screen.

On phones the joystick is digital: past 30% of its radius it registers a direction, so a small push moves you as fast as a full one. From the code, dashing uses the same double-tap check, which on the stick means flicking it twice. Touch drives only player 1, and switching to another app pauses the game. You can try all of this here.

Design notes

  • Designing Inkloop: loops, cuts and seals

    Why the only way to die in Inkloop is to be enclosed, why cutting never kills, how the bots are tuned to feel human, and what changed after simulation.

  • Game sound with no audio files

    Inkloop, Meme Brawl and Runekeep ship no audio files. Every effect and song is synthesized live with the Web Audio API. Here is how, and what it costs.

  • How Runekeep turns typing practice into tower defence

    Inside Runekeep's code: how targets lock, how difficulty ramps, why Letter Trial drills one row at a time, and how WPM and accuracy are counted.