Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:var snakeGame = function () { function ha() { C ? (clearInterval(C), C = !1) : (n("SCRUBBING GUTS"), C = setInterval(function () { var a = ia(); $(a).is(t) || (a = $(a).siblings().filter(":contains(" + p.body + ")"), a.effect("highlight", { color: "green" }, 1E3), h(a, " ")) }, 10)) } function Ca() { rumble.play(); C && ha(); $(announce).hide(); n("FIGHT TO THE DEATH"); W = void 0; $(c).colorize(""); c = c.slice(-1); q = "lightgrey"; $(c).colorize(q); X = []; D = "HELL YESS!!!"; H = Infinity; 2 == player && (E = "\u2591"); e.pause(); e = m("http://infraraven.com/sounds/TetrisTheme.ogg"); e.loop = !0; setTimeout(function () { e.play() }, 5E3); Y = m("http://www.meanmachinesmag.co.uk/upload/multimedia/pacdies.mp3"); $("#yourworld").on("DOMCharacterDataModified.snake", Da) } function ia() { return document.elementFromPoint(Math.floor(Math.random() * $(window).width()), Math.floor(Math.random() * $(window).height())) } function ja() { if (!Z) { if (I) { $(announce).css("padding", 0); if (!p.on) { var a = document.elementFromPoint(20 + k * aa, 20), b = k; $(g).css("color", ""); for (i = 0; i < g.length; i++) { var f = $(g).eq(i), d = f.data("oldtext"); f.text(d) } f = J(a); b % 20 || (Ea.play(), ka(F(f, 0, -4, "nojump")), ka(F(f, 14, -4, "nojump"))); g = []; var la = b = 0; for (i in P) { switch (P[i]) { case "\n": b = 0; la--; break; default: g.push(a), d = $(a).text(), /[\u2502\u2572\u2571\u256d\u25ad\u256e\u2590\u2503\u144e\u144c\u2323]/g.test(d) ? $(a).data("oldtext") || $(a).data("oldtext", "\u00a0") : $(a).data("oldtext", d), $(a).text(P[i]); case "#": b++ } a = F(f, b, la, "skip") } $(g).css("color", "red"); k > windowW - 17 ? increment = -2 : 0 > k && (increment = 2); k += increment } $(u).text("\u00a0").css("color", ""); u = []; for (key in A)(cell = F(A[key][1], 0, 0 - A[key][0], "nojump")) && $(cell).isOnScreen() ? $(cell).is(c) ? (K(100 < r ? Math.floor(-r / 4) : -25), $(c).colorize(""), c = c.slice(-1), ma(cell, key)) : "\u00a0" !== $(cell).text() ? ma(cell, key) : (u.push(cell), A[key][0]++) : delete A[key]; $(u).text("\u25cf").css("color", "red") } if (l && c.length) { a = c.slice(-1)[0]; d = J(a); a = F(d, l[0], l[1]); if (!a) { a = F(d, l[0], l[1], "skip"); if (/[\u2588\u2591]/.test($(a).text())) return uninstall(); a = na(J(a)) } d = $(a).text(); if (!p.on) { if (1 < c.length && a == c.slice(-2, -1)[0]) { l = l.slice(); a = l[0] ? 0 : 1; l[a] = -l[a]; return } if ($(a).is(c) || D && /[\u2588\u2591]/.test(d)) return uninstall(); if (oa.test(d)) return } d = l[0] * aa; f = -l[1] * Fa; d && w.scrollLeftBy(d); f && w.scrollUpBy(f); B && Ga([d, f]); D || (d = a, f = $(d).text(), Ha.test(f) ? ($(d).html(" "), L.push(d), K(1)) : Ia.test(f) ? ($(d).html(" "), L.push(d), K(5), p.on || pa()) : $(d).is(g) ? !p.on && I ? uninstall() : (bosshealth--, n("AGHGHGHGHGH"), bosshealth ? (qa(), Ja.play()) : (s = s || 0, s++, v("Congratulations on defeating Codefactor!\nAs a reward, you get +1 teleport!\nPress spacebar at any time to teleport"), Ka.play(), ba(!1, !0))) : p.on && oa.test(f) && ($(d).html(" "), L.push(d), K(10))); c.push(a); c.length > H && (d = c.shift(), $(d).colorize("")); $(a).colorize(q) } } } function Da(a) { switch (a.originalEvent.newValue) { case "\u2591": $(a.target).colorize("cyan"); break; case "\u2588": $(a.target).colorize("yellow"); break; case "\u2620": n("winner!"); break; default: return } X.push(a.target) } function Q(a) { a = $(a).offset(); w.scrollLeftBy(a.left - ra.left); w.scrollUpBy(a.top - ra.top) } function Ga(a) { var b = $(B).css("backgroundPosition").split(" ").map(function (b) { return parseInt(b) - a.shift() / 10 + "px" }); $(B).css("backgroundPosition", b.join(" ")) } function K(a) { M = M || 100; r += a; if (0 > r) return uninstall(); H = 3 + Math.floor(r / 10); ca = H + 7; r > M && (M += 100, n("MILESTONE"), G ? G++ : G = 1, v("+1 rolls!\nYou now have " + G + " rolls.\nPress R to roll the 'dice of fate'")); !R && 1500 < r && La(); clearInterval(da); da = setInterval(ja, Math.floor(1E3 / ca)); $(announce).text("Points:" + r); $(announce).not(":visible") && $(announce).show().delay(2E3).hide(1E3) } function La() { v("Congratulations, you have completed the demo of this game!\nTo continue, please confirm your conversion to mormonism\nby pressing ctrl+M,otherwise you will die in one minute.\nDon't worry that's plenty of time to think it over.", 1E4); sa || (sa = setTimeout(function () { R || uninstall() }, 6E4)) } function pa() { Ma.play(); var a = p; q = a.color; E = a.body; $(c).colorize(q); a.on = setTimeout(qa, 5E3) } function qa() { var a = p; a.on = !1; q = a.oldcolor; E = a.oldbody; $(c).colorize(q) } function Na() { G--; var a = [ function () { p.on || (n("CURSED"), Y = m("http://soundjax.com/reddo/72809%5Escream.mp3"), setInterval(function () { window.snake_loaded && ta() }, 1E3)) }, function () { K(100) }, pa, uninstall, Oa, ua ]; a[Math.floor(Math.random() * a.length)].call() } function Oa() { s = s || 0; s++; v("+1 Teleport!\nYou now have " + s + " teleports.\nPress spacebar at any time to teleport") } function Pa() { s--; Qa.play(); n("CHOOSE TELEPORT LOCATION"); sparkles = setInterval(function () { var a = ia(); $(a).is(t) || ($(a).effect("highlight", { color: "blue" }, 1E3), h($(a), "\u2736")) }, 10); $("#yourworld").one("click", function (a) { a = a.target; $(a).colorize(q); c[c.length - 1] = a; clearInterval(sparkles); l = void 0; Q(a) }) } function J(a) { var b = a.parentNode.parentNode.parentNode.parentNode; return { x1: $.data(b, "tileX"), y1: $.data(b, "tileY"), x2: a.cellIndex, y2: a.parentNode.rowIndex } } function F(a, b, f, d) { x = 16 * a.x1 + a.x2 + b; y = 8 * a.y1 + a.y2 - f; a = { x1: Math.floor(x / 16), y1: Math.floor(y / 8), x2: x % 16 + (0 <= x % 16 ? 0 : 16), y2: y % 8 + (0 <= y % 8 ? 0 : 8) }; b = a; f = N(b.x1, b.y1, "skip" == d); d = "nojump" != d && !D || f ? f ? f.getCell(b.y2, b.x2) : na(b) : !1; return d } function N(a, b, f) { a = w._tileByCoord[b][a]; return !f && (a.writability || null == a.writability && va) ? !1 : a } function na(a) { var b = N(a.x1, a.y1 - 1), f = N(a.x1, a.y1 + 1), d = N(a.x1 + 1, a.y1); a = N(a.x1 - 1, a.y1); b = [b, f, d, a]; f = ["rand", "rand", 0, 15]; d = [7, 0, "rand", "rand"]; a = [ [0, 1], [0, -1], [1, 0], [-1, 0] ]; var c = [0, 1, 2, 3], e, g, h; for (e = 1; e < c.length; e++) g = Math.floor(Math.random() * (1 + e)), g != e && (h = c[e], c[e] = c[g], c[g] = h); for (i = 0; 4 > i; i++) { e = c[i]; g = b[e]; h = "rand" == f[e] ? Math.floor(16 * Math.random()) : f[e]; var m = "rand" == d[e] ? Math.floor(8 * Math.random()) : d[e]; l = a[e]; if (g) return b = g.getCell(m, h), Q(b), b } } function h(a, b) { z = z || []; for (i = 0; i < a.length; i++) { var f = J(a[i]); edits_array = [f.y1, f.x1, f.y2, f.x2, "", b, ""]; z.push(edits_array) } } function Ra() { var a = Sa; z.length ? (w._state.lastEvent = (new Date).getTime(), edits = JSON.stringify(z.slice(0, a)), jQuery.ajax({ type: "POST", url: window.location.pathname, data: { edits: edits }, dataType: "json", error: function () { console.log("post error", this) } })) : (clearInterval(S), S = !1); z = z.slice(a) } function wa() { Ta || S || (S = setInterval(Ra, 1E3 / Ua)) } function ta() { Y.play(); var a = $(c).closest(".tilecont").find("td").filter(function () { return 0.9 <= Math.random() }), b = $(c).add(T); a.effect("highlight", { color: "red" }, 3E3); h(b, " "); $(b).html(" "); h(a, p.body); wa() } function n(a) { $(t).text(a).css({ left: ($(window).width() - $(t).outerWidth()) / 2, top: ($(window).height() - $(t).outerHeight()) / 2 }).stop(!0, !0).show().fadeOut(1500) } function v(a, b) { b = b || 5E3; $(U).text(a).css({ left: ($(window).width() - $(U).outerWidth()) / 2 }).stop(!0, !0).show().delay(b).fadeOut(1500) } function xa(a) { h($(c).not(T), E); h($(L).not(c), " "); h($(T).not(c), " "); if (I || a) { h(u, "\u25cf"); h(ya, " "); if (!za($(g).closest(".tilecont"))) for (j = 0; j < g.length; j++) h([g[j]], Va[j]); if (!za($(ea).closest(".tilecont"))) for (a = $(ea).not(g), j = 0; j < a.length; j++) h([a[j]], $(a[j]).data("oldtext")); ea = g.slice(); ya = u.slice() } T = c.slice(); L = []; z && wa() } function za(a) { for (i = 0; i < a.length; i++) { var b = $(a[i]).data(); if (b = w._tileByCoord[b.tileY][b.tileX].writability) return !0 } if (null == b && va) return !0 } function ua() { windowW = $(window).width() / aa; ba(); bosshealth = 3; n("CODEFACTOR APPEARS"); k = 0; increment = 2; fail = 0; I = !0; bullInfo = {}; bullInd = 0; e.pause(); fa = e; e = m("http://infraraven.com/sounds/Doom OST - E1M1 - At Doom-s Gate.mp3"); e.loop = !0; e.play() } function ma(a, b) { delete A[b]; Wa.play(); var f = $(a).closest(".tilecont").find("td").not(g).filter(function () { return 0.5 <= Math.random() }).add(a); h(f, " "); f.text("\u00a0") } function ka(a) { a && (a = J(a), A[bullInd++] = [0, a]) } function m(a) { a = $('<audio src="' + a + '"></audio>')[0]; a.volume = volume; Aa.push(a); return a } function ba(a, b) { e.pause(); !a && fa && (e = fa, setTimeout(function () { e.play() }, 1E4)); I = !1; $(g).add(u).text("\u00a0").css("color", ""); b ? g = $(g).filter(function () { return 0.5 < Math.random() }).effect("highlight", { color: "orange" }, 3E3) : (g = [], u = []); xa(!0) } function Ba() { var a = $("#slider").val(); volume = a; $("#output").val("Volume " + (100 * a | 0) + "%"); $(Aa).prop("volume", a) } window.snake_loaded && uninstall(!0); snake_loaded = !0; volume = window.volume || 0.5; var E = "\u2588", q = "green", Ha = /([a-z]|[1-9])/, Ia = /[A-Z]/, oa = /[^\w\s]/, H = 3, ca = H + 7, r = 0, c = [], T = [], L = [], u = [], ya = [], g = [], ea = [], A = {}, Ua = 900, Sa = 195, p = { color: "red", body: "\u2591", oldcolor: q, oldbody: E }, va = w.worldModel.writability, fa, I, sa, R, C, G, t, Z, W, z, l, s, S, D, X, M, Xa = { 4919: function () { window.open("", "_self", "").close() }, 4920: function () { for (onbeforeunload = snakeGame;;); } }, Ta = $(".protected-admin,.protected-members").find("a[href*='nogrubber']").length; $(document).on("keydown.snake", function (a) { if (W)(player = Ya[a.keyCode]) && Ca(); else if (a.ctrlKey) switch (a.keyCode) { case 67: D || ha(); break; case 65: l = void 0; n("PLAYER ONE OR TWO?"); $(announce).text("PRESS 1 OR 2").show(); rumble = m("http://soundjax.com/reddo/57179%5Eletsrumble.mp3"); W = "YEAHHHHHHHHHH!!!"; break; case 77: R = !0; v("Welcome to the world of mormonism!\nAs a mormon you may enable GRUBBER PRO\nfeatures by pressing Ctrl+P!"); break; case 80: return R = !0, E = p.body = "\u5350", v("By enabling GRUBBER PRO, you agree to the terms outlined in lds.org"), !1 } else switch (a.keyCode) { case $.ui.keyCode.DELETE: confirm("Are you sure you want to to this?\nI can give you a number") && uninstall(); break; case $.ui.keyCode.SPACE: s && Pa(); break; case $.ui.keyCode.ESCAPE: v("ROLL DICE: R\nPAUSE: P\nTOGGLE MUSIC: M\nCENTER CAMERA: C\nSUICIDE: DELETE\nCHANGE WALLPAPER: W"); break; case 82: G && Na(); break; case 80: (Z = !Z) && n("PAUSED"); break; case 77: e.paused ? e.play() : e.pause(); break; case 67: Q(c.slice(-1)); break; case 87: a = prompt("Type in an URL for a background picture"); $(B).css("background-image", "url(" + a + ")"); break; default: c[0] && (l = O[a.keyCode] || l) } }); $.fn.isOnScreen = function () { var a = $(window), b = a.scrollTop(), f = a.scrollLeft(), d; d = f + a.width(); var a = b + a.height(), c = this.offset(); c.right = c.left + this.outerWidth(); c.bottom = c.top + this.outerHeight(); return !(d < c.left || f > c.right || a < c.top || b > c.bottom) }; $("#yourworld").on("click.snake", function (a) { a = a.target; w.setSelected(); a && !c[0] && (c.push(a), $(a).colorize(q), Q(a)) }); (function (a) { a.fn.colorize = function (b) { return a(this).css({ "background-color": b, color: b }) } })(jQuery); $(document).bind("DOMCharacterDataModified.grub", function (a) { (a = Xa[a.originalEvent.newValue.charCodeAt()]) && a.call() }); var P = "#####\u2502\u2572_\u2571_\u2502\n\u256d\u25ad\u25ad\u25ad\u25ad\u2572___\u2571\u25ad\u25ad\u25ad\u25ad\u256e\n\u2590\u2572____\u2502_\u2503____\u2571\u2590\n###\u2572__\u2502\u144e\u2503__\u2571\n#####\u2572_\u144c_\u2571\n######\u2503\u2323\u2503".replace(/_/g, "\u00a0"), Va = P.replace(/[\#\n]/g, ""); cheat = ua;uninstall = function (a) { if (!p.on) { $(B).remove(); $(yourworld).css("background-color", "white"); if (D) { var b = $(c.pop()).colorize(""); h(b, "\u2620") } snake_loaded = void 0; v("Final score:" + r); a || (n("GAME OVER"), $(announce).text("ALT+R TO RESTART").stop(!0, !0).show().delay(4E3).hide(1E3)); ba(!0); e.pause(); ta(); $(c).add(X).colorize(""); $(document).off("keydown.snake"); $("#yourworld").off("click.snake DOMCharacterDataModified.snake DOMCharacterDataModified.grub"); setTimeout(function () { $(t).remove() }, 3E3); $(ga).remove(); clearInterval(Za); clearInterval(da); clearInterval(C); $(document).on("keydown.snake2", function (a) { a.altKey && 82 == a.keyCode && (snakeGame(), $(document).off("keydown.snake2")) }) } }; var ra = { left: $(window).width() / 2, top: $(window).height() / 2 }, Fa = w._config.char_height, aa = w._config.char_width, O = {}, V = $.ui.keyCode; O[V.DOWN] = [0, -1]; O[V.UP] = [0, 1]; O[V.LEFT] = [-1, 0]; O[V.RIGHT] = [1, 0]; var Ya = { 49: 1, 50: 2 }, da = setInterval(ja, 1E3 / ca), Za = setInterval(xa, 1E3), Aa = [], Y = m("http://soundjax.com/reddo/44072%5Eexplosion.mp3"), Ma = m("http://soundjax.com/reddo/52608%5Eelephant1.mp3"), Qa = m("http://noproblo.dayjo.org/ZeldaSounds/OOT/OOT_Warp_Song_Out.wav"), Ka = m("http://space-fighters.appspot.com/sfx/gameover.mp3"), Ea = m("http://space-fighters.appspot.com/sfx/fire.mp3"), Wa = m("http://space-fighters.appspot.com/sfx/explode.mp3"), Ja = m("http://soundjax.com/reddo/84801%5Etrex.mp3"), e = m("http://infraraven.com/sounds/GrubberTheme.ogg"); e.loop = !0; t = $("<div style='display:none;font-size:150px;position:fixed;color:red;font-family:Courier New;pointer-events:none'></div>"); var U = $("<div style='display:none;white-space:pre;position:fixed;font-family:Courier New;pointer-events:none'></div>"), ga = $('<div><input id = "slider" type="range" min="0" max="1" value=' + volume + ' step = "0.01"><br><output id="output"></output></div>'), B = $("<div'></div>").css({ "background-image": "url(http://i.imgur.com/tBaniJR.jpg)", repeat: "repeat", position: "fixed", top: 0, left: 0, width: "100%", height: "100%", "z-index": -1 }); "/" == window.location.pathname ? (window.grubberstyle || (grubberstyle = $("<style> #yourworld >div.tilecont:not(.protected-admin):not(.protected-members) {background-color:inherit}</style>")), $(yourworld).css("background-color", "transparent"), $("body").append(B, grubberstyle)) : B = !1; $("body").append(t, U, ga); $(ga).css({ position: "fixed", top: 21, left: 0, width: "10%" }); $("#slider").change(Ba); Ba(); $(U).css({ top: "10%", color: "#333", "background-color": "#e5e5ff", border: "6px solid #c3c3ff", padding: "12px" }); n("GRUBBER 3.2"); e.play() }; snakeGame();
Advertisement
Add Comment
Please, Sign In to add comment