A player's side of a Cauldron2D.World: join, send input, receive frames, leave.
Anything that runs in a process can be a player — a terminal session, a computer player, a test.
:ok = Cauldron2D.Player.join(world, :alice, %{username: "alice"})
Cauldron2D.Player.input(world, :alice, Cauldron2D.Input.state(input))
receive do
{:cauldron_frame, %{tick: tick, view: view, events: events}} -> ...
endFrames arrive once per tick for as long as the player is joined. Leaving, or the process exiting, stops them.
Summary
Functions
Send what the player is doing now; applied before the next tick.
Join world as id from the calling process.
Leave world.
Functions
@spec input( GenServer.server(), Cauldron2D.World.player_id(), Cauldron2D.Input.state() ) :: :ok
Send what the player is doing now; applied before the next tick.
@spec join(GenServer.server(), Cauldron2D.World.player_id(), map()) :: :ok | {:error, term()}
Join world as id from the calling process.
@spec leave(GenServer.server(), Cauldron2D.World.player_id()) :: :ok
Leave world.