Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. heightmapString = msg.getParams()[0];
  2.  
  3. rows = heightmapString.split("n");
  4. rows.splice(-1,1);
  5. for (y=0;y<rows.length;y++)
  6. {
  7. cols = rows[y].split('');
  8. for (x=0;x<cols.length;x++)
  9. {
  10. finalHeightmapElement = null;
  11.  
  12. if (cols[x] == parseInt(cols[x]) && cols[x] != 0 && cols[x] != 9 && cols[x] != 8)
  13. {
  14.  
  15.  
  16. rowBefore = rows[y-1];
  17. if ((rowBefore == undefined || rowBefore[x] == 9) && rows[y] != undefined && rows[y][x] != 9)
  18. {
  19.  
  20. if (rows[y][x-1] != undefined && rows[y-1] != undefined && rows[y-1][x-1] != undefined)
  21. {
  22. wall = $('');
  23. }else{
  24. wall = $('');
  25. }
  26.  
  27. wall.css('position','absolute');
  28.  
  29. wall.css("left",(x*64+y*64)/2+23-32);
  30. wall.css("top",(y*32-x*32)/2-125);
  31.  
  32. wall.css("z-index",1000+y-1-x-1);
  33.  
  34. $('#images').append(wall);
  35. }
  36.  
  37. if ((cols[x+1] == undefined || cols[x+1] == 9) && cols[x] != 9 && cols[x] != undefined)
  38. {
  39.  
  40. wall = $('');
  41. wall.css('position','absolute');
  42.  
  43. wall.css("left",(x*64+y*64)/2+32);
  44. wall.css("top",(y*32-x*32)/2-125);
  45.  
  46. wall.css("z-index",1000+y-1-x-1);
  47.  
  48. $('#images').append(wall);
  49. }
  50.  
  51. tile = $("<svg xwid=\"1\" width=\"66px\" height=\"40px\" class=\"rtile roomTile"+x+"x"+y+"\" rx=\""+x+"\" ry=\""+y+"\">"+
  52. "<defs>" +
  53. "<clipPath id=\"clipPolygon\">"+
  54. "<polygon points=\"31 0, 29 1, 27 2, 25 3, 23 4, 21 5, 19 6, 17 7, 15 8, 13 9, 11 10, 9 11, 7 12, 5 13, 3 14, 1 15, 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 2 25, 4 26, 6 27, 8 28, 10 29, 12 30, 14 31, 16 32, 18 33, 20 34, 22 35, 24 36, 26 37, 28 38, 30 40, 35 40, 37 38, 39 37, 41 36, 43 35, 45 34, 47 33, 49 32, 51 31, 53 30, 55 29, 57 28, 59 27, 61 26, 63 25, 65 24, 66 23, 66 22, 66 21, 66 20, 66 19, 66 18, 66 17, 66 16, 64 15, 62 14, 60 13, 58 12, 56 11, 54 10, 52 9, 50 8, 48 7, 46 6, 44 5, 42 4, 40 3, 38 2, 36 1, 34 0\">"+
  55. "</polygon>"+
  56. "</clipPath>"+
  57. "</defs>"+
  58. "<image xlink:href=\"./assets/images/tile.png\" x=\"0\" y=\"0\" image-rendering=\"optimizeQuality\" height=\"40px\" width=\"66px\" class=\"tile\" rx=\""+x+"\" ry=\""+y+"\" style=\"clip-path:url(#clipPolygon)\" />"+
  59. "</svg>");
  60. tile.css('position','absolute');
  61.  
  62. tile.css("left",(x*64+y*64)/2);
  63. tile.css("top",(y*32-x*32)/2);
  64.  
  65. lastX = (x*64+y*64)/2;
  66. lastY = (y*32-x*32)/2;
  67.  
  68. tile.css("z-index",1000+y-x);
  69. tile.children(".tile").hover(function(){
  70. $(this).attr('xlink:href',"./assets/images/tileHover.png");
  71. currentTile = $(this);
  72. },function(){
  73. $(this).attr('xlink:href',"./assets/images/tile.png");
  74. currentTile = null;
  75. });
  76.  
  77. tile.children(".tile").mousedown(function(){
  78. dragged = false;
  79. });
  80.  
  81. tile.children(".tile").mouseup(function(){
  82. if (!dragged && !move)
  83. {
  84. msg = new ClientMessage(4);
  85. msg.add($(this).attr('rx'));
  86. msg.add($(this).attr('ry'));
  87. sendMessage(msg);
  88. }
  89. });
  90.  
  91. $('#images').append(tile);
  92. }else{
  93. if (cols[x] == 8)
  94. {
  95.  
  96.  
  97. wall = $('');
  98. wall.css('position','absolute');
  99. wall.addClass('roomTile'+x+'x'+y);
  100.  
  101. wall.css("left",(x*64+y*64)/2+32);
  102. wall.css("top",(y*32-x*32)/2-107);
  103.  
  104. wall.css("z-index",1000+y-x);
  105. wall.css("pointer-events","none");
  106.  
  107.  
  108. dtile = $('<img src="assets/images/tile.png" xwid=\"8\">');
  109. dtile.css('position','absolute');
  110.  
  111. dtile.css('left','67px');
  112. dtile.css("top",(y*32-x*32)/2+1);
  113.  
  114. dtile.css("z-index",997+y-x);
  115.  
  116.  
  117. $('#images').append(dtile);
  118.  
  119. $('#images').append(wall);
  120. }
  121. }
  122.  
  123.  
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement