Transcendence - Multiplayer Pong Game

Typescript
WebSocket
Real Time
GitHub
transcendence game page screenshot

Transcendence is a real-time multiplayer ping pong game featuring live notifications, integrated chat, tournament system, and comprehensive user management.

Technologies

The project has a micro-service architecture, each service is deployed as a docker container and orchestracted via Docker Swarm, uses ELK stack for logging, Hashicorp vault for secrets, traefik and more... However my contribution consisted of the development of the game service, A Node.js and fastify REST API, with websockets support via fastify websocket plugin, sqlite was used as the database with Prisma ORM. I also worked on the frontend for the game, handling rendering, game updates and events using HTML canvas with a React-like library.

Note: Though the project uses many technologies for different features I have only used some of them as my part consisted mainly of the game, backend and frontend.

Features

Key features include game creation, invitation (with acceptance/rejection via notifications), spectator mode, tournament system, leaderboard, and game history. The game is a 2D ping pong game that uses a WebSocket connection for game updates. As a server-authoritative realtime game, logic and state are processed on the server, then the server sends real-time update to the players and spectators. Tournament System: Players compete between each others and winners are matched together using a match making algorithm, tournament events are sent to the client via an SSE (Server Sent Events) connection.

Challenges

I was already familiar with backend development, common api crud routes were not complicaated, but it was a first for me working on a game backend, the main challenge was making the game loop efficient so that it can handle many games at once with zero to little lag or frame drop. My initial optimization strategy was to follow the well-known rule of minimizing promise and object allocations within the hot path. This is because they are primary contributors to performance issues in CPU-bound tasks. The other challenge was keeping track of game sessions and handling reconnections with minimal overhead, for that I used a simple session to game state map, keeping minimal database lookups.

Key Learning

Working on this project introduced me to multiplayer/real time game development and its nuances, also allowed me to strengthen my backend development, database design, and state management skills.