ge
grid-engine
npm i grid-engine
ge

grid-engine

An exceptional plugin for grid-based features in the Phaser 3 engine.

by Johannes Baum

2.16.0 (see all)License:ISCTypeScript:Built-In
npm i grid-engine
Readme

Welcome to the Grid Engine plugin! This Phaser 3 plugin adds grid-based movement to your tilemap game. Your characters will be able to only move in whole tile sizes, locked to the x-y grid!

This plugin is also compatible (and written in) TypeScript; enjoy full type support!

Features

  • Grid-based movement, of course!
  • Tile-based collision detection
  • One-way collision detection
  • Support for multiple characters
  • Pathfinding (for both NPCs and the player)
  • Random movement (can also limit to a radius)
  • Following other characters
  • Diagonal movement (8 directions)
  • Isometric maps (Beta)
  • Multiple character layers (Beta)
  • Collision groups

📖 Read our most current documentation.

➡️ You can try/download a list of examples.

🛠 Also check out the Chrome DevTools plugin.

Installation

Installing the Grid Engine plugin is simple.

NPM

npm i --save grid-engine

Web

<!-- Download the .zip and copy GridEngine.min.js from dist directory -->
<script src="GridEngine.min.js"></script>

Then, inside your Phaser game config...

const gameConfig = {
  // ...

  plugins: {
    scene: [
      {
        key: "gridEngine",
        plugin: GridEngine,
        mapping: "gridEngine",
      },
    ],
  },

  // ...
};

const game = new Phaser.Game(gameConfig);

Now you're all set to start using Grid Engine in your scenes!

function create() {
  // ...

  const gridEngineConfig = {
    characters: [
      {
        id: "player",
        sprite: playerSprite,
        walkingAnimationMapping: 6,
      },
    ],
  };

  this.gridEngine.create(tilemap, gridEngineConfig);

  // ...
}

Example GIFs

Special Thanks

splashsky, therebelrobot, xLink

License

Apache 2.0

Downloads/wk

67

GitHub Stars

106

LAST COMMIT

3mos ago

MAINTAINERS

1

CONTRIBUTORS

6

OPEN ISSUES

24

OPEN PRs

0
VersionTagPublished
2.16.0
latest
1mo ago
No alternatives found
No tutorials found
Add a tutorial