Play snake with your friends!
Project hosted at: https://github.com/krazkidd/snakem
License: GPLv3 (see LICENSE.md file)
- ...
This is a monorepo with three components:
-
Game server
Requires:
- Python ^3.11 or Docker CLI
-
Game client
Requires:
- Python ^3.11
- POSIX OS (terminal with curses support)
-
Web frontend
Requires:
- A modern browser supported by Vue.js
The game server and client are packaged together as a Python module. Uvicorn (with FastAPI integration) is the web server, providing a WebSockets endpoint for game client communications and a RESTful API for the web frontend.
It is customary to utilize Python's virtualization facilities to avoid dependency conflicts.
-
To create and enter a virtual Python environment, run
$ cd src/server $ python3 -m venv .venv $ source .venv/bin/activate
-
To install all dependencies in the virtual environment, run
$ pip install -r requirements.txt
From here, you are able to run the Snake-M client or server.
-
To exit the virtual environment, run
$ deactivate
To start the server from the Python virtual environment, run
$ uvicorn snakem.web.app:app --host 127.0.0.1 --port 9000 --log-level debug --reload
To build and run the server in a Docker container, run
$ cd src/server
$ sudo docker build -t snakem:latest .
$ sudo docker run --rm -it -p 9000:9000/tcp --name snakem snakem:latest
To get the container IP address and port, run
$ sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' snakem
First ensure SERVER_HOST
in src/server/snakem/config/client.py
has the right server IP address and port.
To start the client, run
$ cd src/server
$ python3 -m snakem.net.client
First ensure __SERVER_URL__
in src/web/vite.config.js
has the right server IP address.
$ cd src/web
$ npm run dev
-
Install the recommended extensions (see
.vscode/extensions.json
). -
Open the Command Palette and execute
python.setInterpreter
. Select the interpreter installed in the virtual environment location (src/server/.venv/bin/python
). -
In the Run and Debug view, launch either
- snakem server (local)
- snakem client (local)
This repository provides a configuration template for DigitalOcean's App Platform. You can launch your own Snake-M server in the cloud in a couple of clicks with the button below.
The snake favicon (src/web/public/favicon/favicon.ico
and accompanying files) and other emojis are used under the CC-BY 4.0 license from the twemoji project.