ECSx
ECSx is a framework for using Entity Component System architecture to build real-time games and simulations. It is currently 100% Elixir, using :ets
for managing Components, and GenServer
for managing Systems under-the-hood.
Features
- Generators handle all boilerplate creation
- Type-checking for all component data
- Strict serializability of data operations
- Persistence with file system or Ecto (via ecsx_persistence_ecto)
- Integration with Phoenix LiveDashboard (via ecsx_live_dashboard)
How to Get Started
All you need to a functional game up and running:
- Install
:ecsx
into an existing Elixir app - Run
mix ecsx setup
- Run
mix ecsx.gen.component
to define the various attributes which game entities may have - Run
mix ecsx.gen.system
to define the logical systems which update the game state over time - Write system logic using pure Elixir and a simple ECSx interface; e.g.
HitPoints.get(entity)
- Develop your frontend using any technology you like (including LiveView)
To get you started quickly, there is a tutorial which walks you through each of the above steps, to create a game with a LiveView frontend, where you move around a battleship which automatically attacks any pirate ships which get within range
Resources
- DockYard blog post explaining ECS architecture and why it’s useful for Elixir gamedev
- ElixirConf 2023 talk with more examples and live ECSx demo
- Elixir Newbie podcast #34 where I discuss the history and key features of the project
- DockYard Elixir Roundtable podcast #21 the first public announcement of ECSx (starts at 28:00)
- Github repo
- Official documentation
- “Ship game” tutorial app repo