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
Every cell in a widening spray from
origintowardstarget: the aim snaps to the nearest of the 8 directions, the length is the distance aimed, and stepioflengthspansround(i / length * width)cells to each side of the centre line. A width of 0 is a single-file beam, the same cellslinewould trace along that snapped direction.