Skip to main content

Module grid

Module grid 

Source
Expand description

The tactics kit’s map (game ADR-0038, game ADR-0088): a screen says what is on the visible part of a grid map as a MapScene (plain data), and a GridSkin says how it looks. The skin paints the ground (each tile’s terrain, flashing where it just changed), the ranges by their names, the path, the cursor and the threat arrows; the units are the game’s own view of them, painted by the game’s UnitPainter between the skin’s layers.

Two skins: the GlyphSkin draws each tile as two glyph cells, in its own look or another GlyphStyle (a one-bit screen’s), and the SpriteSkin paints the ground from a tileset’s terrain tiles, with layers between tiles by the corner rule (corners) and the map’s light, at any of the zooms it offers. Both lay their tiles out top-down (Projection). How a game with painters of its own and several looks uses them, with no skin trait of its own: skin’s docs.

With them, the rest of a grid stage’s look: the tile Camera, the virtual Cursor, a path that follows it (steer()) and how long a unit’s walk is shown (walk); and a whole map painted once to pan over (MapPicture). Anything new shown on a map goes in the scene and is painted by every skin; it is never drawn straight into the buffer by a screen.

The debug view’s grid channel shows a scene’s layout over it: the cell lines, the map’s bounds, the cursor’s cell and each unit’s (debug::layout_gizmos, ADR-0085).

Re-exports§

pub use camera::Camera;
pub use cursor::Cursor;
pub use glyph::GlyphSkin;
pub use glyph::GlyphStyle;
pub use layout::CELL_PX;
pub use layout::Grid;
pub use layout::Projection;
pub use layout::px_rect;
pub use picture::MapPicture;
pub use scene::CursorStyle;
pub use scene::CursorView;
pub use scene::Ends;
pub use scene::MapEdges;
pub use scene::MapScene;
pub use scene::MapUnit;
pub use scene::RangeLayer;
pub use scene::RangeName;
pub use scene::ThreatView;
pub use scene::TileView;
pub use scene::Tints;
pub use skin::GridSkin;
pub use skin::Looks;
pub use skin::MapColors;
pub use skin::NoUnits;
pub use skin::TerrainGlyphs;
pub use skin::Terrains;
pub use skin::UnitPainter;
pub use skin::WalkSpeeds;
pub use sprite::SpriteSkin;
pub use steer::steer;
pub use walk::Facing;
pub use walk::Gait;
pub use walk::STANDING_FRAME;

Modules§

camera
The tile camera: which map tiles the viewport shows. How many tiles that is (the view’s size) comes from the grid skin (game ADR-0038).
corners
The corner rule (game ADR-0052): which tiles a picture drawn between tiles joins.
cursor
The virtual cursor on a grid map: which tile it is on, how it moves (one tile per step, never off the map) and how it pulses: between full and about half brightness, never off. A grid skin draws it (CursorView).
debug
The grid kit’s channel of the debug view (ADR-0085): GRID, the layout of a MapScene as its skin laid it out (Grid). A game’s map screen offers it by calling layout_gizmos from its debug_draw:
glyph
The glyph skin: a grid map drawn with colored glyphs (game ADR-0018, game ADR-0024, game ADR-0029). A tile is two 8 × 16 cells: a 16 × 16 pixel square. That size is known only here. A GlyphStyle changes how ranges, flashes, the cursor and the threat marks show on those tiles.
layout
Where a scene’s tiles go on the console, in pixels: what every grid skin works out from its own tile size, and the shared drawing (the path, the threat arrows) works from. The tiles are laid out by a Projection: today top-down squares only (ADR-0003 §6; the isometric one is ticket 1126).
path
The movement path arrow, as every grid skin draws it (game ADR-0018): a 3-px line through tile centres, under the glyphs, from the edge of the unit’s tile, ending in a single arrowhead over the destination tile. Worked out from the skin’s tile size: on the glyph skin’s 16 px tiles the line is pixels 7..=9.
picture
A whole grid map painted once into a buffer just big enough, to pan over (ticket 1154): a cinematic’s backdrop (Pan) or the scene camera’s (debug::camera).
scene
What is on the visible part of a grid map, as plain data (game game ADR-0038): terrain (flashing where it just changed, or marked with what it would turn into), ranges, units, the cursor, the path and those that threaten a tile. No colors, glyphs, cells or pixels: a GridSkin turns a scene into those. The units are the game’s own view of them (U), which only the game’s UnitPainter paints.
skin
A grid skin: how a MapScene looks (game ADR-0038). The skin paints the ground, the ranges, the path, the cursor and the threat arrows; the game’s UnitPainter paints its units, between the skin’s layers. What the skin paints with besides the scene (the palette, the game’s terrains, the lights) it is given as Looks.
sprite
The sprite skin (game ADR-0038, game ADR-0049, game ADR-0052): a grid map’s ground painted from a tileset’s terrain tiles (TerrainTiles).
steer
A unit’s path as the cursor steers it: the player draws a route by moving the cursor, and the path follows. A grid skin draws it (MapScene::path).
threat
The threat arrows, as every grid skin draws them (game ticket 0448): a slim straight arrow from each enemy that could attack a tile to that tile, and a ! above each of those enemies. Over units and terrain, so never hidden. Worked out from the skin’s tile size, in the art’s own pixels.
walk
How units move on a grid map (game ticket 0440): a unit that can still act steps on the spot, and a moving unit glides from tile to tile along its path, its legs going, turned the way it walks. Every timing is here.