|
MMO 0.1.0
Building an MMO: The Engineering Series
|
The game built in the YouTube series Building an MMO: The Engineering Series: a C++ server, a C++ client, and everything around them. Each episode's code is a git tag (ep001/end, ep002/end, ...).
You need CMake, Ninja and a C++20 compiler. The client draws with raylib, on top of the system's OpenGL:
sudo apt install xorg-dev libgl1-mesa-dev, the X11 and OpenGL headers.CMake fetches and builds the libraries: GoogleTest, raylib, Dear ImGui, rlImGui, abseil, protobuf, Asio and prometheus-cpp. The first build compiles protobuf, so it takes a few minutes.
Then, in another terminal or two:
The server listens on TCP port 7777, and the client connects to localhost, or to the host you give it (./build/bin/mmo_client 192.168.1.20). Each player is a cube on a board of tiles. W, A, S and D, or the arrow keys, move yours, which has a white marker over it. View, Settings changes the background.
protocol/mmo.proto is the contract between the client and the server. The build runs protoc on it, and both sides use the C++ it generates.
Or with only Docker installed:
In Docker, the client's tests open their window on a virtual display from Xvfb, and render with llvmpipe, Mesa's OpenGL driver that runs on the CPU. So they don't need a screen or a GPU.
The server serves its metrics for Prometheus at http://localhost:9464/metrics: the players online, how long each tick takes, the bytes it sends and the messages it receives.
compose.yaml starts the server together with Prometheus, which scrapes it every two seconds, and Grafana, with a dashboard of those metrics. The dashboard and Grafana's data source are files in monitoring/, so they're set up the same way on any machine.
mmo_bot connects a swarm of bots that wander around like players at their keys. It takes the host, the port, how many bots, and how many seconds to spread their arrival over:
Or in Docker, next to the server: 300 bots, arriving over two minutes.
A few hundred bots need more open files than macOS allows a shell by default, so on the Mac, run ulimit -n 4096 first. Stop everything with docker compose --profile load down.