Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f4th4n/gen_game
Distributed game server, written in Elixir
https://github.com/f4th4n/gen_game
distributed-systems elixir game game-development
Last synced: 3 months ago
JSON representation
Distributed game server, written in Elixir
- Host: GitHub
- URL: https://github.com/f4th4n/gen_game
- Owner: f4th4n
- Created: 2021-09-25T05:25:43.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T11:37:18.000Z (9 months ago)
- Last Synced: 2024-04-13T21:51:23.713Z (9 months ago)
- Topics: distributed-systems, elixir, game, game-development
- Language: Elixir
- Homepage:
- Size: 2.66 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Hex.pm](https://img.shields.io/hexpm/v/gen_game.svg)](https://hex.pm/packages/gen_game) [![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/gen_game)
# GenGame
[Read website documentation](https://gengame.rbs8.com)
GenGame is realtime and distributed game server, runs on Erlang VM.
Whether you're building a social network game, MMORPG, or TCG, GenGame helps you create a robust backend game server, offering clients for popular game platforms. It's also extensible with Elixir/Erlang or any HTTP server.
## Features
- **Users** - Register/login new users.
- **Relay Multiplayer** - Sending a message or event in the match.
- **Server Authoritative** - Execute custom logic using Elixir/Erlang or any programming language via HTTP server.
- **Matchmaker** - Let players finding fair match with expressive query.## Getting Started
Let's discover **GenGame** in less than 5 minutes.
There are two ways to get GenGame up and running: using Docker or building it from source. We recommend using Docker, as it's easier to manage. Building from source is intended for those who want to develop GenGame further or are interested in understanding how it works under the hood.
### Using Docker (Recommended)
First, create a file `docker-compose.yml`.
```yaml
services:
gen_game:
container_name: gen_game
image: f4th4n/gen_game:latest
environment:
DATABASE_URL: ecto://postgres:postgres@postgres/gen_game_prod
depends_on:
- postgres
ports:
- 4000:4000postgres:
container_name: postgres
image: postgres:14-alpine
healthcheck:
test: "pg_isready -U postgres"
volumes:
- postgres:/var/lib/postgresql/data
environment:
PSQL_HISTFILE: /root/log/.psql_history
POSTGRES_PASSWORD: postgres
POSTGRES_DB: gen_game_prod
ports:
- 5433:5432volumes:
postgres:
```Then run the command:
```bash
docker compose up
```Test by visiting http://localhost:4000/, if you see response below then congratulation, it works:
```json
{
"status": "ok",
"app": "gen_game"
}
```### Build Yourself
Requirements
1. Elixir
2. Erlang
3. PostgresSteps
1. Clone the [repo](https://github.com/f4th4n/gen_game)
2. Copy `.env.example` to `.env`
3. Update `.env`, fill DATABASE_URL
4. Run command below:```bash
source .env
iex --sname gen_game --cookie g3ng4m3 -S mix phx.server
```Test by visiting http://localhost:4000/, if you see:
```json
{
"status": "ok",
"app": "gen_game"
}
```then it works.
## Upgrade
To update to the latest version of GenGame:
If you are using Docker, change the tag to the newer version. You can see the full list of tags at [Docker Hub](https://hub.docker.com/r/f4th4n/gen_game).
If you are building it yourself, pull the newer code from [the repository](https://github.com/f4th4n/gen_game) and then rebuild.
## Client Libraries
#### Unity
If you're using Unity or any C# application then you should use [gen_game_unity](https://github.com/f4th4n/gen_game_unity) to connect to GenGame server.
#### JavaScript
If you're using PhaserJS, Cocos2d-x, Construct3, Telegram Game, Facebook Instant Game, or any JavaScript application then you should use [gen_game_js](https://github.com/f4th4n/gen_game_client_js) to connect to GenGame server.
## Extend With Hooks
You can extend GenGame functionality beyond its capability with **hooks**. Hooks let you run your own function in between events, so you can achieve thing like server authoritative actions.
Server authoritative means server doing some calculation before sending it to the client. For example, your game need to spawn an enemy or calculating damage based on player's armor.
There are 2 ways to do this.
1. Using Elixir
2. Using any other programming languageSee the documentation [here](https://gengame.rbs8.com/docs/category/hooks).
## Benchmark
Is GenGame really fast? The main strength of GenGame is not raw speed but concurrent connection. They can handle ~20k concurrent connection with 2 CPU 4 GB memory easily. You can read the whole article how we did this [here](https://medium.com/p/c4e68ae2dc4e).