diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-05-10 02:17:14 -0700 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-05-10 02:17:14 -0700 |
commit | 86aac4847705f0a4559400da6c0e9f1aeba5cdf8 (patch) | |
tree | c8c43ab196e5a0a4d280ea84152be5d0e061e0c7 /js/mapspecs.js | |
parent | 51d99728286212717003009dd5706bb74edcb272 (diff) | |
download | pathery-86aac4847705f0a4559400da6c0e9f1aeba5cdf8.tar.xz |
Many bugs and PHP notices & warning fixes.
Diffstat (limited to 'js/mapspecs.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>";
}
}
|