Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 13th, 2012  |  syntax: None  |  size: 2.44 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function load() {
  2.                                 var i = 0;
  3.                                 var j = 0;
  4.                                 var x = 0;
  5.                                 var y = 0;
  6.                                 for(i=0;i<19;i++)
  7.                                 {
  8.                                         for(j=0;j<19;j++)
  9.                                         {
  10.                                                 x = j * 32;
  11.                                                 y = i * 32;
  12.                                                 if(j == 18 && i == 18){
  13.                                                         $("<div id='tilebase_"+j+"_"+i+"' onClick='addtile(this);'/>").appendTo("#maparea").css({'position' : 'absolute', 'top' : y+'px', 'left' : x+'px', 'border-right' : '0px', 'border-bottom' : '0px', 'width' : '32px', 'height' : '32px'});
  14.                                                         var cell = new Array('left', 'top');
  15.                                                 }else{
  16.                                                         if(j == 18){
  17.                                                                 $("<div id='tilebase_"+j+"_"+i+"' onClick='addtile(this);'/>").appendTo("#maparea").css({'position' : 'absolute', 'top' : y+'px', 'left' : x+'px', 'border-right' : '0px', 'border-bottom' : '1px solid #ff0000', 'width' : '32px', 'height' : '32px'});
  18.                                                         }else if(i == 18){
  19.                                                                 $("<div id='tilebase_"+j+"_"+i+"' onClick='addtile(this);'/>").appendTo("#maparea").css({'position' : 'absolute', 'top' : y+'px', 'left' : x+'px', 'border-bottom' : '0px', 'border-right' : '1px solid #ff0000', 'width' : '32px', 'height' : '32px'});
  20.                                                         }else{
  21.                                                                 $("<div id='tilebase_"+j+"_"+i+"' onClick='addtile(this);'/>").appendTo("#maparea").css({'position' : 'absolute', 'top' : y+'px', 'left' : x+'px', 'border-bottom' : '1px solid #ff0000', 'border-right' : '1px solid #ff0000', 'width' : '32px', 'height' : '32px'});
  22.                                                         }
  23.                                                         var cell = new Array('left', 'top');
  24.                                                 }
  25.                                                 xcell.push(cell);
  26.                                         }
  27.                                         ycell.push(xcell);
  28.                                 }
  29.                                 $("<div id='tilelist' />").prependTo("#toolarea");
  30.                                 $("<select id='tileselect' />").appendTo("#tilelist").css({'width' : '200px'});
  31.                                 mapjson = JSON.stringify(ycell);
  32.                                 console.log(mapjson);
  33.                                 for(i=0;i<terrain_tiles.length;i++)
  34.                                 {
  35.                                         if(i == 0)
  36.                                         {
  37.                                                 $("<option value='"+i+"' selected>"+terrain_tile_name[i]+"</option>").appendTo("#tileselect").css({'background-image' : 'url(terrain_set.png)', 'background-repeat' : 'no-repeat', 'background-position' : terrain_tiles[i][0]+' '+terrain_tiles[i][1]});
  38.                                         }
  39.                                         else
  40.                                         {
  41.                                                 $("<option value='"+i+"'>"+terrain_tile_name[i]+"</option>").appendTo("#tileselect").css({'background-image' : 'url(terrain_set.png)', 'background-repeat' : 'no-repeat', 'background-position' : terrain_tiles[i][0]+' '+terrain_tiles[i][1]});
  42.                                         }
  43.                                 }
  44.                                 $("<input type='hidden' id='maparray' value='' />").appendTo("#toolarea");
  45.                                 //$("<input type='submit' id='saveme' value='Save Map' />").appendTo("#toolarea");
  46.                         }