Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload = function() {
- var ctx = document.getElementById("canvas").getContext("2d");
- var botsName = "- MEYBOTS COM -";
- setTimeout(function() {
- var f = -7071;
- var g = -7071;
- var h = 7071;
- var j = 7071;
- var k = {
- minx: 0,
- miny: 0,
- maxx: 0,
- maxy: 0
- };
- function valcompare(Y, Z) {
- return 0.01 > Y - Z && -0.01 < Y - Z
- }
- vz = function(a, b, c, d) {
- if (valcompare(c - a, d - b)) {
- f = a;
- g = b;
- h = c;
- j = d
- } else {
- if (valcompare(a, k.minx)) {
- if (0.01 < c - k.maxx || -0.01 > c - k.maxx) {
- f = a;
- h = a + 14142.135623730952
- }
- }
- if (0.01 < a - k.minx || -0.01 > a - k.minx) {
- if (valcompare(c, k.maxx)) {
- h = c;
- f = c - 14142.135623730952
- }
- }
- if (0.01 < b - k.miny || -0.01 > b - k.miny) {
- if (valcompare(d, k.maxy)) {
- j = d;
- g = d - 14142.135623730952
- }
- }
- if (valcompare(b, k.miny)) {
- if (0.01 < d - k.maxy || -0.01 > d - k.maxy) {
- g = b;
- j = b + 14142.135623730952
- }
- }
- if (a < f) {
- f = a;
- h = a + 14142.135623730952
- }
- if (c > h) {
- h = c;
- f = c - 14142.135623730952
- }
- if (b < g) {
- g = b;
- j = b + 14142.135623730952
- }
- if (d > j) {
- j = d;
- g = d - 14142.135623730952
- }
- k.minx = a;
- k.miny = b;
- k.maxy = d;
- k.maxx = c //validate for ingame client
- }
- offset_x = f || -7071;
- offset_y = g || -7071
- };
- var l = io.connect('ws://127.0.0.1:8081');
- var q = localStorage.getItem('PCWARS');
- var m = true;
- var n = true;
- var o = new Array(2);
- var p = document.getElementById("canvas");
- last_transmited_game_server = null;
- if (!q) {
- q = "MEY-" + Math.floor((1 + Math.random()) * 0x1000000).toString(16).substring(1);
- localStorage.setItem('PCWARS', q)
- }
- l.on('force-login', function(data) {
- l.emit("login", {
- "uuid": q,
- "type": "client"
- });
- transmit_game_server()
- });
- l.emit("login", q);
- var r = 0;
- function emitPosition() {
- x = window.x;
- y = window.y;
- l.emit("pos", {
- "x": x - (f + 7071),
- "y": y - (g + 7071),
- "nick": botsName,
- "dimensions": [-7071, -7071, 7071, 7071]
- })
- }
- function emitSplit() {
- l.emit("cmd", {
- "name": "split"
- })
- }
- function changeMode() {
- l.emit("cmd", {
- "name": "mode"
- })
- }
- function emitMassEject() {
- l.emit("cmd", {
- "name": "eject"
- })
- }
- function changeMode() {
- l.emit("cmd", {
- "name": "mode"
- })
- }
- function toggleMovement() {
- m = !m;
- switch (m) {
- case true:
- p.onmousemove = o[0];
- o[0] = null;
- p.onmousedown = o[1];
- o[1] = null;
- break;
- case false:
- p.onmousemove({
- clientX: window.x,
- clientY: window.y
- });
- o[0] = p.onmousemove;
- p.onmousemove = null;
- o[1] = p.onmousedown;
- p.onmousedown = null;
- break
- }
- }
- interval_id = setInterval(function() {
- emitPosition()
- }, 1);
- document.addEventListener('keydown', function(e) {
- var a = e.keyCode || e.which;
- switch (a) {
- case 65:
- n = !n;
- break;
- case 88:
- changeMode();
- break;
- case 68:
- toggleMovement();
- break;
- case 69:
- emitSplit();
- break;
- case 82:
- emitMassEject();
- break;
- case 90:
- toggleInsane();
- break;
- }
- });
- function transmit_game_server() {
- last_transmited_game_server = CONNECTION_URL;
- l.emit("cmd", {
- "name": "connect_server",
- "ip": last_transmited_game_server
- })
- }
- var s = 0;
- var t = 0;
- $("body").mousemove(function(a) {
- s = a.clientX;
- t = a.clientY
- });
- }, 200)
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement