Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Commit

Permalink
added draw hook
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Apr 19, 2013
1 parent 94cf894 commit d4fab68
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function GameEngine()
// information populated by the level scripter
this.gameData = null;

this.drawHooks = null;

this.levelFile = this.storage.getItem(STORAGE_LEVEL);

var self = this;
Expand Down Expand Up @@ -240,6 +242,8 @@ GameEngine.prototype.restart = function()

this.gameData = {};

this.drawHooks = [];

this.loadObjects();

var gameState = this.storage.getItem(STORAGE_STATE);
Expand Down Expand Up @@ -508,6 +512,11 @@ GameEngine.prototype.doTick = function doTick(self)

self.renderer.redraw();

self.drawHooks.forEach(function(f)
{
f.call(self.level, self);
});

requestAnimationFrame(function() { doTick(self); });
};

Expand Down Expand Up @@ -675,6 +684,11 @@ GameEngine.prototype.tick = function(self)
//dbg_log(["NOT_FALLING", "IN_JUMP", "FALLING"][self.fallingState]);
};

GameEngine.prototype.addDrawHook = function(f)
{
this.drawHooks.push(f);
};


// move the character n pixels, detecting collisions
// returns true if character has been blocked by something
Expand Down

0 comments on commit d4fab68

Please sign in to comment.