diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/mapspecs.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js index f55eb14..1a0693f 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -876,15 +876,19 @@ function mapAsHTML(map, targetWidth, mapEditor) { var scale = map.width / targetWidth;
//alert(scale);
- var width = parseInt(map.width / scale);
- var height = parseInt(map.height / scale);
- var tileWidth = parseInt(width / map.width);
+ //var width = parseInt(map.width / scale);
+ //var height = parseInt(map.height / scale);
- width = tileWidth * map.width;
+ var tileWidth = parseInt((map.width / scale) / map.width);
+ var tileHeight = tileWidth;
+
+ var width = tileWidth * map.width;
+ var height = tileHeight * map.height;
var mapgrid = '';
mapgrid += '<div style="clear:both;"></div><div class="map playable" style="width:'+width+'px; height:'+height+'px">';
+
for (var y in map.tiles) {
for (var x in map.tiles[y]) {
var type = map.tiles[y][x][0];
@@ -901,13 +905,13 @@ function mapAsHTML(map, targetWidth, mapEditor) { //oldy is used for Position too... for now
if (mapEditor == true) {
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onMouseOver='mapEditOver(this)' onMouseDown='mapEditClick(this)' >";
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileHeight+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onMouseOver='mapEditOver(this)' onMouseDown='mapEditClick(this)' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
} else if (type == 'o') {
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onClick='grid_click(this)' >";
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileHeight+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onClick='grid_click(this)' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
} else {
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='"+Tile[type]+" "+value+" On: "+x+","+oldy+"' id='"+idHandle+"' >";
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileHeight+"px; ' class='mapcell "+type+value+"' title='"+Tile[type]+" "+value+" On: "+x+","+oldy+"' id='"+idHandle+"' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
}
}
|