A tile grid in blocks, for finding a way when the tiles are many: a block is passable when every tile in it is open, and a path is a run of block centres.
coarse = Cauldron2D.Grid.Coarse.new(grid, {width, height}, block: 2, wrap?: true)
{:ok, path} = Cauldron2D.Grid.Coarse.find(coarse, me.pos, enemy.pos)
goal = Cauldron2D.Grid.Coarse.waypoint(grid, me.pos, path)grid is the function Cauldron2D.Collision takes, a tile coordinate to :open,
:solid or a half tile. A point in a block that is not passable — on a base, in a
pocket — starts from, or is sought at, the nearest passable block within two of it.
Summary
Functions
The block the tile at point is in.
The tile position at the centre of a block.
The path from from to to as block centres, or :none when there is none within limit blocks.
The coarse map of grid, size tiles across and down; options :block, tiles to a block (default 2), and :wrap? (default false).
Whether the block holding the tile at point is passable.
The point of path to make for from from: the furthest in a clear straight line on grid, else the first.
Types
@type t() :: %Cauldron2D.Grid.Coarse{ block: pos_integer(), height: pos_integer(), passable: MapSet.t({integer(), integer()}), width: pos_integer(), wrap?: boolean() }
Functions
The block the tile at point is in.
The tile position at the centre of a block.
@spec find(t(), {number(), number()}, {number(), number()}, pos_integer()) :: {:ok, [{float(), float()}]} | :none
The path from from to to as block centres, or :none when there is none within limit blocks.
@spec new(Cauldron2D.Collision.grid(), {pos_integer(), pos_integer()}, keyword()) :: t()
The coarse map of grid, size tiles across and down; options :block, tiles to a block (default 2), and :wrap? (default false).
Whether the block holding the tile at point is passable.
@spec waypoint(Cauldron2D.Collision.grid(), {number(), number()}, [{float(), float()}]) :: {float(), float()}
The point of path to make for from from: the furthest in a clear straight line on grid, else the first.