mwg API
    Preparing search index...

    Function coneCells

    • Every cell in a widening spray from origin towards target: the aim snaps to the nearest of the 8 directions, the length is the distance aimed, and step i of length spans round(i / length * width) cells to each side of the centre line. A width of 0 is a single-file beam, the same cells line would trace along that snapped direction.

      Parameters

      • origin: Step
      • target: Step
      • width: number

      Returns Step[]

      import { coneCells, chainTargets, knockbackPath, Level, WALL, FLOOR } from '@datamoc/mw_games/roguelike';

      const breath = coneCells({ x: 5, y: 5 }, { x: 5, y: 0 }, 3); // a dragon's breath, aimed north

      const monsters = [{ x: 5, y: 4 }, { x: 5, y: 3 }, { x: 6, y: 2 }];
      const arc = chainTargets(monsters, { x: 5, y: 5 }, 3, 2); // a lightning bolt hopping between them

      const level = new Level(20, 20, [WALL, FLOOR], 1);
      const shovedTo = knockbackPath(level, { x: 5, y: 5 }, { x: 1, y: 0 }, 3); // shoved 3 cells east