Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.PHONY: start stop check-deps setup compile db shell clean help

ERLANG_VSN := $(shell cat .tool-versions | grep erlang | awk '{print $$2}')
REBAR_VSN := $(shell cat .tool-versions | grep rebar | awk '{print $$2}')

# Colors
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
BOLD := \033[1m
RESET := \033[0m

help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-15s$(RESET) %s\n", $$1, $$2}'

start: check-deps db compile ## Start everything (deps check + db + server)
@echo ""
@echo "$(BOLD)$(GREEN)Starting Asobi Arena...$(RESET)"
@echo ""
@rebar3 nova serve

stop: ## Stop PostgreSQL
@docker compose down
@echo "$(GREEN)PostgreSQL stopped.$(RESET)"

check-deps: ## Verify all required tools are installed
@echo "$(BOLD)Checking dependencies...$(RESET)"
@echo ""
@MISSING=0; \
\
if command -v erl >/dev/null 2>&1; then \
INSTALLED=$$(erl -noshell -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().'); \
EXPECTED=$$(echo $(ERLANG_VSN) | cut -d. -f1); \
if [ "$$INSTALLED" = "$$EXPECTED" ]; then \
echo " $(GREEN)✓$(RESET) Erlang/OTP $$INSTALLED"; \
else \
echo " $(YELLOW)!$(RESET) Erlang/OTP $$INSTALLED found, expected $(ERLANG_VSN)"; \
fi; \
else \
echo " $(RED)✗$(RESET) Erlang/OTP not found"; \
MISSING=1; \
fi; \
\
if command -v rebar3 >/dev/null 2>&1; then \
echo " $(GREEN)✓$(RESET) rebar3"; \
else \
echo " $(RED)✗$(RESET) rebar3 not found"; \
MISSING=1; \
fi; \
\
if command -v docker >/dev/null 2>&1; then \
echo " $(GREEN)✓$(RESET) Docker"; \
else \
echo " $(RED)✗$(RESET) Docker not found"; \
MISSING=1; \
fi; \
\
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then \
echo " $(GREEN)✓$(RESET) Docker Compose"; \
else \
echo " $(RED)✗$(RESET) Docker Compose not found"; \
MISSING=1; \
fi; \
\
echo ""; \
if [ "$$MISSING" -eq 1 ]; then \
echo "$(BOLD)$(RED)Missing dependencies.$(RESET) Install them with:"; \
echo ""; \
if command -v mise >/dev/null 2>&1; then \
echo " $(BOLD)mise install$(RESET) # Erlang + rebar3 (from .tool-versions)"; \
else \
echo " $(BOLD)# Option 1: mise (recommended)$(RESET)"; \
echo " curl https://mise.run | sh"; \
echo " mise install"; \
echo ""; \
echo " $(BOLD)# Option 2: manual$(RESET)"; \
echo " # Install Erlang/OTP $(ERLANG_VSN) and rebar3 $(REBAR_VSN)"; \
fi; \
echo ""; \
echo " Docker: https://docs.docker.com/get-docker/"; \
echo ""; \
exit 1; \
fi; \
echo "$(GREEN)All good.$(RESET)"

setup: check-deps ## First-time setup (deps check + fetch deps + start db + compile)
@$(MAKE) db
@echo ""
@echo "$(BOLD)Fetching dependencies...$(RESET)"
@rebar3 get-deps
@$(MAKE) compile
@echo ""
@echo "$(BOLD)$(GREEN)Setup complete!$(RESET) Run $(BOLD)make start$(RESET) to launch."

db: ## Start PostgreSQL (if not already running)
@if docker compose ps --status running 2>/dev/null | grep -q postgres; then \
echo " $(GREEN)✓$(RESET) PostgreSQL already running"; \
else \
echo " Starting PostgreSQL..."; \
docker compose up -d; \
echo " $(GREEN)✓$(RESET) PostgreSQL running on port 5436"; \
fi

compile: ## Compile the project
@rebar3 compile

shell: check-deps db compile ## Start an interactive Erlang shell
@rebar3 shell

clean: ## Remove build artifacts
@rebar3 clean
@echo "$(GREEN)Clean.$(RESET)"
54 changes: 46 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,48 @@ A multiplayer top-down arena shooter built on [Asobi](https://github.com/widgren

This project demonstrates how to build a game on Asobi: implement the `asobi_match` behaviour with your game logic, configure it as a game mode, and you have a fully featured multiplayer backend with auth, matchmaking, leaderboards, and more.

## Quick Start
## Try it

```sh
# Start PostgreSQL
docker compose up -d
git clone https://github.com/widgrensit/asobi_arena.git
cd asobi_arena
make start
```

That's it. `make start` checks your environment, starts PostgreSQL, compiles, and launches the server on `http://localhost:8084`.

### What if I'm missing something?

`make start` will tell you exactly what's missing and how to install it:

```
✗ Erlang/OTP not found
✓ Docker
✗ rebar3 not found

Missing dependencies. Install them with:

# Fetch dependencies and run
rebar3 shell
# Option 1: mise (recommended)
curl https://mise.run | sh
mise install
```

The server starts on `http://localhost:8080`. Asobi provides all the REST and WebSocket endpoints automatically.
### Available commands

```sh
make start # Check deps + start db + compile + run
make setup # First-time setup (fetch deps, start db, compile)
make check-deps # Just verify your environment
make db # Start PostgreSQL only
make shell # Interactive Erlang shell
make stop # Stop PostgreSQL
make clean # Remove build artifacts
```

## Requirements

- Erlang/OTP 28+ and rebar3 (use [mise](https://mise.run) or see `.tool-versions`)
- Docker and Docker Compose (for PostgreSQL)

## Game Logic

Expand All @@ -39,9 +70,16 @@ The match server runs at 10 ticks/second and broadcasts state to all connected p
- Match ends when time runs out or one player remains
- Winner = most kills

## Unity Client
## Client SDKs

Connect with any of the [Asobi SDKs](https://asobi.dev):

See [asobi-unity-demo](https://github.com/widgrensit/asobi-unity-demo) for the Unity client.
- [Unity demo](https://github.com/widgrensit/asobi-unity-demo) — ready-to-play Unity client
- [Godot](https://github.com/widgrensit/asobi-godot)
- [Defold](https://github.com/widgrensit/asobi-defold)
- [Dart / Flutter](https://github.com/widgrensit/asobi-dart)
- [JavaScript](https://github.com/widgrensit/asobi-js)
- [Unreal](https://github.com/widgrensit/asobi-unreal)

## Configuration

Expand Down
Loading