PR pixi-reels

computeDropOffsets()

pixi-reels


pixi-reels / index / computeDropOffsets

Function: computeDropOffsets()

function computeDropOffsets(
   visibleRows: number, 
   winnerRows: readonly number[], 
   options?: {
  initial?: boolean;
}): DropOffset[];

Defined in: cascade/tumbleAlgorithm.ts:61

Compute per-row drop offsets for one reel given its winner set.

Returns one entry per visible row, top-to-bottom. Rows with offsetRows === 0 should NOT be animated. they’re survivors that didn’t move.

Convention (Moment B): the new grid must place new symbols at the top winnerRows.length rows and survivors at the bottom rows in their original top-to-bottom order. This matches how server-side gravity simulations emit cascade results.

Parameters

ParameterTypeDescription
visibleRowsnumber-
winnerRowsreadonly number[]-
options{ initial?: boolean; }-
options.initial?booleanWhen true (Moment A. the player’s first spin click), every row is treated as new regardless of winnerRows (which is normally empty for initial spins). When false (Moment B . cascade refill), an empty winnerRows means no movement on this reel; survivor reels in a refill correctly return all-zero offsets. Default false so callers can’t accidentally trigger a full re-drop on a reel that had no winners.

Returns

DropOffset[]