Advertisement
Guest User

Untitled

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