Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var bomb = {
- char : "⚫",
- location: null,
- exploded: false,
- explosion:{
- 0:" ██████ ████████ ████████ ██████ ",
- 1:"\\ ▓▓▓▓▓▓▓▓▓▓▓▓ / ▓████████████▓ ▓████▓▓▓▓▓▓████▓▓███▓▓▓▓▓▓▓▓███▓▓███▓▓Boom▓▓███▓▓████▓▓▓▓▓▓████▓ ▓████████████▓ / ▓▓▓▓▓▓▓▓▓▓▓▓ \\",
- 2:" ▓ ▓ ▓ ▓ ▒ ░ ▓ ░ ▓ ▓ ░ ░ ░▓░ ▓ ▓ ▓ ▒ ▒░▒░▒░▒▓ ▓ ▒░▒░░▒▒▓ ░ ▒▒▒▒░░▒▓▓ ▓▓ ▓ ▓ ▓ ▓ ▓ ▒ ▓ ░░ ",
- 3:" "
- }
- }
- $("body").append("<style>.tilecont {border: 1px solid #ddd;}</style>")
- var keys = {
- keyleft: jQuery.Event("keydown"),
- };
- keys.keyleft.keyCode = $.ui.keyCode.LEFT
- $(document).on("tap",function(e){
- if (e.shiftKey) {
- bomb.exploded = false;
- $($("textarea")[0]).val(bomb.char)
- setTimeout(function(){$($("textarea")[0]).trigger(keys.keyleft);
- bomb.location = Helpers.getCellCoords($(".active-cursor"))
- setInterval(function(){
- if($(".active-cursor")[0].innerText !== bomb.char){
- explode()
- }
- })
- },10)
- }
- })
- var explode = function(){
- if (bomb.exploded == false){
- clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[0])
- setTimeout(function(){
- clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[1])
- setTimeout(function(){
- clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[2])
- setTimeout(function(){
- clearblock(bomb.location.tileX,bomb.location.tileY,bomb.explosion[3])
- },1000)
- },1000)
- },1000)
- bomb.exploded = true;
- }
- }
- wsaddr = window.location.host;
- path = window.location.pathname.replace(/\/$/, "");
- ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
- ws_path = ws_scheme + "://" + wsaddr + path + "/ws/";
- socket= new WebSocket (ws_path);
- wsQueue = [];
- wsSend = function(data) {
- data = JSON.stringify(data);
- return wsQueue.push(data);
- }
- var clearblock = function(x,y,d){
- var datastring = d;
- var data;
- var i;
- var k;
- var sent;
- i = 0;
- sent = [];
- data = {
- edits: [],
- kind: "write"
- };
- for (k in datastring) {
- sent.push(k);
- data.edits.push([y,x,0,0+k,new Date().getTime(),datastring[k] ,window.nextObjId++]);
- i += 1;
- if (i >= 200) {
- break;
- }
- }
- if (data.edits.length) {
- wsSend(data);
- if (wsQueue.length) {
- try {
- socket.send(wsQueue[0]);
- wsQueue.splice(0, 1);
- } catch (_error) {}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement