Home » Posts tagged "phaser.js"

Inheritance with phaser.js

Today’s short one to celebrate moving from dev.kofun to main domain – only code snippet, no further explanations.
How to make subclass for pharser.js class?

Let’s make subclass of Sprite, and call it Ghost.

function Ghost(game, args){
	Phaser.Sprite.call(this, game, args);

// Add Sprite object prototype as Ghost prototype
Ghost.prototype = Object.create(Phaser.Sprite.prototype);
Ghost.prototype.constructor = Ghost;

And we use it like:

var tmpGhost = new Ghost(game);

// and add it to game like this:

Illusion of Intelligence – AI for Pacman

PacmanGIFAfter screwing up main game loop for Untangle (see postmortem) I really, really wanted to try using complete game-making framework, rather than writing everything from scratch. I decided to write simple pacman clone with phaser.js.

Today I’ll write about implementing AI for pacman’s ghosts. I assume that you already know rules behind ghosts behaviour (if not check awesome articles on GameInternals or Pac-man Dossier).

You can find pacman’s code on github. If you want to play newest version online click here.
Read more