SHARE
TWEET

Untitled

a guest Sep 21st, 2019 78 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. var tapped=false
  22. $(document).on("touchend",function(e){
  23.     if(!tapped){ //if tap is not set, set up single tap
  24.       tapped=setTimeout(function(){
  25.           tapped=null
  26.           //insert things you want to do when single tapped
  27.       },300);   //wait 300ms then run single click code
  28.     } else {    //tapped within 300ms of last tap. double tap
  29.       clearTimeout(tapped); //stop single tap callback
  30.       tapped=null
  31.       //insert things you want to do when double tapped
  32.  
  33. bomb.exploded = false;
  34. $($("textarea")[0]).val(bomb.char)
  35. setTimeout(function(){$($("textarea")[0]).trigger(keys.keyleft);
  36. bomb.location = Helpers.getCellCoords($(".active-cursor"))
  37.  
  38. setInterval(function(){
  39.  
  40. if($(".active-cursor")[0].innerText !== bomb.char){
  41. explode()
  42. }
  43. })
  44. },10)
  45.    }
  46.     e.preventDefault()
  47. });
  48. })
  49.  
  50. var explode = function(){
  51. if (bomb.exploded == false){
  52.  
  53.  
  54. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[0])
  55. setTimeout(function(){
  56. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[1])
  57. setTimeout(function(){
  58. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[2])
  59. setTimeout(function(){
  60. clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[3])
  61.  
  62. },1000)
  63. },1000)
  64. },1000)
  65. bomb.exploded = true;
  66. }
  67.  
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74. wsaddr = window.location.host;
  75. path = window.location.pathname.replace(/\/$/, "");
  76. ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
  77. ws_path = ws_scheme + "://" + wsaddr + path + "/ws/";
  78. socket= new WebSocket (ws_path);  
  79. wsQueue = [];
  80. wsSend = function(data) {
  81.     data = JSON.stringify(data);
  82.     return wsQueue.push(data);
  83.     }
  84.  
  85.  
  86.  
  87. var clearblock = function(x,y,d){
  88. var datastring = d;
  89.             var data;
  90.             var i;
  91.             var k;
  92.             var sent;
  93.  
  94.                 i = 0;
  95.                 sent = [];
  96.                 data = {
  97.                     edits: [],
  98.                     kind: "write"
  99.                 };
  100.  
  101.  
  102.  
  103.                 for (k in datastring) {
  104.                     sent.push(k);
  105.                     data.edits.push([y,x,0,0+k,new Date().getTime(),datastring[k] ,window.nextObjId++]);
  106.                     i += 1;
  107.                     if (i >= 200) {
  108.                         break;
  109.                     }
  110.                 }
  111.                 if (data.edits.length) {
  112.                     wsSend(data);
  113.                     if (wsQueue.length) {
  114.                         try {
  115.                             socket.send(wsQueue[0]);
  116.                             wsQueue.splice(0, 1);
  117.                         } catch (_error) {}
  118.                     }
  119.                 }
  120.            
  121.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top