Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var bomb = {
  2. char : "⚫",
  3. location: null,
  4. exploded: false,
  5. explosion:{
  6. 0:"                                     ██████         ████████        ████████         ██████                                     ",
  7. 1:"\\ ▓▓▓▓▓▓▓▓▓▓▓▓ / ▓████████████▓ ▓████▓▓▓▓▓▓████▓▓███▓▓▓▓▓▓▓▓███▓▓███▓▓Boom▓▓███▓▓████▓▓▓▓▓▓████▓ ▓████████████▓ / ▓▓▓▓▓▓▓▓▓▓▓▓ \\",
  8. 2:"    ▓      ▓  ▓  ▓  ▒  ░ ▓ ░  ▓   ▓ ░ ░ ░▓░ ▓ ▓   ▓ ▒ ▒░▒░▒░▒▓   ▓  ▒░▒░░▒▒▓        ░ ▒▒▒▒░░▒▓▓   ▓▓  ▓  ▓  ▓  ▓   ▓ ▒  ▓  ░░   ",
  9. 3:"                                                                                                                                "
  10. }
  11. }
  12. $("body").append("<style>.tilecont {border: 1px solid #ddd;}</style>")
  13. var keys = {
  14.     keyleft: jQuery.Event("keydown"),
  15. };
  16.  
  17.  
  18. keys.keyleft.keyCode = $.ui.keyCode.LEFT
  19.  
  20.  
  21. $(document).on("touchstart",function(){
  22. bomb.exploded = false;
  23. $($("textarea")[0]).val(bomb.char)
  24. setTimeout(function(){$($("textarea")[0]).trigger(keys.keyleft);
  25. bomb.location = Helpers.getCellCoords($(".active-cursor"))
  26.  
  27. setInterval(function(){
  28.  
  29. if($(".active-cursor")[0].innerText !== bomb.char){
  30. explode()
  31. }
  32. })
  33. },10)
  34.  
  35. })
  36.  
  37. var explode = function(){
  38. if (bomb.exploded == false){
  39.  
  40.  
  41. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[0])
  42. setTimeout(function(){
  43. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[1])
  44. setTimeout(function(){
  45. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[2])
  46. setTimeout(function(){
  47. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[3])
  48.  
  49. },1000)
  50. },1000)
  51. },1000)
  52. bomb.exploded = true;
  53. }
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61. wsaddr = window.location.host;
  62. path = window.location.pathname.replace(/\/$/, "");
  63. ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
  64. ws_path = ws_scheme + "://" + wsaddr + path + "/ws/";
  65. socket= new WebSocket (ws_path);  
  66. wsQueue = [];
  67. wsSend = function(data) {
  68.     data = JSON.stringify(data);
  69.     return wsQueue.push(data);
  70.     }
  71.  
  72.  
  73.  
  74. var clearblock = function(x,y,d){
  75. var datastring = d;
  76.             var data;
  77.             var i;
  78.             var k;
  79.             var sent;
  80.  
  81.                 i = 0;
  82.                 sent = [];
  83.                 data = {
  84.                     edits: [],
  85.                     kind: "write"
  86.                 };
  87.  
  88.  
  89.  
  90.                 for (k in datastring) {
  91.                     sent.push(k);
  92.                     data.edits.push([y,x,0,0+k,new Date().getTime(),datastring[k] ,window.nextObjId++]);
  93.                     i += 1;
  94.                     if (i >= 200) {
  95.                         break;
  96.                     }
  97.                 }
  98.                 if (data.edits.length) {
  99.                     wsSend(data);
  100.                     if (wsQueue.length) {
  101.                         try {
  102.                             socket.send(wsQueue[0]);
  103.                             wsQueue.splice(0, 1);
  104.                         } catch (_error) {}
  105.                     }
  106.                 }
  107.            
  108.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement