{"id":15722547,"url":"https://github.com/romanchekashov/multiplayergames","last_synced_at":"2026-04-30T10:37:33.744Z","repository":{"id":191610670,"uuid":"684996237","full_name":"romanchekashov/MultiplayerGames","owner":"romanchekashov","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-29T10:44:25.000Z","size":81291,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T23:43:51.880Z","etag":null,"topics":["dedicated-gameservers","defold","defold-game-engine","game","game-development","gameserver","lua","multiplayer","multiplayer-game","multiplayer-game-server","socket","websocket","webtransport"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romanchekashov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-30T09:37:31.000Z","updated_at":"2024-09-29T10:44:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"59f3f960-d0f1-4209-a81e-fc6eaaa6161e","html_url":"https://github.com/romanchekashov/MultiplayerGames","commit_stats":null,"previous_names":["romanchekashov/multiplayergames"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanchekashov%2FMultiplayerGames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanchekashov%2FMultiplayerGames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanchekashov%2FMultiplayerGames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanchekashov%2FMultiplayerGames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romanchekashov","download_url":"https://codeload.github.com/romanchekashov/MultiplayerGames/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246395572,"owners_count":20770240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dedicated-gameservers","defold","defold-game-engine","game","game-development","gameserver","lua","multiplayer","multiplayer-game","multiplayer-game-server","socket","websocket","webtransport"],"created_at":"2024-10-03T22:08:21.884Z","updated_at":"2026-04-30T10:37:33.718Z","avatar_url":"https://github.com/romanchekashov.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"Multiplayer games\n---\n\n### Authoritive server\n- Client sends inputs, keys pressed (commands) to server (prefer: UDP but care about reliability)\n  - Each UDP packet contains new commands and replicates previous commands (so, even if some packets are lost, the server should be able to process all the client commands)\n  - Client sends inputs with a timestamp (to calculate latency)\n  - Server acknowledges client about received commands so client can remove them from the buffer\n  - Client-Side Prediction: Client predicts the game state based on the commands it sends to the server. So client can move or take an action instantly!\n  - Received game state confirms that the client predicted it correctly. But if client made miss-prediction, it's state will be corrected and user may see that!\n- Server calculates game state(whole world state (snapshot) should be sent in 1 UDP packet: use [delta compression](./docs/delta_compression.md)) and sends it to all clients (prefer: UDP)\n  - Because everything inside 1 UDP packet there is no problem with packet loss\n  - Client interpolate between snapshots to smooth movement (minimum 2 snapshots are needed to interpolate)\n  - Server has current (present) state! But clients see previous (past) state!\n  - Server has a Snapshot Buffer to store latest snapshots (0ms, 50ms, 100ms, 150ms, 200ms, 250ms) in order to improve Hit detection accuracy! For example: User hits an object in frame 42. Server takes 2 latest snapshots (0ms, 50ms) and make same as client interpolation to frame 42 and process a hit detection at that frame! So user can hit the target which they actually see.\n\n### System design overview:\n1. Game Server\n2. Middleware Communication Server\n3. Game Client\n\n## 1. Game Server\n### Defold headless game\n- On server game should have collision object without sprites\n- https://forum.defold.com/t/dmengine-headless-all-flags-list/73914/3\n- Also, it’s also probably likely that you want to use a bundled game, in which case there are no loose file, but a few archives (.arcd, .arci)\n- And for content, I would probably scale down all textures to e.g. 2x2 size.\n- All in all, I would use a separate .settings file (same format as game.project) to setup the server settings (you can specify the server.collection as the bootstrap there):\n```shell\njava -jar bob.jar clean build --archive bundle --settings headless.settings --bo bundle_headless \n```\n\n## 2. Middleware Communication Server\n### Communication protocols:\n### Websockets:\n- [Python Websockets SSL with Lets Encrypt](https://gist.github.com/xprilion/ceab48ec77a70be1d403e396170991e6)\n- [How to use Nginx as a Reverse proxy for HTTPS and WSS - Self Signed Certificates and Trusted Certificates](https://www.linkedin.com/pulse/how-use-nginx-reverse-proxy-https-wss-self-signed-ramos-da-silva/)\n- [NGINX as a WebSocket Proxy](https://www.nginx.com/blog/websocket-nginx/)\n\n### WebTransport HTTP/3 + QUIC (datagrams over UDP):\n```sh\n./install.sh # python dependencies\n./run.sh # webtransport_server.py\n```\n##### Resources\n- https://github.com/GoogleChrome/samples/blob/gh-pages/webtransport/webtransport_server.py\n- https://github.com/aiortc/aioquic/issues/237\n- [Using WebTransport](https://developer.chrome.com/en/articles/webtransport/)\n- [ERR_METHOD_NOT_SUPPORTED, Opening handshake failed.](https://github.com/aiortc/aioquic/issues/237)\n\n### Lua language 5.1\n- [YouTube: Full Lua Programming Crash Course - Beginner to Advanced](https://www.youtube.com/watch?v=1srFmjt1Ib0)\n- [YouTube: Lua Tutorial](https://www.youtube.com/watch?v=iMacxZQMPXs)\n\n### Python language 3.10\n- [venv — Creation of virtual environments](https://docs.python.org/3/library/venv.html)\n- [How to Create Requirements.txt File in Python](https://www.javatpoint.com/how-to-create-requirements-txt-file-in-python)\n```shell\npython3.10 -m venv venv # set virtual environment\npython3.10 -m pip freeze \u003e requirements.txt # manage dependencies versions\n\npython3.10 -m pip install aioquic\npython3.10 -m pip install websockets\npython3.10 webtransport_server.py # run\n```\n##### Resources\n- [Install Python3 in Ubuntu Docker](https://jdhao.github.io/2021/01/17/install_python3_in_ubuntu_docker/)\n- [Docker fails to install cffi with python:3.9-alpine in Dockerfile](https://stackoverflow.com/questions/71372066/docker-fails-to-install-cffi-with-python3-9-alpine-in-dockerfile)\n- [Docker can't find Python venv executable](https://stackoverflow.com/questions/72468361/docker-cant-find-python-venv-executable)\n- [Install pip in docker](https://stackoverflow.com/questions/36611052/install-pip-in-docker)\n- [aioquic examples](https://github.com/aiortc/aioquic/tree/main/examples)\n- [How to Set Up a Virtual Environment in Python – And Why It's Useful](https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/)\n- [asyncio.get_event_loop(): DeprecationWarning: There is no current event loop](https://stackoverflow.com/questions/73361664/asyncio-get-event-loop-deprecationwarning-there-is-no-current-event-loop)\n- [socket.error:[errno 99] cannot assign requested address and namespace in python](https://stackoverflow.com/questions/19246103/socket-errorerrno-99-cannot-assign-requested-address-and-namespace-in-python)\n- \n\n### Deploy:\n```shell\ndocker-compose --env-file .env.local up --build -d # build and start Dockers\ndocker-compose --env-file .env.local up -d         # start Dockers without rebuild\ndocker-compose --env-file .env.local down          # stop Dockers\n```\n\n##### Resources\n- [Best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)\n- [Exposing Container Ports in Docker](https://blog.knoldus.com/exposing-container-ports-in-docker/)\n- [Networking in Compose](https://docs.docker.com/compose/networking/)\n- [ubuntu docker image](https://hub.docker.com/_/ubuntu/tags?page=1\u0026name=22)\n\n### Resources:\n- [Multiplayer server: Nakama](server/Nakama.md)\n- [Find (and kill) process locking port 3000 on Mac](https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac)\n- [How to kill a process running on particular port in Linux?](https://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux)\n- [How to kill a process on a port on ubuntu](https://stackoverflow.com/questions/9346211/how-to-kill-a-process-on-a-port-on-ubuntu)\n- [How to find the path of a file on Mac](https://setapp.com/how-to/how-to-find-the-path-of-a-file-in-mac)\n- [mkcert is a simple tool for making locally-trusted development certificates](https://github.com/FiloSottile/mkcert)\n- [localhost-ssl-certificate.md](https://gist.github.com/ethicka/27c36c975a5c2cbbd1874bc78bab61c4)\n- https://github.com/GoogleChrome/samples\n- [Photon Cloud Documentation: Realtime Intro](https://doc.photonengine.com/realtime/current/getting-started/realtime-intro/#)\n- [YouTube: Bringing you tutorials covering C#, Unity3D, and Photon SDK(Чел пишет фреймворк на PhotonServer)](https://www.youtube.com/@cjrgaming/videos)\n- [YouTube: В подкасте \"Как делают игры\" про сервера](https://www.youtube.com/watch?v=vYEebcnap-w)\n- [Простым языком об HTTP](https://habr.com/ru/articles/215117/)\n- [Как работает реляционная БД](https://habr.com/ru/companies/vk/articles/266811/)\n- [Архитектура сервера онлайн-игры на примере Skyforge](https://habr.com/ru/companies/vk/articles/220359/)\n- [Базы данных в онлайн-играх. От Аллодов Онлайн до Skyforge](https://habr.com/ru/companies/vk/articles/182088/)\n\n### References Papers:\n- [Статьи Михаила на Хабре про сетевой код](https://habr.com/ru/users/marsermd/publications/articles/)\n- [YouTube: Как устроен сетевой код в играх | Неткод, мультиплеер, геймдев | Podlodka Podcast #377](https://youtu.be/Hf1_0RCrw7o?si=PcQQfhb0syLi-LSM)\n- [Source Multiplayer Networking](https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking)\n- [Server In-game Protocol Design and Optimization: Footnotes](https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization#Footnotes)\n- [GitHub: A Curated List of Multiplayer Game Network Programming Resources](https://github.com/ThusSpokeNomad/GameNetworkingResources)\n- [YouTube Playlist: Rollback Netcode in Godot](https://youtube.com/playlist?list=PLCBLMvLIundBXwTa6gwlOUNc29_9btoir\u0026si=2YQN2EW5xAbOrU1d)\n- [Fast-Paced Multiplayer (Part I): Client-Server Game Architecture](https://www.gabrielgambetta.com/client-server-game-architecture.html)\n- [Fast-Paced Multiplayer (Part II): Client-Side Prediction and Server Reconciliation](https://www.gabrielgambetta.com/client-side-prediction-server-reconciliation.html)\n- [Gaffer On Games](https://gafferongames.com/)\n- [Доклад про мультиплеер от Destiny](https://www.gdcvault.com/play/1022246/Shared-World-Shooter-Destiny-s)\n- [Доклад про latency в Call of Duty](https://gdcvault.com/play/1023220/Fighting-Latency-on-Call-of)\n- [YouTube: GDC Networking Scripted Weapons and Abilities in Overwatch](https://www.youtube.com/watch?v=odSBJ49rzDo)\n- [YouTube: Overwatch Netcode 60Hz Test Results \u0026 More!](https://www.youtube.com/watch?v=H0zbpPCdhGk)\n- [YouTube: Replay Technology in Overwatch: Kill Cam, Gameplay, and Highlights](https://www.youtube.com/watch?v=W4oZq4tn57w)\n- [YouTube: Networking Scripted Weapons and Abilities in Overwatch](https://www.youtube.com/watch?v=ScyZjcjTlA4)\n- [interpolation and extrapolation on the client to smooth movement](https://www.google.com/search?q=interpolation+and+extrapolation+on+the+client+to+smooth+movement\u0026oq=interpolation+and+extrapolation+on+the+client+to+smooth+movement\u0026gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRiPAtIBCDU2OTlqMGo3qAIAsAIA\u0026sourceid=chrome\u0026ie=UTF-8)\n- [Client-side prediction](https://en.wikipedia.org/wiki/Client-side_prediction)\n- https://en.wikipedia.org/wiki/Quake_(video_game)#QuakeWorld\n- [1500 Archers on a 28.8: Network Programming in Age of Empires and Beyond](https://www.gamedeveloper.com/programming/1500-archers-on-a-28-8-network-programming-in-age-of-empires-and-beyond)\n- [YouTube: Миллион пользователей онлайн в World of Tanks с инженерной точки зрения](https://www.youtube.com/watch?v=5y23xezgQKE)\n\n### References from Godot Engine:\n- [YouTube Playlist: Dedicated Multiplayer](https://youtube.com/playlist?list=PLZ-54sd-DMAKU8Neo5KsVmq8KtoDkfi4s\u0026si=diFKwNYeEH_FNBYd)\n- [YouTube: Add Multiplayer to your Godot Game!](https://youtu.be/V4a_J38XdHk?si=9ZJCS1iRwI4bBTK7)\n- [YouTube: Export and Run a Godot Dedicated Server](https://www.youtube.com/watch?v=jgJuX04cq7k)\n- [YouTube: Godot Multiplayer Lag Compensation with Netfox](https://youtu.be/GqHTNmRspjU?si=EzmM4nZoJ2KWfsJA)\n- [GitHub: Netfox Addons for building multiplayer games with Godot](https://github.com/foxssake/netfox/discussions)\n- [GitHub: A Simple Godot 4 Online Multiplayer FPS Prototype](https://github.com/devloglogan/MultiplayerFPSTutorial)\n- [Multiplayer in Godot 4.0: Scene Replication](https://godotengine.org/article/multiplayer-in-godot-4-0-scene-replication/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanchekashov%2Fmultiplayergames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromanchekashov%2Fmultiplayergames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanchekashov%2Fmultiplayergames/lists"}