A classic XPilot map read for play: the block legend, the features on it, and the options ExPilot honours.
{:ok, arena} = ExPilot.Map.parse_file("priv/maps/dogfight.map.gz")
ExPilot.Map.grid(arena).({12, 7})
ExPilot.Map.bases(arena)
ExPilot.Map.option(arena, :gravity)Block legend
| char | tile |
|---|---|
space, . | open |
x | wall |
q s a w | half walls filling the bottom-right, bottom-left, top-right and top-left corners |
# | fuel station |
_, 0–9 | base, team bases |
r d f c | cannons facing up, left, down and right |
@ ( ) | wormhole, wormhole in, wormhole out |
+ - > < | gravity attracting, repelling, clockwise, anticlockwise |
i m k j | gravity pulling up, down, right, left |
* | treasure |
! | target |
b h g y t | decoration, drawn as walls but not collided with |
A–Z | race checkpoints, in order |
Anything else is open space.
Options
option/2 reads edgewrap, teamplay, teamimmunity, gravity, gravityangle,
gravitypoint, gravitypointsource, friction, shotspeed,
shotlife, maxrobots, maxplayershots, limitedlives, worldlives, mapname,
mapauthor, maxunshieldedwallbouncespeed and maxshieldedwallbouncespeed (in
XPilot's units per frame), wallbouncefueldrainmult, racemode, racelaps, targets,
itemprobmult, maxitemdensity, every item…prob, initialfuel and every
initial… item count, allowshields, shotswallbounce, shotsgravity,
allowplayerkilling (playerkillings), allowplayercrashes, allowplayerbounces,
playerwallbouncebrakefactor, targetkillteam, treasurekillteam,
dropitemonkillprob, laserisstungun, minefusetime and firerepeatrate (frames),
shieldeditempickup, shieldedmining, ballswallbounce, checkpointradius and
playersonradar, with XPilot's defaults where the map is silent — except the
unshielded bounce speed, whose default here is 3.5 units per frame so that a ship at
cruising speed still crashes, the bounce brake factor (0.5) and the fire rate (4 frames).
gravity_point/1 is the gravitypoint option as a point.
Summary
Functions
The art name a tile is drawn with, or nil for open space.
Bases, each %{pos: {x, y}, team: team | nil, dir: dir}, in map order.
Cannons, each %{pos: {x, y}, facing: :up | :down | :left | :right}.
Race checkpoints in order.
Fuel station tiles.
The gravitypoint option, "x,y" in blocks, as the centre of that block.
Gravity points, each %{pos: {x, y}, kind: kind} with the kinds the legend lists.
The collision grid as Cauldron2D.Collision reads it.
What the legend makes of one character; nil for open space.
The map's name from its header.
An option ExPilot honours, converted, with XPilot's default when the map is silent.
Parse map text (edgewrap wraps it); {:error, reason} as Cauldron2D.Map.parse/2 gives it.
Read and parse a map file, gzipped or not.
The map's size in tiles.
Where the targets are.
The tile at point, wrapped when the map wraps; nil for open space.
Treasure tiles.
Wormholes, each %{pos: {x, y}, kind: :normal | :in | :out}.
Whether the map wraps at its edges.
Types
Functions
The art name a tile is drawn with, or nil for open space.
Bases, each %{pos: {x, y}, team: team | nil, dir: dir}, in map order.
dir is the way a ship on the base faces: away from the wall it sits on — :up over
a floor, :down under a ceiling, :right off a wall on its left, :left off one on
its right — and :up with no wall touching it.
Cannons, each %{pos: {x, y}, facing: :up | :down | :left | :right}.
Race checkpoints in order.
Fuel station tiles.
The gravitypoint option, "x,y" in blocks, as the centre of that block.
Gravity points, each %{pos: {x, y}, kind: kind} with the kinds the legend lists.
@spec grid(t()) :: Cauldron2D.Collision.grid()
The collision grid as Cauldron2D.Collision reads it.
Walls and half walls are solid; everything else is open. Outside a map that does not wrap is solid; a wrapping map reads the tile on the other side.
What the legend makes of one character; nil for open space.
The map's name from its header.
An option ExPilot honours, converted, with XPilot's default when the map is silent.
Parse map text (edgewrap wraps it); {:error, reason} as Cauldron2D.Map.parse/2 gives it.
Read and parse a map file, gzipped or not.
@spec size(t()) :: {pos_integer(), pos_integer()}
The map's size in tiles.
Where the targets are.
The tile at point, wrapped when the map wraps; nil for open space.
Treasure tiles.
Wormholes, each %{pos: {x, y}, kind: :normal | :in | :out}.
Whether the map wraps at its edges.