Skip to content

Instantly share code, notes, and snippets.

@unstoppablecarl
Created March 2, 2013 19:49
Show Gist options
  • Save unstoppablecarl/5072952 to your computer and use it in GitHub Desktop.
Save unstoppablecarl/5072952 to your computer and use it in GitHub Desktop.
ig.BackgroundMap.inject({
drawFull: function(context) {
var ctx = context = context || ig.system.context,
scale = ig.system.scale,
tileWidthScaled = Math.floor(this.tilesize * scale),
tileHeightScaled = Math.floor(this.tilesize * scale),
tile;
ctx.save();
ctx.scale(scale, scale);
for( var y = 0; y < this.height; y++) {
for( var x = 0; x < this.width; x++ ) {
var pxX = Math.floor((x) * this.tilesize),
pxY = Math.floor((y) * this.tilesize);
if( (tile = this.data[y][x]) ) {
ig.log(pxX,pxY,tileWidthScaled,tileHeightScaled);
ctx.fillStyle = 'rgba(216,184,123, .2)';
ctx.fillRect(pxX, pxY,tileWidthScaled, tileHeightScaled);
}
} // end for x
} // end for y
ctx.restore();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment