Slap Chub build log - WordPad
✕
C:\ar9av\builds\SLAPCHUB.TXT
  1. Desktop
  2. Build Log
  3. Games

Build log · Games

How I built Slap Chub

Slap, grab, throw and pinch a soft-body chub built from a 40-point Verlet ring

Screenshot of Slap Chub running in the portfolio
Slap Chub, running on the desktop. Open it yourself →

1.Why I built it

Slap Chub is a toy about one thing: how a soft body wobbles when you hit it. I wanted the jiggle to come from real physics I wrote by hand, with every sound synthesized live instead of played from samples.

It started as slapping only, with hand prints, combos, a dizzy state and a jiggle-o-meter. Later the same day I added grabbing and throwing, and then pinching the cheeks.

2.How it works

A ring of Verlet points with three constraints

The body is 40 points in a pear-shaped ring, integrated with Verlet: each point stores its current and previous position, and velocity is the difference between them. The sim runs 2 substeps per 60 Hz frame, and each substep does 4 constraint iterations. Velocity is clamped to 22 px per substep so a hard hit can't blow up the solver.

Three constraints hold it together. Neighbour springs act as skin. A pressure constraint compares the ring's current area (shoelace formula) to its rest area, divides the difference by the perimeter, and pushes every point out along its normal by that amount, so the body behaves as if it is full of pudding. Soft shape matching finds the best-fit rotation of the rest pose with an atan2 over the points and pulls each point a small fraction (shapeK, 0.016 to 0.06) towards it. Shape matching is kept weak on purpose, so a slap dents the skin and the whole body rings.

Slaps are impulses on old positions

In Verlet you add velocity by moving a point's previous position. A slap shifts every point's old position against the hand's direction, weighted by a Gaussian around the contact point whose width grows with hand speed (sigma = 58 + speed * 0.012). Points near the hand get the dent and the whole body gets a small nudge. The impulse is divided by the chub's mass, so Sumo Toad (mass 1.6) is harder to move than Pudding.

Damping is split in two. The motion of each point relative to the centroid is damped by the chub's damp value, while the centroid's own motion is barely damped (0.9995). That way the wobble settles but a throw still carries across the room.

Grab, throw and pinch

Grabbing takes the 7 skin points nearest the hand, weights them with a Gaussian falloff, pulls them towards the hand, and drags the whole body along loosely, so it stretches and dangles. On release, every point's velocity is blended 75% towards the hand's measured velocity, so how fast you were moving is how fast it flies. Wall and floor impacts add up per-point impact speed, which drives the splat sound and the dizzy eyes.

A pinch grabs just three skin points and doesn't drag the body. It also drops the stiffness of the skin springs near the pinch (a per-edge soft multiplier as low as 0.06) and turns air damping way up so the chub plants its feet. The cheek stretches out instead of the body sliding. Pull too far and it slips out with a POP.

Jiggle bones for the face

The eyes, mouth, cheeks and belly ride on separate damped springs, each with its own stiffness and damping. Each spring targets an anchor computed from the deformed skin: the rest-frame position is rotated by the body angle, then offset by a weighted average of how far nearby ring points have moved from their rest spots, with nearness measured by angle. Features follow the local squash but lag behind it, which gives a second wobble on top of the body's.

Each feature is clamped to 22 px from its anchor so nothing flies off the skin. Hand prints are stored in the body's rotating frame, so they stay on the skin as it tumbles and fade after 4 seconds.

Every sound is synthesized

The slap is layered from a one-second white noise buffer: a bandpassed crack around 2.4 to 3.3 kHz, a highpassed finger snap 6 ms later, and lowpassed noise for weight. Under that sits a sine thump that sweeps from 190 Hz down to 48 Hz, and on harder slaps a boing with an 11 to 15 Hz vibrato LFO. All of it goes through a convolver whose impulse response is generated noise with a cubic decay.

The oof is a sawtooth glide sent through three bandpass filters tuned to vowel formants, with a different set for big hits, and pitched by each chub's voice multiplier. A constant triangle-wave drone through a resonant lowpass changes pitch and volume with the measured jiggle energy and squash, so the body hums while it wobbles. Best scores for power, combo, jiggle and throw are kept in localStorage.

3.Try it

Tap or swing to slap, press and drag to grab and throw, and right-drag, use the Pinch tool or pinch with two fingers to stretch its cheeks.

More from the build log

Slap Chub · 4 min readAll 29 builds