Drives a Cauldron2D.Game in a test, with no world process and no clock: join
players, hold actions, run ticks, read views and events.
driver = Cauldron2D.Test.new(MyGame, game_opts: [seed: 1], hz: 50)
{:ok, driver} = Cauldron2D.Test.join(driver, :alice, %{username: "alice"})
driver = driver |> Cauldron2D.Test.hold(:alice, [:thrust]) |> Cauldron2D.Test.tick(10)
Cauldron2D.Test.view(driver, :alice)
Cauldron2D.Test.events(driver)A tick is what Cauldron2D.World does on one step: the input held since the last tick
is applied, the game steps by 1 / hz, and its events are drained and kept, oldest
first. until/3 ticks until a condition holds or a limit is reached.
Summary
Functions
Every event drained so far, oldest first.
What player id holds from the next tick: a list of actions, an aim, and optionally how hard each action is held.
Join player id with props; the game's refusal is returned as it gave it.
Player id leaves.
A driver for game; options :game_opts (default []) and :hz (default 50).
The game's state.
Run count ticks.
How many ticks have run.
Tick until condition holds of the driver, at most limit times; {:timeout, driver} when it never did.
The game's view for player id now.
Types
@type t() :: %Cauldron2D.Test{ dt: float(), events: [term()], game: module(), pending: %{required(term()) => Cauldron2D.Input.state()}, state: term(), ticks: non_neg_integer() }
Functions
Every event drained so far, oldest first.
@spec hold(t(), term(), [atom()], {number(), number()} | nil, %{ required(atom()) => float() }) :: t()
What player id holds from the next tick: a list of actions, an aim, and optionally how hard each action is held.
Join player id with props; the game's refusal is returned as it gave it.
Player id leaves.
A driver for game; options :game_opts (default []) and :hz (default 50).
The game's state.
@spec tick(t(), pos_integer()) :: t()
Run count ticks.
@spec tick_count(t()) :: non_neg_integer()
How many ticks have run.
Tick until condition holds of the driver, at most limit times; {:timeout, driver} when it never did.
The game's view for player id now.