Posts Tagged ‘grid’

  • Phaser Coding Tips 5

    Phaser Coding Tips is a free weekly email – subscribe here.

    phaser-tips-header1

    After a couple of weeks spent working on platform game mechanics I felt we ought to take a small break. Therefore this weeks tutorial is based on an often requested feature on the forum: grid movement. Or more specifically, “How to move around a grid smoothly like Pacman”.

    We’ll cover the code needed to gracefully slide around a tilemap, turning on a dime and create the full core of a Pacman game.

    Get the source

    I’m only going to highlight the most important parts of the code here. So please always look at the source first. If you’ve questions about something I didn’t cover then ask on the forum.

    Run / Edit the Cars code on jsbin or codepen
    Run / Edit the Pacman code on jsbin or codepen

    Clone the phaser-coding-tips git repo.

    lets-code-header

    The Basic Set-up

    We’ll need a player sprite and a tilemap. The tilemap contains the layout of the level. Here we’ve drawn a simple level in Tiled:

    tiled

    This is exported as a JSON file and loaded into our game, along with the tileset. In the create method we set our objects up:
    Read More