View Source ECSx (ECSx v0.3.1)

ECSx is an Entity-Component-System (ECS) framework for Elixir.

In ECS:

  • Every game object is an Entity, represented by a unique ID.
  • The data which comprises an Entity is split among many Components.
  • Game logic is split into Systems, which update the Components every server tick.

Under the hood, ECSx uses Erlang Term Storage (ETS) to store active Components in memory. A single GenServer manages the ETS tables to ensure strict serializability and customize the run order for Systems.

Link to this section Summary

Functions

Returns the ECSx manager module.

Returns the path to the ECSx manager file.

Returns the tick rate of the ECSx application.

Link to this section Functions

@spec manager() :: module() | nil

Returns the ECSx manager module.

This is set in your app configuration:

config :ecsx, manager: MyApp.Manager
@spec manager_path() :: binary() | nil

Returns the path to the ECSx manager file.

This is inferred by your module name. If you want to rename or move the manager file so the path and module name are no longer in alignment, use a custom :path opt along with the manager module, wrapped in a tuple.

examples

Examples

# standard path: lib/my_app/manager.ex
config :ecsx, manager: MyApp.Manager

# custom path: lib/foo/bar/baz.ex
config :ecsx, manager: {MyApp.Manager, path: "lib/foo/bar/baz.ex"}
@spec tick_rate() :: integer()

Returns the tick rate of the ECSx application.

This defaults to 20, and can be changed in your app configuration:

config :ecsx, tick_rate: 15