Advertisement
Guest User

Untitled

a guest
Jan 29th, 2013
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <html>
  3. <head>
  4.         <title>Editor</title>
  5.         <script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
  6.         <script type="text/javascript">
  7.  
  8. var tiles = [];        
  9. var draw = 0;
  10. var w = 0;
  11. var h = 0;
  12.  
  13. $(document).ready(function() {
  14.     $('#tile-selector img').click(function() {
  15.         draw = $(this).attr("tile");
  16.     });
  17. });
  18.  
  19. function run() {
  20.     w = $("#w").val();
  21.     h = $("#h").val();
  22.    
  23.     for (var i = 0; i < h; i++) {
  24.             tiles[i] = [];
  25.     }
  26.  
  27.     for (var y = 0; y < h; y++) {
  28.             for (x = 0; x < w; x++) {
  29.                     $("#box").append("<img src='src/" + draw +".png' x='"+ x +"' y='"+ y +"' height='15' width='15'></img>");              
  30.                     tiles[x][y] = draw;
  31.             }
  32.             $("#box").append("<br />");
  33.     }
  34.  
  35.      $("#box img").click(function() {
  36.             $(this).attr("src", "src/" + draw +".png");
  37.             tiles[$(this).attr("x")][$(this).attr("y")] = draw;
  38.      });
  39. }
  40.    
  41. function end() {
  42.     var output = "";
  43.     for (var x = 0; x < w; x++) {
  44.         for (var y = 0; y < h; y++) {
  45.             output += "tiles["+ x +"+"+ y +"*width] =" + tiles[x][y] +";\r\n";
  46.         }    
  47.     }
  48.  
  49.     $("#output").val(output);
  50. }
  51.  
  52. </script>
  53. </head>
  54. <body>
  55.  
  56.         width<input type="text" id="w"></input>
  57.         height<input type="text" id="h"></input>
  58.         <input type="button" id="s" value="start" onclick="run();"></input>
  59.         <input type="button" id="s" value="end" onclick="end();"></input>
  60.         <div id="tile-selector">
  61.             <img src="src/0.png" height="15" width="15" tile="0">
  62.             <img src="src/1.png" height="15" width="15" tile="1">
  63.             <img src="src/2.png" height="15" width="15" tile="2">
  64.             <img src="src/3.png" height="15" width="15" tile="3">
  65.             <img src="src/4.png" height="15" width="15" tile="4">
  66.             <img src="src/5.png" height="15" width="15" tile="5">
  67.             <img src="src/6.png" height="15" width="15" tile="6">
  68.             <img src="src/7.png" height="15" width="15" tile="7">
  69.             <img src="src/8.png" height="15" width="15" tile="8">
  70.             <img src="src/9.png" height="15" width="15" tile="9">
  71.             <img src="src/10.png" height="15" width="15" tile="10">
  72.             <img src="src/11.png" height="15" width="15" tile="11">
  73.             <img src="src/12.png" height="15" width="15" tile="12">
  74.             <img src="src/13.png" height="15" width="15" tile="13">
  75.             <img src="src/14.png" height="15" width="15" tile="14">
  76.             <img src="src/15.png" height="15" width="15" tile="15">
  77.             <img src="src/16.png" height="15" width="15" tile="16">
  78.             <img src="src/17.png" height="15" width="15" tile="17">
  79.             <img src="src/18.png" height="15" width="15" tile="18">
  80.             <img src="src/19.png" height="15" width="15" tile="19">
  81.             <img src="src/20.png" height="15" width="15" tile="20">
  82.             <img src="src/21.png" height="15" width="15" tile="21">
  83.             <img src="src/22.png" height="15" width="15" tile="22">
  84.             <img src="src/23.png" height="15" width="15" tile="23">
  85.             <img src="src/24.png" height="15" width="15" tile="24">
  86.             <img src="src/25.png" height="15" width="15" tile="25">
  87.             <br>
  88.             <img src="src/26.png" height="15" width="15" tile="26">
  89.             <img src="src/27.png" height="15" width="15" tile="27">
  90.             <img src="src/28.png" height="15" width="15" tile="28">
  91.             <img src="src/29.png" height="15" width="15" tile="29">
  92.             <img src="src/30.png" height="15" width="15" tile="30">
  93.             <img src="src/31.png" height="15" width="15" tile="31">
  94.             <img src="src/32.png" height="15" width="15" tile="32">
  95.             <img src="src/33.png" height="15" width="15" tile="33">
  96.             <img src="src/34.png" height="15" width="15" tile="34">
  97.             <img src="src/35.png" height="15" width="15" tile="35">
  98.             <img src="src/36.png" height="15" width="15" tile="36">
  99.             <img src="src/37.png" height="15" width="15" tile="37">
  100.             <img src="src/38.png" height="15" width="15" tile="38">
  101.             <img src="src/39.png" height="15" width="15" tile="39">
  102.             <img src="src/40.png" height="15" width="15" tile="40">
  103.             <img src="src/41.png" height="15" width="15" tile="41">
  104.             <img src="src/42.png" height="15" width="15" tile="42">
  105.  
  106.            
  107.            
  108.         </div>
  109. <div id="box"></div>
  110. Output<br />
  111. <textarea id="output" style="width: 600px; height: 300px;"></textarea>
  112. </div>
  113. </body>
  114. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement