ElixirDoom.Weapons (elixir_doom v0.1.0)

Copy Markdown View Source

The weapon a player holds: the two pictures drawn over the view — the weapon and its muzzle flash — each running through its own states, raising, lowering, readying and firing, and what each weapon does when it fires.

tick/2 runs one tic of player id's weapon. The pictures' positions, sx and sy, are in Doom's 320 by 200 screen: the weapon is up at 32 and down at 128.

Summary

Functions

Raise player id's pending weapon, or the one in hand.

Lower player id's weapon, as when they die.

Whether player has the ammunition to fire weapon.

Put player id's slot (:weapon or :flash) into state, running its actions.

One tic of player id's weapon and flash.

Functions

bring_up(world, id)

@spec bring_up(ElixirDoom.World.t(), term()) :: ElixirDoom.World.t()

Raise player id's pending weapon, or the one in hand.

drop(world, id)

Lower player id's weapon, as when they die.

has_ammo?(player, weapon)

@spec has_ammo?(map(), atom()) :: boolean()

Whether player has the ammunition to fire weapon.

set(world, id, slot, state)

@spec set(ElixirDoom.World.t(), term(), :weapon | :flash, atom() | nil) ::
  ElixirDoom.World.t()

Put player id's slot (:weapon or :flash) into state, running its actions.

tick(world, id)

One tic of player id's weapon and flash.