Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- heightmapString = msg.getParams()[0];
- rows = heightmapString.split("n");
- rows.splice(-1,1);
- for (y=0;y<rows.length;y++)
- {
- cols = rows[y].split('');
- for (x=0;x<cols.length;x++)
- {
- finalHeightmapElement = null;
- if (cols[x] == parseInt(cols[x]) && cols[x] != 0 && cols[x] != 9 && cols[x] != 8)
- {
- rowBefore = rows[y-1];
- if ((rowBefore == undefined || rowBefore[x] == 9) && rows[y] != undefined && rows[y][x] != 9)
- {
- if (rows[y][x-1] != undefined && rows[y-1] != undefined && rows[y-1][x-1] != undefined)
- {
- wall = $('');
- }else{
- wall = $('');
- }
- wall.css('position','absolute');
- wall.css("left",(x*64+y*64)/2+23-32);
- wall.css("top",(y*32-x*32)/2-125);
- wall.css("z-index",1000+y-1-x-1);
- $('#images').append(wall);
- }
- if ((cols[x+1] == undefined || cols[x+1] == 9) && cols[x] != 9 && cols[x] != undefined)
- {
- wall = $('');
- wall.css('position','absolute');
- wall.css("left",(x*64+y*64)/2+32);
- wall.css("top",(y*32-x*32)/2-125);
- wall.css("z-index",1000+y-1-x-1);
- $('#images').append(wall);
- }
- tile = $("<svg xwid=\"1\" width=\"66px\" height=\"40px\" class=\"rtile roomTile"+x+"x"+y+"\" rx=\""+x+"\" ry=\""+y+"\">"+
- "<defs>" +
- "<clipPath id=\"clipPolygon\">"+
- "<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\">"+
- "</polygon>"+
- "</clipPath>"+
- "</defs>"+
- "<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)\" />"+
- "</svg>");
- tile.css('position','absolute');
- tile.css("left",(x*64+y*64)/2);
- tile.css("top",(y*32-x*32)/2);
- lastX = (x*64+y*64)/2;
- lastY = (y*32-x*32)/2;
- tile.css("z-index",1000+y-x);
- tile.children(".tile").hover(function(){
- $(this).attr('xlink:href',"./assets/images/tileHover.png");
- currentTile = $(this);
- },function(){
- $(this).attr('xlink:href',"./assets/images/tile.png");
- currentTile = null;
- });
- tile.children(".tile").mousedown(function(){
- dragged = false;
- });
- tile.children(".tile").mouseup(function(){
- if (!dragged && !move)
- {
- msg = new ClientMessage(4);
- msg.add($(this).attr('rx'));
- msg.add($(this).attr('ry'));
- sendMessage(msg);
- }
- });
- $('#images').append(tile);
- }else{
- if (cols[x] == 8)
- {
- wall = $('');
- wall.css('position','absolute');
- wall.addClass('roomTile'+x+'x'+y);
- wall.css("left",(x*64+y*64)/2+32);
- wall.css("top",(y*32-x*32)/2-107);
- wall.css("z-index",1000+y-x);
- wall.css("pointer-events","none");
- dtile = $('<img src="assets/images/tile.png" xwid=\"8\">');
- dtile.css('position','absolute');
- dtile.css('left','67px');
- dtile.css("top",(y*32-x*32)/2+1);
- dtile.css("z-index",997+y-x);
- $('#images').append(dtile);
- $('#images').append(wall);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement