Okay im having a problem with drawing an isometric map exported from tiled.
Here is my problem.
where it should be like this
Here is the code that i used to reproduce the 1st image, what's wrong with it?
for (var y = 0; y < this.height; y++){
for (var x = 0; x < this.width; x++){
counter++;
var sprite = this.tilemap.getSprite(this.data[ counter ], this);
var drawX = 0, drawY = 0;
if ( sprite ) {
var cell = sprite.cell[ this.data[counter] ];
if (!cell) continue;
if (this.orientation == 'isometric') {
// Isometric maps
drawX = x * cell.w;
drawY = y * cell.h;
}
if (sprite && cell){
Engine.currentGame.ctx.drawImage(
sprite.sprite.img,
cell.x,
cell.y,
cell.w,
cell.h,
drawX,
drawY,
cell.w,
cell.h
);
}
}
}
}
game.currentGame.ctx.restore();
return this;
};
UPDATE:
var counter = 0;
game.currentGame.ctx.save();
for (var x = 0; x < this.width; x++){
for (var y = 0; y < this.height; y++){
counter++;
var sprite = this.tilemap.getSprite(this.data[ counter ], this);
var drawX = 0, drawY = 0;
if ( sprite ) {
//console.log( counter );
var cell = sprite.cell[ this.data[counter] ];
if (!cell) continue;
if (this.orientation == 'isometric') {
// Isometric maps
drawX = x * cell.w;
drawY = y * cell.h;
}
if (sprite && cell){
Engine.currentGame.ctx.drawImage(
sprite.sprite.img,
cell.x,
cell.y,
cell.w,
cell.h,
drawX,
drawY,
cell.w,
cell.h
);
}
}
}
}
game.currentGame.ctx.restore();
return this;