Advertisement
MAYEDGAMER

Untitled

Jun 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 0 0
  1. window.onload = function() {
  2. var ctx = document.getElementById("canvas").getContext("2d");
  3. var botsName = "- MEYBOTS COM -";
  4. setTimeout(function() {
  5. var f = -7071;
  6. var g = -7071;
  7. var h = 7071;
  8. var j = 7071;
  9. var k = {
  10. minx: 0,
  11. miny: 0,
  12. maxx: 0,
  13. maxy: 0
  14. };
  15.  
  16. function valcompare(Y, Z) {
  17. return 0.01 > Y - Z && -0.01 < Y - Z
  18. }
  19. vz = function(a, b, c, d) {
  20. if (valcompare(c - a, d - b)) {
  21. f = a;
  22. g = b;
  23. h = c;
  24. j = d
  25. } else {
  26. if (valcompare(a, k.minx)) {
  27. if (0.01 < c - k.maxx || -0.01 > c - k.maxx) {
  28. f = a;
  29. h = a + 14142.135623730952
  30. }
  31. }
  32. if (0.01 < a - k.minx || -0.01 > a - k.minx) {
  33. if (valcompare(c, k.maxx)) {
  34. h = c;
  35. f = c - 14142.135623730952
  36. }
  37. }
  38. if (0.01 < b - k.miny || -0.01 > b - k.miny) {
  39. if (valcompare(d, k.maxy)) {
  40. j = d;
  41. g = d - 14142.135623730952
  42. }
  43. }
  44. if (valcompare(b, k.miny)) {
  45. if (0.01 < d - k.maxy || -0.01 > d - k.maxy) {
  46. g = b;
  47. j = b + 14142.135623730952
  48. }
  49. }
  50. if (a < f) {
  51. f = a;
  52. h = a + 14142.135623730952
  53. }
  54. if (c > h) {
  55. h = c;
  56. f = c - 14142.135623730952
  57. }
  58. if (b < g) {
  59. g = b;
  60. j = b + 14142.135623730952
  61. }
  62. if (d > j) {
  63. j = d;
  64. g = d - 14142.135623730952
  65. }
  66. k.minx = a;
  67. k.miny = b;
  68. k.maxy = d;
  69. k.maxx = c //validate for ingame client
  70. }
  71. offset_x = f || -7071;
  72. offset_y = g || -7071
  73. };
  74. var l = io.connect('ws://127.0.0.1:8081');
  75. var q = localStorage.getItem('PCWARS');
  76. var m = true;
  77. var n = true;
  78. var o = new Array(2);
  79. var p = document.getElementById("canvas");
  80. last_transmited_game_server = null;
  81. if (!q) {
  82. q = "MEY-" + Math.floor((1 + Math.random()) * 0x1000000).toString(16).substring(1);
  83. localStorage.setItem('PCWARS', q)
  84. }
  85. l.on('force-login', function(data) {
  86. l.emit("login", {
  87. "uuid": q,
  88. "type": "client"
  89. });
  90. transmit_game_server()
  91. });
  92.  
  93.  
  94. l.emit("login", q);
  95.  
  96. var r = 0;
  97.  
  98. function emitPosition() {
  99. x = window.x;
  100. y = window.y;
  101. l.emit("pos", {
  102. "x": x - (f + 7071),
  103. "y": y - (g + 7071),
  104. "nick": botsName,
  105. "dimensions": [-7071, -7071, 7071, 7071]
  106. })
  107. }
  108.  
  109. function emitSplit() {
  110. l.emit("cmd", {
  111. "name": "split"
  112. })
  113. }
  114.  
  115. function changeMode() {
  116. l.emit("cmd", {
  117. "name": "mode"
  118. })
  119. }
  120. function emitMassEject() {
  121. l.emit("cmd", {
  122. "name": "eject"
  123. })
  124. }
  125. function changeMode() {
  126. l.emit("cmd", {
  127. "name": "mode"
  128. })
  129. }
  130.  
  131. function toggleMovement() {
  132. m = !m;
  133. switch (m) {
  134. case true:
  135. p.onmousemove = o[0];
  136. o[0] = null;
  137. p.onmousedown = o[1];
  138. o[1] = null;
  139. break;
  140. case false:
  141. p.onmousemove({
  142. clientX: window.x,
  143. clientY: window.y
  144. });
  145. o[0] = p.onmousemove;
  146. p.onmousemove = null;
  147. o[1] = p.onmousedown;
  148. p.onmousedown = null;
  149. break
  150. }
  151. }
  152. interval_id = setInterval(function() {
  153. emitPosition()
  154. }, 1);
  155. document.addEventListener('keydown', function(e) {
  156. var a = e.keyCode || e.which;
  157. switch (a) {
  158. case 65:
  159. n = !n;
  160. break;
  161. case 88:
  162. changeMode();
  163. break;
  164. case 68:
  165. toggleMovement();
  166. break;
  167. case 69:
  168. emitSplit();
  169. break;
  170. case 82:
  171. emitMassEject();
  172. break;
  173. case 90:
  174. toggleInsane();
  175. break;
  176. }
  177. });
  178.  
  179.  
  180.  
  181. function transmit_game_server() {
  182. last_transmited_game_server = CONNECTION_URL;
  183. l.emit("cmd", {
  184. "name": "connect_server",
  185. "ip": last_transmited_game_server
  186. })
  187. }
  188. var s = 0;
  189. var t = 0;
  190. $("body").mousemove(function(a) {
  191. s = a.clientX;
  192. t = a.clientY
  193. });
  194. }, 200)
  195. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement