Skip to content

Academic · Oct–Nov 2025

Serpix

Snake meets Pong: a two-player duel I built in vanilla JS, then took online.

Playable
Serpix match: a blue snake chases a red ball across a black arena, with both players' scores above and an event log below.

TL;DR

  • Mixed Snake's growing body, Pong's head-to-head duel and Slither.io's free 360° movement.
  • Built the course version in one week with zero dependencies, then ported it to React and took it online.
  • Wrote the game server in Node.js and Socket.IO: it runs every match, pairs players up and gives each match its own room.
  • The offline version, two players on one keyboard, is playable right here.

Serpix is a fast two-player arcade game. It combines the growing body of Snake, the head-to-head duel of Pong and the continuous movement of Slither.io. The goal is simple: make your opponent crash into your ever-growing body.

I built the first version in one week for a front-end course at CESAR School⁠ (opens in a new tab), in plain HTML, CSS and JavaScript, for two players on one keyboard. Afterwards I ported it to React and took it online: now each player joins from their own browser, and a Node.js server runs the match. You can play the online version⁠ (opens in a new tab) with a friend, or try the offline version right on this page.

What I built

  • Two players, head to head: online from two browsers, or offline on one keyboard.
  • Growth: catch the bouncing ball to score and lengthen your snake, turning yourself into a bigger obstacle.
  • Last snake standing: each player has three lives, and the first to take all of the opponent's wins.
  • Free 360° movement instead of Snake's grid, for smooth turns and more tactics.
  • Persistent leaderboard in the offline version: wins are saved locally with score and match time, sorted by score and then by time.
  • Game feel: particle effects and sounds when you eat the ball, take damage and win.

How it's built

The course version

The course required clean, modular code with no external dependencies:

  • 100% vanilla HTML, CSS and JavaScript, each in its own files.
  • Object-oriented design with classes such as Player, Ball, Game, Particle and ParticleSystem.
  • Dynamic DOM updates for the event log and the leaderboard.
  • An efficient particle system that manages each particle's lifecycle, avoiding memory leaks and keeping the frame rate smooth.

The online version

  • Client: React with Vite, Tailwind CSS and React Router, with the game's particles and sounds ported over.
  • Server: Node.js with Express and Socket.IO. It runs the simulation, checks collisions and sends the game state to both players.
  • Hosting: the client on Vercel and the server on Render.

What I learned

Taking Serpix online taught me how real-time multiplayer fits together.

The server is the authority. It runs the match about 60 times a second, checks every collision and sends both players the same snapshot of the game. Each browser only sends which turn keys are held and draws the snapshots it receives, so the two screens can't disagree about a hit. One-off moments, like eating the ball or taking a hit, go out as separate events that trigger the particles and sounds.

Around the match, I had to manage the connections themselves. A simple lobby holds the first player until a second one looks for a game, then both join their own Socket.IO room, so a match's updates reach only its two players. If the waiting player leaves, the lobby clears; if someone drops mid-match, the game ends and the player who stayed wins. Because the client and the server live on different hosts, the server's CORS settings allow only the game's own address.

The simple design has a cost: the browser draws only the latest snapshot, with no prediction, so every turn waits for a round trip to the server before it shows on screen.

Play Serpix

Offline version, two players on one keyboard. Player 1: A and D to turn. Player 2: ← and → to turn.

Open it in its own tab⁠ (opens in a new tab)

Media

Gameplay

From the start screen into a match, in the offline version.
Tutorial.
The offline version's local leaderboard.

Screenshots and art

  • The offline version's start screen.

1 / 1

Serpix start screen with the green logo, name fields for both players, a Start Game button and links to the leaderboard and tutorial.
The offline version's start screen.

Like this?

Let's talk

Open to conversations about developer and production roles, and collaborations. I'm in Recife, Brazil (UTC−3).