Gennaro, Mirko, Tommaso: Walking Buddies

Gennaro Esposito, Mirko Bassani, Tommaso Stanga

Walking Buddies is an asynchronous multiplayer system that synchronizes the mouse position across three different devices.
Each participant has a small on-screen widget — a “buddy” — that moves according to its owner’s cursor.
All movements are stored and transmitted in real time through a Supabase database

GitHub repository

How It Works

1. Mouse Tracking

character.js continuously reads local mouse coordinates using window.electronAPI.getMousePosition() every 50 ms.
If the position changes, it sends the update to Supabase and animates the local buddy.

2. Realtime Sync

db.js manages the Supabase connection:

  • Each user has a record containing position and heartbeat

On update, Supabase broadcasts changes to all clients:

channel.on("postgres_changes", { event: "UPDATE" }, payload => {
  updateRemotePosition(characterId, data.data.position);
});

3. Movement & Animation

Buddies interpolate between currentPosition and targetPosition, adjusting direction and speed dynamically.
When idle, they perform small random movements to stay “alive.”
Each frame switches between idle and walk sprites for continuous animation.

4. Heartbeat & Presence

A periodic heartbeat (Date.now()) confirms each client’s activity.
If no updates arrive for 30 s, the buddy fades out (leave animation).
Reconnection brings it back on screen.