Cauldron2D.Net.Link.Local (Cauldron2D.Net v0.1.2)

Copy Markdown View Source

A player's connection to a world reachable as a process — on this node, or on a node this one is connected to — through Cauldron2D.Net.Session, so the frames arrive in the same shape a Cauldron2D.Net.Link.Socket delivers.

{:ok, link} = Cauldron2D.Net.Link.Local.start_link(game: MyGame.Client, world: pid, name: "alice", props: %{}, owner: self())

The owner receives {:cauldron_link, :sheet, sheet, png} once, {:cauldron_link, :map, map} once, {:cauldron_link, :frame, frame} each tick and {:cauldron_link, :closed, reason} when the world goes. Sound plays through :sink (default TuningFork.Sink.Speaker), on this machine. input/2, levels/3 and leave/1 are what the player does.

Summary

Functions

Returns a specification to start this module under a supervisor.

What the player holds and aims at, as Cauldron2D.Wx.Input.state/1 gives it.

Leave the world and stop.

The effects and music levels.

Pause or resume a world of the player's own; nothing for a shared one.

Join :world as :name with :props for :game, reporting to :owner.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

input(link, state)

@spec input(GenServer.server(), %{held: [String.t()], aim: [number()] | nil}) :: :ok

What the player holds and aims at, as Cauldron2D.Wx.Input.state/1 gives it.

leave(link)

@spec leave(GenServer.server()) :: :ok

Leave the world and stop.

levels(link, sfx, music)

@spec levels(GenServer.server(), number(), number()) :: :ok

The effects and music levels.

pause(link)

@spec pause(GenServer.server()) :: :ok

Pause or resume a world of the player's own; nothing for a shared one.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Join :world as :name with :props for :game, reporting to :owner.