vipertecpro / game3d-grid
Grids for game3d games: square and hex cells in world space, boards, match-3 runs and cascades, turns and A* paths.
Requires
- php: ^8.5
- vipertecpro/game3d: ^2.1
Requires (Dev)
- pestphp/pest: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-28 20:03:26 UTC
README
An add-on for game3d, a paid plugin for NativePHP Mobile sold at https://vipertecpro.com/products/game3d-engine (Android only). This add-on is free and MIT, and needs game3d to run. It is an independent project, not made or endorsed by NativePHP.
Grids for games made with game3d: board games, match-3, tactics, puzzles. PHP only, MIT.
use Vipertecpro\Game3dGrid\{Grid, Cell, Board, Matches, Cascade, Pathfinder, Turns}; $grid = Grid::square(8, 8, 1.0, origin: [-3.5, -3.5]); // on the ground (xz) $grid2d = Grid::hex(7, 6, 1.0, plane: 'xy'); // facing a camera2d $grid->toWorld(new Cell(2, 3)); // [x, y, z] of its centre $grid->toCell([1.2, 0, -0.4]); // the cell under a point, or null $runs = Matches::find($board); // rows and columns of 3+ $steps = Cascade::resolve($board, fn (Cell $c) => $kinds[array_rand($kinds)]); $path = Pathfinder::find($grid, $from, $to, blocked: $walls); // A* $turns = Turns::of(['red', 'blue']);
The add-on's scene builders: gridDraggable() (snaps to the cells; a drop off the board goes back, and the drag event's point is a cell: $grid->cellAt($point)), gridPlace(),
gridWalk() (a path, cell by cell, then the kit.grid.arrived event),
gridPop() (pieces pop in turn) and gridFall() (pieces drop with a bounce).
Install
This add-on needs a game3d licence. From your dashboard at vipertecpro.com, add the game3d Composer repository and key (the two composer config commands shown there), then:
composer require vipertecpro/game3d-grid
- Cells: cell (0, 0) is centred on
origin. Columns run along +x; rows run along +z, or down the screen inxy. - Hex grids: pointy-top, with odd rows pushed half a cell right.
- Gravity: pieces fall toward the last row.
- Pathfinding: costs per cell are optional. With costs, the search is Dijkstra.
Testing
The tests need game3d ^2.1, which is not public, so they run where a licensed copy is
installed: add the game3d repository as in Install, then run composer install and
vendor/bin/pest.