Guest User

Untitled

a guest
Oct 22nd, 2016
1,525
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Copyright 2016 Stan Tatarnykov
  2. (function() {
  3. var t = {
  4. scope: {}
  5. };
  6. t.defineProperty = "function" == typeof Object.defineProperties ? Object.defineProperty : function(t, e, a) {
  7. if (a.get || a.set) throw new TypeError("ES3 does not support getters and setters.");
  8. t != Array.prototype && t != Object.prototype && (t[e] = a.value)
  9. };
  10. t.getGlobal = function(t) {
  11. return "undefined" != typeof window && window === t ? t : "undefined" != typeof global ? global : t
  12. };
  13. t.global = t.getGlobal(this);
  14. t.polyfill = function(e, a, i, n) {
  15. if (a) {
  16. i = t.global;
  17. e = e.split(".");
  18. for (n = 0; n < e.length - 1; n++) {
  19. var r = e[n];
  20. r in i || (i[r] = {});
  21. i = i[r]
  22. }
  23. e = e[e.length - 1];
  24. n = i[e];
  25. a = a(n);
  26. a != n && null != a && t.defineProperty(i, e, {
  27. configurable: !0,
  28. writable: !0,
  29. value: a
  30. })
  31. }
  32. };
  33. t.polyfill("Array.prototype.fill", function(t) {
  34. return t ? t : function(t, e, a) {
  35. var i = this.length || 0;
  36. 0 > e && (e = Math.max(0, i + e));
  37. if (null == a || a > i) a = i;
  38. a = Number(a);
  39. 0 > a && (a = Math.max(0, i + a));
  40. for (e = Number(e || 0); e < a; e++) this[e] = t;
  41. return this
  42. }
  43. }, "es6-impl", "es3");
  44. t.polyfill("Math.trunc", function(t) {
  45. return t ? t : function(t) {
  46. t = Number(t);
  47. if (isNaN(t) || Infinity === t || -Infinity === t || 0 === t) return t;
  48. var e = Math.floor(Math.abs(t));
  49. return 0 > t ? -e : e
  50. }
  51. }, "es6-impl", "es3");
  52. var e = 120,
  53. a = [];
  54. a.push({
  55. name: "USA 1 (New York)",
  56. ip: "45.79.152.38"
  57. });
  58. a.push({
  59. name: "USA 2 (New York)",
  60. ip: "173.255.237.64"
  61. });
  62. a.push({
  63. name: "USA 3 (California)",
  64. ip: "45.33.53.86"
  65. });
  66. a.push({
  67. name: "Brazil/ USA 4 (Texas)",
  68. ip: "45.33.12.194"
  69. });
  70. a.push({
  71. name: "Europe 1 (Germany)",
  72. ip: "139.162.173.197"
  73. });
  74. a.push({
  75. name: "Europe 2 (London)",
  76. ip: "88.80.189.198"
  77. });
  78. a.push({
  79. name: "Asia",
  80. ip: "103.3.63.181"
  81. });
  82. var i = Math.min(a.length - 1, Et(0, 5)),
  83. n = a[i];
  84. if ("undefined" !== typeof Storage) {
  85. console.log("Last used server is " + localStorage.getItem("lastServerIP"));
  86. for (var r = localStorage.getItem("lastServerIP"), s = 0; s < a.length; s++) a[s].ip == r && (i = s, n = a[i])
  87. }
  88. var l = .18,
  89. h = .1,
  90. o = "#3FBA54",
  91. c = "#09992F",
  92. f = "#09992F",
  93. m = "#4E66E4",
  94. g = "#4655A6",
  95. u = "#F35F53",
  96. y = "#CF6259",
  97. p = 1,
  98. w = 2,
  99. I = 3,
  100. P = 4,
  101. b = 5,
  102. M = 6,
  103. x = 7,
  104. U = 8,
  105. v = 9,
  106. A = 10,
  107. T = 11,
  108. S = 1,
  109. k = 2,
  110. E = 3,
  111. C = 4,
  112. D = 5,
  113. B = 6,
  114. R = 7,
  115. O = 8,
  116. F = 9,
  117. _ = 10,
  118. Y = 11,
  119. L = 12,
  120. W = 13,
  121. X = 14,
  122. N = document.getElementById("gCanvas"),
  123. z = null,
  124. H = null,
  125. G = N.getContext("2d"),
  126. V = 5,
  127. q = V,
  128. j = camy = n_camx = n_camy = o_camx = o_camy = 0,
  129. Z = 0,
  130. J = 0,
  131. K = 0,
  132. Q = 0,
  133. $ = 0,
  134. tt = 0,
  135. et = !1,
  136. at = !1,
  137. it, nt, rt = 0,
  138. st = 0,
  139. lt = "",
  140. ht = 0,
  141. ot = !1,
  142. dt = !1,
  143. ct = !1,
  144. ft = water = 100,
  145. mt = xp = xpPer = 0,
  146. gt = 0,
  147. ut = +new Date,
  148. yt = 0,
  149. pt = 0,
  150. wt = "",
  151. It = 100,
  152. Pt = Array(20).fill(0),
  153. bt = Array(20).fill(0),
  154. Mt = Array(20).fill(0),
  155. xt = [],
  156. Ut = {},
  157. vt = [],
  158. At = +Date.now(),
  159. Tt;
  160. St();
  161. Qt();
  162. Zt();
  163.  
  164. function St() {
  165. Ut = {};
  166. xt = [];
  167. vt = [];
  168. ft = water = 100;
  169. water = ft = mt = xpPer = xp = 0;
  170. wt = "";
  171. document.getElementById("spawnXpLabel").style.display = wt ? "block" : "none";
  172. document.getElementById("spawnXpLabel").textContent = wt
  173. }
  174.  
  175. function kt(t, e) {
  176. return Math.random() * (e - t) + t
  177. }
  178.  
  179. function Et(t, e) {
  180. return Math.floor(Math.random() * (e - t + 1)) + t
  181. }
  182.  
  183. function Ct(t) {
  184. t = Math.trunc(t) % 360 + (t - Math.trunc(t));
  185. return 0 < t ? t : t + 360
  186. }
  187.  
  188. function Dt(t) {
  189. return 180 / Math.PI * t
  190. }
  191.  
  192. function Bt(t) {
  193. return Math.PI / 180 * t
  194. }
  195.  
  196. function Rt(t, e, a, i) {
  197. return Math.atan2(i - e, a - t)
  198. }
  199.  
  200. function Ot(t, e) {
  201. return 0 != (t >> e) % 2
  202. }
  203.  
  204. function Ft(t, e, a) {
  205. return a ? t | 1 << e : t & ~(1 << e)
  206. }
  207.  
  208. function _t(t, e) {
  209. var a = Ct(Dt(e - t));
  210. 180 < a && (a -= 360);
  211. return Bt(a)
  212. }
  213.  
  214. function Yt(t, e, a) {
  215. return Math.min(a, Math.max(e, t))
  216. }
  217.  
  218. function Lt(t) {
  219. return unescape(encodeURIComponent(t))
  220. }
  221.  
  222. function Wt(t) {
  223. return decodeURIComponent(escape(t))
  224. }
  225.  
  226. function Xt(t, e, a) {
  227. var i = 1.2 * G.measureText("M").width;
  228. t = t.split("\n");
  229. for (var n = 0; n < t.length; ++n) G.fillText(t[n], e, a), a += i
  230. }
  231.  
  232. function Nt(t) {
  233. var e = parseInt(t, 10),
  234. a = Math.floor(e / 3600);
  235. t = Math.floor((e - 3600 * a) / 60);
  236. e = e - 3600 * a - 60 * t;
  237. 10 > e && (e = "0" + e);
  238. return t + ":" + e
  239. }
  240.  
  241. function zt(t) {
  242. return 1e3 > t ? t : Math.round(t / 1e3 * 10) / 10 + "k"
  243. }
  244. Ht.prototype = {
  245. id: 0,
  246. oType: B,
  247. spawnTime: 0,
  248. rPer: 0,
  249. updateTime: 0,
  250. x: 0,
  251. y: 0,
  252. ox: 0,
  253. oy: 0,
  254. nx: 0,
  255. ny: 0,
  256. rad: 0,
  257. oRad: 0,
  258. nRad: 0,
  259. z: 0,
  260. name: "",
  261. dead: !1,
  262. type: 0
  263. };
  264.  
  265. function Ht(t, e, a, i, n) {
  266. this.id = t;
  267. this.oType = e;
  268. this.ox = this.x = this.nx = a;
  269. this.oy = this.y = this.ny = i;
  270. this.nRad = n;
  271. this.oRad = this.rad = 0;
  272. if (e == Y || e == X) this.oRad = this.rad = n;
  273. this.hpPer = this.hpPer_n = this.hpBarA = this.hpBarA_n = this.angle = this.angledelta = 0;
  274. this.rPer = kt(0, 1);
  275. this.spawnTime = +Date.now();
  276. this.updateTime = ae;
  277. this.flag_hurt = !1;
  278. this.oType == k && (this.flag_tailBitten = this.flag_lowWat = !1);
  279. if (this.oType == k || this.oType == F || this.oType == W) this.chatTxt = "", this.chatFadeT = ae - 1, this.chatA = 0;
  280. this.updateZ = function() {
  281. switch (this.oType) {
  282. case X:
  283. this.z = -111;
  284. break;
  285. case Y:
  286. this.z = -110;
  287. break;
  288. case W:
  289. this.z = -101;
  290. break;
  291. case F:
  292. this.z = -100;
  293. break;
  294. case E:
  295. this.z = 999;
  296. break;
  297. case D:
  298. this.z = 1001;
  299. break;
  300. case C:
  301. this.z = 1002;
  302. break;
  303. case L:
  304. this.z = 9999;
  305. break;
  306. case _:
  307. this.z = 1e4;
  308. break;
  309. default:
  310. this.z = this.type == T ? 1004 : this.type == U ? 1e3 : this.rad
  311. }
  312. };
  313. this.draw = function() {
  314. var t = this.moveUpdate();
  315. G.save();
  316. G.translate(this.x, this.y);
  317. if (this.oType == B || this.oType == R || this.oType == O || this.oType == F || this.oType == W) {
  318. var e;
  319. e = (ae - this.spawnTime) / 1e3;
  320. var a = this.oType == O ? 2 : 1.3;
  321. if (this.oType == F || this.oType == W) a = 2.5;
  322. e = (this.oType == F || this.oType == W ? .04 : .1) * Math.sin(2 * Math.PI / a * e);
  323. G.scale(1 + e, 1 + e / 2)
  324. }
  325. this.dead && (G.globalAlpha *= 1 - t);
  326. this.oType == E ? this.drawCircle("", c) : this.oType == D ? this.drawCircle("", y) : this.oType == C ? this.drawCircle("", g) : this.oType == B ? 4 != this.type ? this.drawCircle("", u) : this.drawCircle("", "#B8413B") : this.oType == O ? (G.strokeStyle = c, G.lineWidth = 2, G.beginPath(), G.rect(-5, 0, 10, .83 * this.rad), G.fillStyle = "#FFCA49", G.fill(), G.stroke(), G.beginPath(), G.arc(0, 0, this.rad, Math.PI, 2 * Math.PI), G.fillStyle = "#CFAD59", G.fill(), G.stroke()) : this.oType == F ? (G.fillStyle = "#9F8641", G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.strokeStyle = c, G.lineWidth = 1.5, G.stroke(), G.fillStyle = "#7E6A35", G.beginPath(), G.arc(0 - this.rPer, 0 - this.rPer, Math.max(0, this.rad - 5), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#5C4E28", G.beginPath(), G.arc(0 + this.rPer, 1, Math.max(0, this.rad - 10), 0, 2 * Math.PI), G.fill()) : this.oType == W ? (G.fillStyle = "#9F8641", G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.strokeStyle = c, G.lineWidth = 1.5, G.stroke(), G.fillStyle = "#7E6A35", G.beginPath(), G.arc(0 - this.rPer, 0 - this.rPer, Math.max(0, this.rad - 5), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#5C4E28", G.beginPath(), G.arc(0 + this.rPer, 1, Math.max(0, this.rad - 12), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#40371D", G.beginPath(), G.arc(0 - 2 * this.rPer - 3, 1, Math.max(0, this.rad - 16.5), 0, 2 * Math.PI), G.fill()) : this.oType == _ ? (G.save(), e = (ae - this.spawnTime) / 1e3, e = 1.5 * Math.sin(2 * Math.PI / 2 * e), G.fillStyle = "#45D157", G.globalAlpha = .93, G.beginPath(), G.arc(.5 * -this.rad, .5 * -this.rad + 10 * this.rPer, Math.max(0, .65 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * this.rad, .5 * -this.rad - 10 * this.rPer, Math.max(0, .73 * this.rad - e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.6 * this.rad, .4 * this.rad, Math.max(0, .78 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * -this.rad, .5 * this.rad, Math.max(0, .6 * this.rad + this.rPer - e), 0, 2 * Math.PI), G.fill(), G.restore()) : this.oType == Y ? (G.save(), G.rotate(2 * this.rPer * Math.PI), e = (ae - this.spawnTime) / 1e3, e = 1.5 * Math.sin(2 * Math.PI / 6 * e), G.globalAlpha = 1, t = 4, G.fillStyle = "#8B7833", G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.fillStyle = "#98803A", G.globalAlpha = 1, G.beginPath(), G.arc(0, 0, Math.max(0, this.rad - t + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.45 * this.rad, .45 * -this.rad + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * this.rad, .5 * this.rad + 15 * this.rPer, Math.max(0, .4 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.55 * -this.rad * .707, .55 * +this.rad * .707 + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.75 * -this.rad, .35 * -this.rad + 15 * this.rPer, Math.max(0, .3 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad + 10 * this.rPer, 50 * this.rPer, 8, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad - 20 * this.rPer, 50 * this.rPer, 10, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.restore()) : this.oType == X ? (G.save(), G.rotate(2 * this.rPer * Math.PI), e = (ae - this.spawnTime) / 1e3, e = 5.5 * Math.sin(2 * Math.PI / 4 * e), G.globalAlpha = 1, t = 4, G.fillStyle = m, G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.fillStyle = g, G.beginPath(), G.arc(0, 0, Math.max(0, this.rad - t + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.45 * this.rad, .45 * -this.rad + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * this.rad, .5 * this.rad + 15 * this.rPer, Math.max(0, .4 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.55 * -this.rad * .707, .55 * +this.rad * .707 + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.75 * -this.rad, .35 * -this.rad + 15 * this.rPer, Math.max(0, .3 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad + 10 * this.rPer, 50 * this.rPer, 8, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad - 20 * this.rPer, 50 * this.rPer, 10, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.restore()) : this.oType == L ? this.drawCircle("", "#8C9688") : this.oType == R ? this.drawCircle("", m) : this.oType == k ? (this.drawAnimal(), this.drawPlayerText(t)) : this.drawCircle("????", "black");
  327. this.hpBarA += .1 * (this.hpBarA_n - this.hpBarA);
  328. .001 < this.hpBarA && (this.hpPer += .1 * (this.hpPer_n - this.hpPer), a = Math.max(1, this.rad / 25), t = 20 * a, e = 5 * a, a = -this.rad - 10 * a, G.globalAlpha *= this.hpBarA, G.fillStyle = "rgba(0,0,0,0.35)", G.fillRect(0 - t / 2, a - e / 2, t, e), G.fillStyle = "#16D729", G.fillRect(0 - t / 2, a - e / 2, this.hpPer / 100 * t, e));
  329. G.restore()
  330. };
  331. this.drawChat = function() {
  332. if (this.chatTxt) {
  333. var t = ae > this.chatFadeT ? 0 : 1;
  334. this.chatA += .1 * (t - this.chatA);
  335. .001 > this.chatA ? .001 > t && (this.chatTxt = "") : (G.save(), G.font = "10px Arial", G.lineWidth = 1, G.textAlign = "center", G.textBaseline = "middle", G.globalAlpha = .8 * this.chatA, G.fillStyle = c, t = G.measureText(this.chatTxt).width, G.fillRect(this.x - 1 - t / 2, this.y - this.rad - 10 - 5 - 1, t + 2, 12), G.fillStyle = "#F1C34C", G.shadowOffsetX = 1, G.shadowOffsetY = 1, G.shadowColor = "black", G.globalAlpha = this.chatA, G.fillText(this.chatTxt, this.x, this.y - this.rad - 10), G.restore())
  336. }
  337. };
  338. this.gotChat = function(t) {
  339. this.chatFadeT = ae + 3e3;
  340. this.chatTxt = t
  341. };
  342. this.drawCircle = function(t, e) {
  343. G.save();
  344. G.fillStyle = c;
  345. G.beginPath();
  346. G.arc(0, 0, this.rad, 0, 2 * Math.PI);
  347. G.fill();
  348. G.fillStyle = e;
  349. G.beginPath();
  350. G.arc(0, 0, Math.max(0, this.rad - 1.5), 0, 2 * Math.PI);
  351. G.fill();
  352. t && (G.globalAlpha = .15, G.fillStyle = "white", G.textBaseline = "middle", G.textAlign = "center", G.fillText(t, 0, 0));
  353. G.restore()
  354. };
  355. this.drawAnimal = function() {
  356. var t;
  357. switch (this.type) {
  358. case p:
  359. t = "#9BA9B9";
  360. break;
  361. case w:
  362. t = "#AA937E";
  363. break;
  364. case I:
  365. t = "#DD6BD4";
  366. break;
  367. case P:
  368. t = "#FF9D43";
  369. break;
  370. case b:
  371. t = "#C4773E";
  372. break;
  373. case M:
  374. t = "#f8c923";
  375. break;
  376. case x:
  377. t = "#CAC05B";
  378. break;
  379. case U:
  380. t = "#99591C";
  381. break;
  382. case v:
  383. t = "#30F51C";
  384. break;
  385. case A:
  386. t = "#945A99";
  387. break;
  388. case T:
  389. t = "#22FF8A";
  390. break;
  391. default:
  392. t = "#000000"
  393. }
  394. G.save();
  395. G.rotate(this.angle);
  396. var e = (ae - this.spawnTime) / 1e3,
  397. a = 2.5 + .7 * Math.sin(2 * Math.PI / 2.5 * e),
  398. i;
  399. i = 0 < Pt[this.type - 1] ? "#EF3C31" : 0 < bt[this.type - 1] ? "#4AE05E" : c;
  400. G.fillStyle = i;
  401. G.beginPath();
  402. G.arc(0, 0, this.rad, 0, 2 * Math.PI);
  403. G.fill();
  404. G.fillStyle = t;
  405. G.beginPath();
  406. G.arc(0, 0, Math.max(0, this.rad - a), 0, 2 * Math.PI);
  407. G.fill();
  408. this.flag_hurt && (G.fillStyle = "rgba(255,0,0,0.3)", G.beginPath(), G.arc(0, 0, Math.max(0, this.rad - a), 0, 2 * Math.PI), G.fill());
  409. if (this.type >= w) {
  410. var e = (ae - this.spawnTime) / 1e3,
  411. e = 4 * Math.sin(2 * Math.PI / 5 * e),
  412. n = 2.5 * a,
  413. r = .08 * this.rad,
  414. s = Math.PI / 180;
  415. G.fillStyle = this.flag_tailBitten ? "#EF3C31" : 0 < Mt[this.type - 1] ? "#4AE05E" : i;
  416. G.beginPath();
  417. G.moveTo((this.rad - a + 1) * Math.cos((281 + n) * s), (this.rad - a + 1) * Math.sin(281 * s));
  418. G.lineTo((this.rad - a + 1) * Math.cos((259 - n) * s), (this.rad - a + 1) * Math.sin(259 * s));
  419. G.lineTo((this.rad + r + a) * Math.cos((270 + e) * s), (this.rad + r + a) * Math.sin((270 + e) * s));
  420. G.lineTo((this.rad - a + 1) * Math.cos((281 + n) * s), (this.rad - a + 1) * Math.sin(281 * s));
  421. G.fill();
  422. G.fillStyle = this.flag_tailBitten ? "#EF3C31" : t;
  423. G.beginPath();
  424. G.moveTo((this.rad - a) * Math.cos(281 * s), (this.rad - a) * Math.sin(281 * s));
  425. G.lineTo((this.rad - a) * Math.cos(259 * s), (this.rad - a) * Math.sin(259 * s));
  426. G.lineTo((this.rad + r) * Math.cos((270 + e) * s), (this.rad + r) * Math.sin((270 + e) * s));
  427. G.lineTo((this.rad - a) * Math.cos(281 * s), (this.rad - a) * Math.sin(281 * s));
  428. G.fill()
  429. }
  430. this.type == A ? (G.beginPath(), G.arc(.2 * this.rad, .7 * this.rad, Math.max(0, .55 * this.rad - a), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.2 * -this.rad, .7 * this.rad, Math.max(0, .55 * this.rad - a), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#8C96A6", G.beginPath(), G.arc(-(.29 * this.rad), .7 * this.rad + 10, Math.max(0, 3 - a / 2), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.29 * this.rad, .7 * this.rad + 10, Math.max(0, 3 - a / 2), 0, 2 * Math.PI), G.fill()) : this.type == x ? (G.fillStyle = "#B5AE4C", G.beginPath(), G.arc(.1 * this.rad, -.45 * this.rad, .13 * this.rad, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(-.4 * this.rad, -.2 * this.rad, .12 * this.rad, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.15 * this.rad, -.25 * this.rad, .16 * this.rad, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.63 * this.rad, -.4 * this.rad, .1 * this.rad, 0, 2 * Math.PI), G.fill()) : this.type == b ? (G.fillStyle = "#E5C870", G.beginPath(), t = .35 * -this.rad, a = .1 * -this.rad, G.moveTo(t, a), G.lineTo(t + .25 * this.rad, a), G.lineTo(t - .35 * this.rad, a - 15), G.fill(), G.beginPath(), t = .35 * this.rad, a = .1 * -this.rad, G.moveTo(t, a), G.lineTo(t - .25 * this.rad, a), G.lineTo(t + .35 * this.rad, a - 15), G.fill()) : this.type == U && (G.fillStyle = "black", G.beginPath(), G.arc(0, this.rad - 3, Math.max(0, 5 - a / 2), 0, 2 * Math.PI), G.fill());
  431. G.save();
  432. t = Math.max(1, this.rad / 25);
  433. G.scale(t, t);
  434. this.drawEyeAtPos(6, .32 * this.rad);
  435. this.drawEyeAtPos(-6, .32 * this.rad);
  436. G.restore();
  437. G.restore();
  438. this.flag_lowWat && (a = .5 * (.8 - .2), a = .2 + a + a * Math.sin(2 * Math.PI / 1.2 * (ae / 1e3)), G.save(), G.globalAlpha = a, G.fillStyle = m, G.beginPath(), G.arc(0, this.rad + 5, 5 * t, 0, 2 * Math.PI), G.fill(), G.restore())
  439. };
  440. this.drawPlayerText = function(t) {
  441. G.save();
  442. G.lineWidth = 1;
  443. G.textAlign = "center";
  444. G.textBaseline = "middle";
  445. G.shadowOffsetX = 1;
  446. G.shadowOffsetY = 1;
  447. G.shadowColor = "black";
  448. G.fillStyle = "white";
  449. G.globalAlpha = this.dead ? G.globalAlpha * (1 - t) : 1;
  450. yOffset = this.rad + 9;
  451. this.name && (G.font = "10px Arial", G.fillText(this.name, 0, 0 + yOffset), yOffset += 12);
  452. G.restore()
  453. };
  454. this.drawEyeAtPos = function(t, e) {
  455. G.beginPath();
  456. G.arc(t, e, 4.5, 0, 2 * Math.PI);
  457. G.fillStyle = "black";
  458. G.fill();
  459. G.beginPath();
  460. G.fillStyle = "white";
  461. G.arc(t - 2, e - 1, .99, 0, 2 * Math.PI);
  462. G.fill()
  463. };
  464. this.moveUpdate = function() {
  465. var t = (ae - this.updateTime) / 1e3 / l,
  466. t = 0 > t ? 0 : 1 < t ? 1 : t;
  467. this.dead && 1 <= t && vt.push(this);
  468. this.x = t * (this.nx - this.ox) + this.ox;
  469. this.y = t * (this.ny - this.oy) + this.oy;
  470. this.rad += .1 * (this.nRad - this.rad);
  471. if (this.oType == k) {
  472. var e = .1 * this.angleDelta;
  473. this.angleDelta -= e;
  474. this.angle += e
  475. }
  476. return t
  477. }
  478. }
  479.  
  480. function Gt(t) {
  481. this.data = t;
  482. this.offset = 0;
  483. this.readUInt8 = function() {
  484. var t = this.data.getUint8(this.offset);
  485. this.offset += 1;
  486. return t
  487. };
  488. this.readUInt16 = function() {
  489. try {
  490. var t = this.data.getUint16(this.offset, !1);
  491. this.offset += 2;
  492. return t
  493. } catch (t) {
  494. return 0
  495. }
  496. };
  497. this.readUInt32 = function() {
  498. var t = this.data.getUint32(this.offset, !1);
  499. this.offset += 4;
  500. return t
  501. };
  502. this.readString = function() {
  503. for (var t = this.readUInt16(), e = "", a, i = 0; i < t; i++) a = this.readUInt8(), i != t - 1 && (e += String.fromCharCode(a));
  504. return Wt(e)
  505. }
  506. }
  507.  
  508. function Vt(t) {
  509. this.len = 0;
  510. this.dataView = new DataView(new ArrayBuffer(t));
  511. this.writeUInt8 = function(t) {
  512. this.dataView.setUint8(this.len, t);
  513. this.len += 1
  514. };
  515. this.writeUInt16 = function(t) {
  516. this.dataView.setUint16(this.len, t, !1);
  517. this.len += 2
  518. };
  519. this.writeInt16 = function(t) {
  520. this.dataView.setInt16(this.len, t, !1);
  521. this.len += 2
  522. };
  523. this.writeUInt32 = function(t) {
  524. this.dataView.setUint32(this.len, t, !1);
  525. this.len += 4
  526. };
  527. this.writeString = function(t) {
  528. t = Lt(t);
  529. len = t.length;
  530. this.writeUInt16(t.length);
  531. for (var e = 0; e < len; e++) this.writeUInt8(t.charCodeAt(e))
  532. }
  533. }
  534. var qt, jt = 0;
  535.  
  536. function Zt() {
  537. !ct && 1 < jt && (i += 1, i > a.length - 1 && (i = 0), n = a[i], Kt());
  538. document.getElementById("connecting").style.visibility = "visible";
  539. console.log("Connecting to " + n.name + " (" + n.ip + ")...");
  540. Tt = new WebSocket("ws://" + n.ip + ":7020");
  541. Tt.binaryType = "arraybuffer";
  542. Tt.onopen = function() {
  543. jt = 0;
  544. document.getElementById("startMenu").style.visibility = "visible";
  545. document.getElementById("connecting").style.visibility = "hidden"
  546. };
  547. Tt.onmessage = function(t) {
  548. $t(new DataView(t.data))
  549. };
  550. Tt.onclose = function(t) {
  551. this == Tt && (jt += 1, qt = setTimeout(function() {
  552. Zt()
  553. }, 2e3), dt = !1, document.getElementById("connecting").style.visibility = "visible")
  554. };
  555. Tt.onerror = function() {
  556. console.log("socket error!")
  557. }
  558. }
  559. document.getElementById("serverSelect").onchange = Jt;
  560.  
  561. function Jt() {
  562. i = document.getElementById("serverSelect").selectedIndex;
  563. n = a[i];
  564. Kt();
  565. console.log("Server changed...");
  566. ee() && Tt.close();
  567. Zt()
  568. }
  569.  
  570. function Kt() {
  571. "undefined" !== typeof Storage && localStorage.setItem("lastServerIP", n.ip);
  572. document.getElementById("serverSelect").selectedIndex = i
  573. }
  574.  
  575. function Qt() {
  576. for (var t = document.getElementById("serverSelect"); t.lastChild;) t.removeChild(t.lastChild);
  577. for (var e = 0; e < a.length; e++) {
  578. var i = document.createElement("option");
  579. i.text = a[e].name;
  580. t.add(i)
  581. }
  582. t.selectedIndex = 0
  583. }
  584.  
  585. function $t(t) {
  586. msg = new Gt(t);
  587. msgType = msg.readUInt8();
  588. switch (msgType) {
  589. case 1:
  590. nPlayers = msg.readUInt16();
  591. lt = nPlayers + " players";
  592. serverVer = msg.readUInt16();
  593. serverVer > e ? setTimeout(function() {
  594. window.location.reload()
  595. }, 700) : (document.getElementById("startMenuWrapper").style.display = "block", ge(!0));
  596. break;
  597. case 2:
  598. 1 == msg.readUInt8() ? (spectating = 2 == msg.readUInt8(), ot = !spectating, ct = dt = !0, ht = msg.readUInt32(), myRoomID = msg.readUInt16(), rt = msg.readUInt16(), st = msg.readUInt16(), j = o_camx = n_camx = msg.readUInt16() / 4, camy = o_camy = n_camy = msg.readUInt16() / 4, q = msg.readUInt16() / 1e3, V = 2 * q, spectating || se(msg), spectating || (document.getElementById("startMenuWrapper").style.display = "none", window.onbeforeunload = function(t) {
  599. return "You're alive in a game, close mope.io?"
  600. }), St()) : alert("Couldn't join a game, server is too full. Try another server, or please try again later.");
  601. break;
  602. case 8:
  603. t = msg.readUInt8();
  604. var a = msg.readUInt8(),
  605. i = msg.readUInt8();
  606. lbData = [];
  607. for (s = 0; s < i; ++s) lbData.push({
  608. rank: msg.readUInt8(),
  609. name: msg.readString(),
  610. score: msg.readUInt32()
  611. });
  612. le(lbData, t, a);
  613. break;
  614. case 10:
  615. nPlayers = msg.readUInt16();
  616. lt = nPlayers + " players";
  617. break;
  618. case 18:
  619. t = msg.readUInt8();
  620. It = msg.readUInt32();
  621. switch (t) {
  622. case p:
  623. oe = "A little mouse...\n Drink water, eat berries to grow!";
  624. break;
  625. case w:
  626. oe = "UPGRADED to rabbit:\nEat animals circled in light-green (You can now eat MICE!)";
  627. break;
  628. case I:
  629. oe = "UPGRADED to PIG:\n You can now eat MUSHROOMS\n+ Pigs swim through MUD/Lakes quickly!";
  630. break;
  631. case P:
  632. oe = "UPGRADED to FOX! ,\n (You can hide inside red berry bushes!)";
  633. break;
  634. case b:
  635. oe = "UPGRADED to DEER:\n Eat ONLY MUSHROOMS!";
  636. break;
  637. case M:
  638. oe = "UPGRADED to LION:\n Rawr, let's hunt Foxes and DEER!";
  639. break;
  640. case x:
  641. oe = "UPGRADED to CHEETAH:\n You're super quick!- Let's chase someone...";
  642. break;
  643. case U:
  644. oe = "UPGRADED to BEAR:\n Bears climb through green hills! (And can swim pretty well too)";
  645. break;
  646. case v:
  647. oe = "UPGRADED to CROCODILE (nice!):\n(Now hide in water spots) + Swim well in Mud & Lakes!";
  648. break;
  649. case A:
  650. oe = "UPGRADED to HIPPO! :\nHippos swim in MUD, and especially lakes!";
  651. break;
  652. case T:
  653. oe = "UPGRADED to DRAGON! (WOW, you're amazing!):\nDominate the lands, fly over hills!";
  654. break;
  655. default:
  656. oe = "Upgraded!"
  657. }
  658. de = "white";
  659. ce = +new Date + 5e3;
  660. Pt = Array(20).fill(0);
  661. t = msg.readUInt8();
  662. for (a = 0; a < t; a++) Pt[msg.readUInt8() - 1] = 1;
  663. bt = Array(20).fill(0);
  664. t = msg.readUInt8();
  665. for (a = 0; a < t; a++) bt[msg.readUInt8() - 1] = 1;
  666. Mt = Array(20).fill(0);
  667. t = msg.readUInt8();
  668. for (a = 0; a < t; a++) Mt[msg.readUInt8() - 1] = 1;
  669. break;
  670. case 14:
  671. t = msg.readUInt8();
  672. var n = msg.readUInt32();
  673. 0 == t ? (oe = "Watch out! You were eaten!", de = "#F1C34C", ce = +new Date + 2500) : 1 == t ? (oe = "You died of hunger :(", de = "#F1C34C", ce = +new Date + 2500) : 2 == t && (oe = "You died of thirst :( Don't let your water run out!", de = "#F1C34C", ce = +new Date + 3500);
  674. ot = !1;
  675. window.setTimeout(function() {
  676. ot || (document.getElementById("startMenuWrapper").style.display = "block", document.getElementById("nickInput").focus(), wt = 0 < n ? "You'll spawn with +" + zt(n) + " XP!" : "", pt = 0, document.getElementById("spawnXpLabel").style.display = wt ? "block" : "none", document.getElementById("spawnXpLabel").textContent = wt, window.onbeforeunload = null)
  677. }, 2e3);
  678. break;
  679. case 4:
  680. ie(msg);
  681. break;
  682. case 19:
  683. if (t = msg.readUInt32(), t = Ut[t]) a = msg.readString(), t.gotChat(a)
  684. }
  685. }
  686.  
  687. function te(t) {
  688. Tt.send(t.dataView.buffer)
  689. }
  690.  
  691. function ee() {
  692. return null != Tt && Tt.readyState == Tt.OPEN
  693. }
  694. var ae = +new Date,
  695. At = +new Date;
  696.  
  697. function ie(t) {
  698. At = ae = +new Date;
  699. o_camx = j;
  700. o_camy = camy;
  701. n_camx = t.readUInt16() / 4;
  702. n_camy = t.readUInt16() / 4;
  703. q = t.readUInt16() / 1e3;
  704. var e = t.readUInt8();
  705. Ot(e, 1) || (ft = t.readUInt8(), xp = t.readUInt32(), mt = t.readUInt8());
  706. for (var a = t.readUInt16(), i = 0; i < a; i++) {
  707. var n = t.readUInt8(),
  708. r = t.readUInt32(),
  709. s = t.readUInt16() / 4,
  710. l = t.readUInt16() / 4,
  711. h = t.readUInt16() / 4,
  712. e = t.readUInt8(),
  713. o = null;
  714. 0 < e && (o = Ut[t.readUInt32()]);
  715. var d = new Ht(r, n, l, h, s);
  716. Ut.hasOwnProperty(r) && (e = Ut[r], delete Ut[r], e = xt.indexOf(e), -1 != e && xt.splice(e, 1));
  717. Ut[r] = d;
  718. xt.push(d);
  719. o && (d.updateTime = ae, d.nx = d.x, d.ny = d.y, d.ox = o.x, d.oy = o.y, d.x = o.x, d.y = o.y);
  720. n == k && (r = t.readUInt8(), e = t.readString(), d.nickName = e, d.type = r, d.name = e ? e : "mope.io");
  721. n == B && 16 == Math.round(s) && (d.type = 4)
  722. }
  723. a = t.readUInt16();
  724. for (i = 0; i < a; i++) {
  725. r = t.readUInt32();
  726. l = t.readUInt16() / 4;
  727. h = t.readUInt16() / 4;
  728. s = t.readUInt16() / 10;
  729. if (d = Ut[r]) d.updateTime = ae, d.ox = d.x, d.oy = d.y, d.nx = l, d.ny = h, d.oRad = d.rad, d.nRad = s;
  730. d && d.oType == k && (s = t.readUInt8(), n = t.readUInt16(), e = t.readUInt8(), d.type = s, s = Bt(n - 90), d.angleDelta = _t(d.angle, s), d.flag_hurt = Ot(e, 7), d.flag_lowWat = Ot(e, 6), s = Ot(e, 5), d.flag_tailBitten = Ot(e, 4), d.flag_tailBitten && r == ht && (oe = "Ouch! Your tail got bitten!", ce = ae + 2e3), s ? (r = t.readUInt8(), .001 > d.hpBarA && (d.hpPer = r), d.hpPer_n = r, d.hpBarA_n = 1) : d.hpBarA_n = 0);
  731. d || console.log("PROBLEM, NO OBJ!")
  732. }
  733. a = t.readUInt16();
  734. for (r = 0; r < a; r++) d = t.readUInt32(), e = t.readUInt32(), d = Ut[d], e = Ut[e], d && (e ? (d.dead = !0, d.updateTime = ae, d.ox = d.x, d.oy = d.y, d.oRad = d.rad, d.nx = e.nx, d.ny = e.ny, d.nRad = Math.min(d.rad, e.rad), d.hp_n = 0) : (d.dead = !0, d.updateTime = ae, d.ox = d.x, d.oy = d.y, d.oRad = d.rad, d.nx = d.x, d.ny = d.y, d.nRad = 0))
  735. }
  736.  
  737. function ne(t, e) {
  738. crossHx = t;
  739. crossHy = e;
  740. crossL = 30;
  741. G.beginPath();
  742. G.moveTo(crossHx, crossHy - crossL / 2);
  743. G.lineTo(crossHx, crossHy + crossL / 2);
  744. G.stroke();
  745. G.moveTo(crossHx - crossL / 2, crossHy);
  746. G.lineTo(crossHx + crossL / 2, crossHy);
  747. G.stroke();
  748. G.closePath()
  749. }
  750.  
  751. function re() {
  752. G.fillStyle = o;
  753. G.fillRect(0, 0, it, nt);
  754. G.save();
  755. G.strokeStyle = "black";
  756. G.globalAlpha = .055;
  757. G.scale(V, V);
  758. for (var t = it / V, e = nt / V, a = -.5 + (it - j + t / 2) % 30; a < t; a += 30) G.beginPath(), G.moveTo(a, 0), G.lineTo(a, e), G.stroke();
  759. for (a = -.5 + (nt - camy + e / 2) % 30; a < e; a += 30) G.beginPath(), G.moveTo(0, a), G.lineTo(t, a), G.stroke();
  760. G.restore()
  761. }
  762.  
  763. function se(t) {
  764. H = document.createElement("canvas");
  765. H.width = 180;
  766. H.height = 180;
  767. var e = H.getContext("2d");
  768. e.globalAlpha = .35;
  769. e.fillStyle = "#000000";
  770. e.fillRect(0, 0, H.width, H.height);
  771. var a = t.readUInt16();
  772. e.fillStyle = m;
  773. e.globalAlpha = .5;
  774. for (var i = 0; i < a; i++) {
  775. var n = .9 * t.readUInt8(),
  776. r = .9 * t.readUInt8(),
  777. s = 4.5 * t.readUInt8();
  778. e.beginPath();
  779. e.arc(n, r, Math.max(1, 180 / rt * s * 1.2), 0, 2 * Math.PI);
  780. e.fill()
  781. }
  782. a = t.readUInt16();
  783. e.fillStyle = "#907A33";
  784. e.globalAlpha = .7;
  785. for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(2.5, 180 / rt * 110), 0, 2 * Math.PI), e.fill();
  786. a = t.readUInt16();
  787. e.fillStyle = c;
  788. e.globalAlpha = 1;
  789. for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(2.5, 180 / rt * 50), 0, 2 * Math.PI), e.fill();
  790. a = t.readUInt16();
  791. e.fillStyle = u;
  792. e.globalAlpha = 1;
  793. for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(3.5, 180 / rt * 40), 0, 2 * Math.PI), e.fill();
  794. a = t.readUInt16();
  795. e.fillStyle = m;
  796. e.globalAlpha = 1;
  797. for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(4.5, 180 / rt * 50), 0, 2 * Math.PI), e.fill()
  798. }
  799.  
  800. function le(t, e, a) {
  801. z = null;
  802. if (0 != t.length) {
  803. z = document.createElement("canvas");
  804. e = z.getContext("2d");
  805. var i;
  806. i = 55 + 22 * t.length;
  807. z.width = 180;
  808. z.height = 1 * i;
  809. e.scale(1, 1);
  810. e.globalAlpha = .35;
  811. e.fillStyle = "#000000";
  812. e.fillRect(0, 0, 200, i);
  813. e.globalAlpha = 1;
  814. e.fillStyle = "#FFFFFF";
  815. i = "Top Players";
  816. e.font = "30px Arial";
  817. e.shadowOffsetX = 1;
  818. e.shadowOffsetY = 1;
  819. e.shadowColor = "black";
  820. e.fillText(i, 90 - e.measureText(i).width / 2, 40);
  821. var n;
  822. e.textAlign = "left";
  823. e.font = "18px Arial";
  824. for (n = 0; n < t.length; ++n) i = t[n].name || "mope.io", e.fillStyle = a == t[n].rank ? "#FEED92" : "#FFFFFF", i = t[n].rank + ". " + i + " (" + zt(t[n].score) + ")", e.fillText(i, 15, 65 + 22 * n)
  825. }
  826. }
  827.  
  828. function he() {
  829. G.save();
  830. if (ot) {
  831. water += .1 * (ft - water);
  832. xpPer += .03 * (mt - xpPer);
  833. var t = 1,
  834. e = 25 >= water;
  835. e && (t = .7 + .3 * Math.sin(2 * Math.PI / 1.2 * (ae / 1e3)));
  836. var a = Math.min(450, .9 * N.width),
  837. i = N.width / 2,
  838. n = N.height - 60;
  839. G.globalAlpha = .35 * t;
  840. G.fillStyle = "#000000";
  841. G.fillRect(i - a / 2, n - 15, a, 30);
  842. G.globalAlpha = t;
  843. G.fillStyle = m;
  844. G.fillRect(i - a / 2, n - 15, water / 100 * a, 30);
  845. G.fillStyle = et ? e ? u : "orange" : e ? u : "white";
  846. G.globalAlpha = 1 * t;
  847. G.font = "22px Arial";
  848. G.lineWidth = 1;
  849. G.textAlign = "center";
  850. G.textBaseline = "middle";
  851. G.shadowColor = "black";
  852. e ? (G.shadowOffsetX = 0, G.shadowOffsetY = 0) : (G.shadowOffsetX = 1, G.shadowOffsetY = 1);
  853. G.fillText(e ? "LOW Water" : "Water", i, n);
  854. G.shadowOffsetX = 0;
  855. G.shadowOffsetY = 0;
  856. G.globalAlpha = .35;
  857. G.fillStyle = "#000000";
  858. n = N.height - 15 - 5;
  859. a = .9 * N.width;
  860. G.fillRect(i - a / 2, n - 15, a, 30);
  861. G.globalAlpha = 1;
  862. G.fillStyle = "#F3C553";
  863. G.fillRect(i - a / 2, n - 15, xpPer / 100 * a, 30);
  864. G.fillStyle = "white";
  865. G.globalAlpha = 1;
  866. G.shadowOffsetX = 1;
  867. G.shadowOffsetY = 1;
  868. G.shadowColor = "black";
  869. G.fillText("" + zt(xp) + " xp (" + zt(It) + " xp Next Animal)", i, n);
  870. G.shadowOffsetX = 0;
  871. G.shadowOffsetY = 0
  872. }
  873. G.restore()
  874. }
  875. var oe = "Ready to survive!",
  876. de = "white",
  877. ce = +new Date + 0;
  878.  
  879. function fe() {
  880. var t = (ce - ae) / 1e3 / 1,
  881. t = 0 > t ? 0 : 1 < t ? 1 : t;
  882. 0 >= t || (G.save(), G.font = "25px Arial", G.lineWidth = 1, G.textAlign = "center", G.textBaseline = "middle", G.shadowOffsetX = 1, G.shadowOffsetY = 1, G.shadowColor = "#000000", G.fillStyle = de, G.globalAlpha = t, Xt(oe, N.width / 2, N.height / 2 - 220), G.restore())
  883. }
  884.  
  885. function me(t) {
  886. ae = +new Date;
  887. window.requestAnimationFrame(me);
  888. G.clearRect(0, 0, N.width, N.height);
  889. t = (ae - At) / 1e3 / .2;
  890. t = 0 > t ? 0 : 1 < t ? 1 : t;
  891. j = t * (n_camx - o_camx) + o_camx;
  892. camy = t * (n_camy - o_camy) + o_camy;
  893. V += .05 * (q - V);
  894. pe();
  895. re();
  896. G.save();
  897. t = it / 2;
  898. var e = nt / 2;
  899. G.translate(t * (1 - V) + (t - j) * V, e * (1 - V) + (e - camy) * V);
  900. G.scale(V, V);
  901. G.save();
  902. ct && (t = 10, t = 600, G.globalAlpha = .5, G.fillStyle = f, G.fillRect(0 - t, 0 - t, rt + 2 * t, t), G.fillRect(0 - t, -.5, t, st + 1), G.fillRect(rt, -.5, t, st + 1), G.fillRect(0 - t, st, rt + 2 * t, t));
  903. G.restore();
  904. vt = [];
  905. for (d = 0; d < xt.length; d++) xt[d].updateZ();
  906. xt.sort(function(t, e) {
  907. return t.z == e.z ? t.id - e.id : t.z - e.z
  908. });
  909. for (d = 0; d < xt.length; d++) xt[d].draw();
  910. for (d = 0; d < xt.length; d++) xt[d].oType != k && xt[d].oType != F && xt[d].oType != W || xt[d].drawChat();
  911. for (d = 0; d < vt.length; d++) t = vt[d], Ut.hasOwnProperty(t.id) && delete Ut[t.id], t = xt.indexOf(t), -1 != t && xt.splice(t, 1);
  912. G.restore();
  913. fe();
  914. he();
  915. ot && (z && z.width && G.drawImage(z, 10, 10), H && H.width && G.drawImage(H, N.width - (10 + H.width), 10), t = Ut[ht]) && (G.fillStyle = "white", G.beginPath(), G.arc(N.width - (10 + H.width) + H.width / rt * t.x, 10 + H.height / st * t.y, 3, 0, 2 * Math.PI), G.fill());
  916. G.save();
  917. G.font = "14px Arial";
  918. G.lineWidth = 1;
  919. G.textAlign = "right";
  920. G.textBaseline = "bottom";
  921. G.shadowOffsetX = 1;
  922. G.shadowOffsetY = 1;
  923. G.shadowColor = "#000000";
  924. G.fillStyle = "white";
  925. G.fillText(lt, N.width - 5, N.height - 2);
  926. G.restore()
  927. }
  928. window.requestAnimationFrame ? window.requestAnimationFrame(me) : setInterval(draw, 1e3 / 60);
  929.  
  930. function ge(t) {
  931. playerName = nickInput.value.replace(/(<([^>]+)>)/gi, "").substring(0, 25);
  932. mes = new Vt(9 + Lt(playerName).length);
  933. mes.writeUInt8(2);
  934. mes.writeUInt8(0);
  935. mes.writeString(playerName);
  936. mes.writeUInt8(t ? 2 : 1);
  937. mes.writeUInt16(N.width);
  938. mes.writeUInt16(N.height);
  939. te(mes);
  940. t || "undefined" !== typeof Storage && localStorage.setItem("nick", playerName + "")
  941. }
  942. document.getElementById("startButton").onclick = function() {
  943. document.getElementById("spawn_cell").play();
  944. ee() && ge(!1)
  945. };
  946. var ue = !1;
  947. document.onkeypress = function(t) {
  948. if (ue || 119 != t.keyCode) {
  949. if (13 == t.keyCode && ot && !spectating) {
  950. var e = document.getElementById("chatinput");
  951. if (!ue) e.style.visibility = "visible", e.focus(), ue = !0;
  952. else if (13 == t.keyCode) {
  953. ue = !1;
  954. e.style.visibility = "hidden";
  955. e.blur();
  956. var a = e.value;
  957. e.value = "";
  958. 0 < a.length && (newMsg = new Vt(3 + a.length), newMsg.writeUInt8(19), newMsg.writeString(a), te(newMsg))
  959. }
  960. }
  961. 13 != t.keyCode || ot || document.getElementById("startButton").click()
  962. } else Ie()
  963. };
  964. window.onresize = ye;
  965.  
  966. function ye() {
  967. it = window.innerWidth;
  968. nt = window.innerHeight;
  969. N.width = it;
  970. N.height = nt;
  971. document.getElementById("chatinput").style.marginTop = N.height / 2 - 50 + "px";
  972. ee() && (mes = new Vt(5), mes.writeUInt8(17), mes.writeUInt16(N.width), mes.writeUInt16(N.height), te(mes))
  973. }
  974. ye();
  975. N.addEventListener("gesturestart", function(t) {
  976. t.preventDefault()
  977. });
  978. N.ontouchstart = function(t) {
  979. t = t.originalEvent.touches[0];
  980. console.log("touch statart");
  981. Z = t.p.pageX;
  982. J = t.pageY;
  983. pe()
  984. };
  985. N.ontouchmove = function(t) {
  986. t.preventDefault();
  987. t = t.touches[0];
  988. t = new MouseEvent("mousemove", {
  989. clientX: t.clientX,
  990. clientY: t.clientY
  991. });
  992. N.dispatchEvent(t)
  993. };
  994. N.onmousemove = function(t) {
  995. Z = t.clientX;
  996. J = t.clientY;
  997. pe()
  998. };
  999. N.onmousedown = function(t) {
  1000. 1 == t.which && (et = !0, ee() && ot && !spectating && (we(), mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(1), te(mes)));
  1001. 3 == t.which && Ie()
  1002. };
  1003. N.onmouseup = function(t) {
  1004. 1 == t.which && (et && (mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), te(mes)), et = !1)
  1005. };
  1006. N.onblur = function(t) {
  1007. et && (mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), te(mes));
  1008. et = !1
  1009. };
  1010. window.onmouseout = function(t) {
  1011. null == t.toElement && null == t.relatedTarget && (et && (mes = new Vt(2), mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), wsSeSendMsg(mes)), et = !1)
  1012. };
  1013. window.onmouseout = function(t) {
  1014. null == t.toElement && null == t.relatedTarget && (et && (mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), te(mes)), mouseLLeftDown = !1)
  1015. };
  1016. document.oncontextmenu = document.body.oncontextmenu = function() {
  1017. return !1
  1018. };
  1019.  
  1020. function pe() {
  1021. var t = it / 2,
  1022. e = nt / 2;
  1023. $ = K;
  1024. tt = Q;
  1025. K = (Z - (t - j * V)) / V;
  1026. Q = (J - (e - camy * V)) / V
  1027. }
  1028.  
  1029. function we() {
  1030. ee() && ot && !spectating && (.1 < Math.abs($ - K) || .1 < Math.abs(tt - Q)) && (mes = new Vt(6), mes.writeUInt8(5), mes.writeInt16(K), mes.writeInt16(Q), te(mes))
  1031. }
  1032.  
  1033. function Ie() {
  1034. ee() && ot && !spectating && (we(), mes = new Vt(1), mes.writeUInt8(20), te(mes))
  1035. }
  1036. setInterval(we, 40);
  1037. window.onload = function() {
  1038. Kt(s);
  1039. if ("undefined" !== typeof Storage) {
  1040. var t = document.getElementById("nickInput");
  1041. t.value = localStorage.getItem("nick");
  1042. t.setSelectionRange(0, t.value.length);
  1043. t.focus()
  1044. }
  1045. }
  1046. })();
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×