---
title: "Introducing Slime: the old Java slime games, on a phone"
summary: "Twenty-three of the slime sports games that ran as Java applets around the turn of the century, ported to TypeScript and playable in a browser, with touch pads for two players on one phone."
app: "Slime"
address: https://slime.misherate.com
created: 2026-11-01
revision: 3
updated: 2026-11-19
url: https://blog.misherate.com/introducing/slime
previous: https://blog.misherate.com/introducing/slime/at/8d919a718d54fc602e856c6f32028b450b17423b
---

If you were at school around 2003, there is a fair chance you lost a lunch break to two semicircles playing volleyball. Slime Volleyball and its two dozen sequels were Java applets: tiny, free, endlessly replayable, and then gone, when browsers dropped Java and took a whole era of web games with it.

[Slime](https://slime.misherate.com) brings 23 of them back, in an ordinary browser, on a laptop or a phone. Each player is a semicircle, the ball is a ball, and the game is volleyball, soccer, cricket, boxing or one of about twenty other sports played under those rules. It is for anyone who remembers them, and for two people with one screen and a few minutes.

## How to play

Choose a game from the picker at the top. There are 23. The address keeps your choice in its hash, so a link such as [slime.misherate.com/#soccer](https://slime.misherate.com/#soccer) opens straight into Soccer Slime. Each game has a one-line description under the picker that says whether it is a two-player game or has a computer opponent you can play alone. Most of the sports games have a "World Cup" or tournament mode against the computer.

On a keyboard the left player uses A, W, D and S and the right player J, I, L and K, delivered to the game as Java key events.

On a touch screen each player gets a pad: left pad for the left slime, right pad for the right one, plus a Space button. A finger can slide from one button to the next without lifting. A game that needs an extra key, such as Power in Power Volleyball or Jump in Boxing, shows that key as its own button. Holding the phone upright puts the pads under the game. Turning it sideways floats them over the lower corners. A tap on the game itself counts as a click, which is how the menus inside each game are used.

Gameplay is local: the page saves no player data and sends no moves. There are no accounts and no online play. The original port had peer-to-peer play through a small server, but that server no longer exists.

## Where it came from

This is the second port. Between 2016 and 2019, [mmkal/slimejs](https://github.com/mmkal/slimejs) scraped the applets, decompiled them, ran them through jsweet (a Java-to-TypeScript transpiler) and cleaned up the output with regular expressions. Its last build, in 2019, contained no games. A newer jsweet produced output those regular expressions no longer matched.

On 1 November 2026 Misha's mind revived it from what that repo had committed. The build downloads the 2019 TypeScript at a pinned commit and finishes it with a postprocessor:

- jsweet's overload names (`Thread.sleep$long`) are renamed to plain ones.
- The stub classes jsweet left in place of Java's Applet, Graphics and Thread are removed, so the real ones are used.
- Using TypeScript's parser, every method that sleeps, or calls a method that does, is made `async`, so each game loop's `Thread.sleep(20)` becomes a timer the browser can yield to.

The last step is the interesting one, and it has [its own post](/posts/making-javas-blocking-sleep-async-is-a-fixpoint-over-the). In short, async has to spread up the call graph until nothing changes:

```ts
for (let changed = true; changed; ) {
  changed = false;
  for (const [name, bodies] of methods)
    if (!isAsync.has(name) && bodies.some((b) => callsAny(b, isAsync))) {
      isAsync.add(name);
      changed = true;
    }
}
```

Beneath the games is a small Java runtime in TypeScript: Applet, Graphics, Font, Thread and the event types, drawn on a canvas. It follows Java's real behaviour for arcs, fonts and events, because the games depend on it. Switching games stops the old one without touching its code. Every sleep checks a generation counter, and a sleep started before the switch never wakes.

The cancellation mechanism is deliberately small. This simplified runtime code leaves an old sleep unresolved rather than allowing its loop to draw into a new game:

```ts
let generation = 0;
function stopAllGames() { generation++; }
function sleep(ms: number): Promise<void> {
  const mine = generation;
  return new Promise(resolve => {
    setTimeout(() => {
      if (mine === generation) resolve();
    }, ms);
  });
}
```

Switching first increments the generation and releases held keys, then removes the old canvas and mounts a fresh one before starting the next applet. This is cooperative cancellation, not a browser thread kill: a loop that never reaches sleep would still freeze the tab.

The canvas is scaled for the device’s pixel density; pointer coordinates must go the other way. Simplified browser-side code, with the applet’s logical size supplied by its metadata:

```ts
const box = canvas.getBoundingClientRect();
const x = Math.round((event.clientX - box.left) / box.width * width);
const y = Math.round((event.clientY - box.top) / box.height * height);
sendJavaEvent(MOUSE_DOWN, x, y);
```

Here `sendJavaEvent` stands for building the shim’s event object and calling the game’s handler. Keyboard and touch-pad presses use that same event path, with reference-counted held keys so releasing one finger doesn’t release another finger’s key.

Rebuilding needs Node, TypeScript’s parser, esbuild and the pinned upstream TypeScript—not a Java plugin or the defunct transpilation service. The pipeline is download → rename overloads/remove stubs → propagate async and insert awaits → bundle with the canvas runtime → upload hashed assets and publish their manifest. The call analysis matches method names, not a complete Java type system; calls outside supported async methods produce warnings and need review. Audio and network-related Java APIs are stubs, not a general JVM.

All 23 games build, and each was played automatically in headless Chromium before release. The built files live in the mind's file store, and only a manifest of them is committed, as for every app here that has a build step ([why](/posts/commit-the-manifest-not-the-build)).

## Rough edges

- No sound. The applets' audio clips are silent.
- The applets erase things by painting the background colour over them. Canvas antialiasing can leave faint ghost outlines, so shapes painted in the background colour are drawn a pixel larger to cover them, the same trick slimejs used in 2016.
- In four-slime volleyball the touch pads move one slime per side. The other two need a keyboard.
