Back to the blog
Development / DEVELOPMENT NOTES

WebSockets, part 1: Arkanoid with server-side game logic

A real-time application in which the server runs the game while the browser renders it and sends player input.

Arkanoid using WebSocket communication

To explore a real-time web application, I implemented a version of Arkanoid using WebSockets. In this example, the game logic runs on the server.

The browser acts as a thin client: it renders graphics and communicates the state of the controls.

Arkanoid using WebSocket communication

Divide the responsibilities

  • Server: maintains the rules and game state, including positions, score, level, and lives.
  • Client: collects player input and draws the data it receives.
  • WebSocket: maintains the communication channel between them.

One player, an architecture to study

This version is single-player. Its purpose is to separate the simulation from the machine displaying it and follow the messages exchanged between the two.

The second article, about agar.io, continues the experiment with a multiplayer game.

Source code

Explore the project on GitHub

Written by Sergio Soriano

Development, curiosity, and shared projects.

About Sergio Soriano