Search by

vipertecpro / game3d-grid

vipertecpro

Grids for game3d games: square and hex cells in world space, boards, match-3 runs and cascades, turns and A* paths.

Package info

github.com/vipertecpro/game3d-grid

pkg:composer/vipertecpro/game3d-grid

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-11-28 16:05 UTC

This package is auto-updated.

Last update: 2026-11-28 20:03:26 UTC


README

Latest version Tests PHP game3d Platforms Licence Downloads

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 in xy.
  • 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.