The Wayback Machine - https://web.archive.org/web/20230626211855/https://github.com/Annoraaq/grid-engine
Skip to content

Annoraaq/grid-engine

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
June 8, 2023 20:03
June 21, 2023 17:47
June 21, 2023 17:50
January 14, 2023 18:44
January 8, 2023 18:53
June 4, 2023 18:17
src
June 21, 2023 19:43
April 23, 2023 18:38
April 23, 2023 17:52
March 13, 2021 19:21
November 16, 2021 17:59
November 3, 2021 16:24
June 21, 2023 17:50
June 21, 2023 17:47
April 23, 2023 18:17

Grid Engine Logo

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!

Features

Basic

  • Grid-based movement, of course!
  • Tile-based collision detection
  • NEW! - Headless mode (allows running it independently of Phaser)
  • Diagonal movement (8 directions)
  • Isometric maps
  • Multiple character layers
  • Multi-tile characters

Movement / Pathfinding

  • Pathfinding (for both NPCs and the player)
  • Random movement (can also limit to a radius)
  • Following other characters
  • Collision groups

๐Ÿ“– Read our most current documentation.

โžก๏ธ You can try/download a list of examples.

๐Ÿ‘พ Join our discord.

๐Ÿ›  Also check out the Chrome DevTools plugin.

Installation

Installing the Grid Engine plugin is simple.

NOTE: For TypeScript check out this example repository.

NPM

npm i --save grid-engine

And then import via:

import { GridEngine } from "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);

  // ...
}

Import Helpers

Besides the GridEngine main class, you can also import several helpers. For example there is the directionFromPos helper function that gives you a Direction from a source to a target position.

If you are importing the NPM module you can import it like:

import {
  GridEngine, // GridEngine main class
  directionFromPos, // One of the GridEngine helpers,
  // ...
} from "grid-engine";

If you are using the web version (import via <script>), all exported functions and classes besides GridEngine are stored in a global variable GridEngineImports.

So you would use it as follows:

GridEngineImports.directionFromPos(/*...*/);

Projects using Grid Engine

If you have a project that is using Grid Engine and that you would like to see in this list, post it in the #showcase channel on our Discord.

Special Thanks

Raiper34, splashsky, therebelrobot, xLink,

License

Apache 2.0