All examples · Experiments · As Markdown, for AIs

Online arena

What this example shows

Ana moves with WASD and zaps with F; Luis with the arrows and Enter. Each half of the page is one of them.

nacatamalon/net is experimental: it can change from one version to the next.

The line is 80 ms each way, and still each player's own fighter moves the moment a key is pressed. Its useShared has an owner and a move: the server moves it with what that player presses, and their page runs the same move at once, ahead of the server; when the server's word comes it starts again from there and runs once more the steps the server had not seen. The other fighter glides a moment behind.

The server reads each player's keys by name with useNet().actions(player), whatever keys they are on that player's machine. A zap is decided with useNet().rewind(player, fn): every shared object is put back where that player saw it when they pressed, so a hit on their screen is a hit.

Starting
Starting
—