Advertisement
Guest User

Untitled

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