mwg API
    Preparing search index...

    Class Elevation

    A discrete height per cell: raised platforms, cliffs, pits.

    A sidecar like Secrets and Doors, holding the Level it belongs to rather than living inside it - the still-fundamentally-2D map gains a height value, not a third axis. Every cell starts at 0, the ground everything else is measured against; negative heights are pits, for whatever a game makes of them.

    What reads it: FieldOfView.update takes heights to block sight asymmetrically (a cliff hides what is behind it from below, but not from above), and Pathfinder takes heights with a climb limit. What does not: TileMap draws tiles where the grid says, and sprites stand where the game puts them - a raised cell looks raised because the game offsets its occupants' sprites upward by their height, which is presentation, not pathing, and lives game-side.

    import { Elevation, Level, Pathfinder, FieldOfView, WALL, FLOOR } from '@datamoc/mw_games/roguelike';

    const level = new Level(20, 20, [WALL, FLOOR], 1);
    const heights = new Elevation(level);
    heights.set(5, 5, 2); // a raised platform

    const pathfinder = new Pathfinder(level);
    pathfinder.find({ x: 0, y: 0 }, { x: 5, y: 5 }, { heights, climb: 1 });

    const fov = new FieldOfView(level);
    fov.update(0, 0, 10, { heights, height: 0 }); // sight from ground level
    Index
    • the height of a cell; off the map reads as ground (walking there is refused by Level itself)

      Parameters

      • x: number
      • y: number

      Returns number

    • raises or lowers one cell - heights are whole levels, not fractions

      Parameters

      • x: number
      • y: number
      • height: number

      Returns void