Skip to content

Commit

Permalink
Fixed Perspective map rendering and a couple of other off-limit cases…
Browse files Browse the repository at this point in the history
… with isometric maps
  • Loading branch information
obiot committed Jul 7, 2012
1 parent f752d48 commit f965bf4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/level/TMXRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
var start = this.pixelToTileCoords(viewport.x + rect.pos.x,
viewport.y + rect.pos.y).floor();

var end = this.pixelToTileCoords(viewport.x + rect.pos.x + rect.width,
viewport.y + rect.pos.y + rect.height).ceil();
var end = this.pixelToTileCoords(viewport.x + rect.pos.x + rect.width + this.tilewidth,
viewport.y + rect.pos.y + rect.height + this.tileheight).ceil();

// main drawing loop
for ( var y = start.y ; y < end.y; y++) {
Expand Down Expand Up @@ -144,11 +144,15 @@
*/
drawTileLayer : function(context, layer, viewport, rect) {

// cache a couple of useful references
var tileset = layer.tileset;
var offset = tileset.tileoffset;

// get top-left and bottom-right tile position
var rowItr = this.pixelToTileCoords(viewport.x + rect.pos.x,
viewport.y + rect.pos.y - layer.tileset.tileheight).floor();
var TileEnd = this.pixelToTileCoords(viewport.x + rect.pos.x + rect.width ,
viewport.y + rect.pos.y + rect.height + layer.tileset.tileheight).ceil();
var rowItr = this.pixelToTileCoords(viewport.x + rect.pos.x - tileset.tilewidth,
viewport.y + rect.pos.y - tileset.tileheight).floor();
var TileEnd = this.pixelToTileCoords(viewport.x + rect.pos.x + rect.width + tileset.tilewidth,
viewport.y + rect.pos.y + rect.height + tileset.tileheight).ceil();

var rectEnd = this.tileToPixelCoords(TileEnd.x, TileEnd.y);

Expand Down Expand Up @@ -180,10 +184,6 @@
// Determine whether the current row is shifted half a tile to the right
var shifted = inUpperHalf ^ inLeftHalf;

// cache a couple of useful references
var tileset = layer.tileset;
var offset = tileset.tileoffset;

// main drawing loop
for (var y = startPos.y; y - this.tileheight < rectEnd.y; y += this.hTileheight) {
var columnItr = rowItr.clone();
Expand Down

0 comments on commit f965bf4

Please sign in to comment.