Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Save New Duplicate & Edit Just Text Twitter
- >
- boxer = {
- theme: {
- background: "#000000",
- border: "#FFFFFF",
- virus: "#666666",
- pellet: "#FF1555"
- },
- keybind: {
- split: 32,
- eject: 87,
- double: 71,
- quad: 84,
- names: 78,
- mass: 77,
- sector: 66,
- smallbots: 86,
- pellet: 70,
- skin: 83,
- clearchat: 67,
- bot: 81,
- box: 9
- },
- settings: {
- animationstyle: "linear",
- linear: 125,
- interpolate: 0.1,
- names: true,
- mass: true,
- abbreviate: true,
- pellet: true,
- border: true,
- sector: false,
- skin: true,
- border: true,
- sector: true,
- mousefeed: false,
- mousesplit: false,
- minimapguide: true,
- smallbots: true,
- activecellindicator: "arrow"
- },
- user: {
- index: 0,
- profile: [],
- setProfile: (letter, src) => {
- if (src) {
- $(`.preview-${letter}`).css({"background-image": `url(${src})`});
- if (letter === "a") {
- $(".profile-preview").eq(boxer.user.index).css({"background-image": `url(${src})`});
- boxer.user.profile[boxer.user.index].skina = loadImage(src);
- } else {
- boxer.user.profile[boxer.user.index].skinb = loadImage(src);
- }
- } else {
- $(`.preview-${letter}`).css({"background-image": "none"});
- if (letter === "a") {
- $(".profile-preview").eq(boxer.user.index).css({"background-image": "none"});
- boxer.user.profile[boxer.user.index].skina = loadImage("");
- } else {
- boxer.user.profile[boxer.user.index].skinb = loadImage("");
- }
- }
- }
- },
- util: {
- check: (url) => url.match(/^https?:\/\/(\w+\.)?imgur.com\/(\w*\d\w*)+(\.[a-zA-Z]{3})?$/)
- },
- core: {
- camera: {
- x: 0,
- y: 0,
- scale: 0.01,
- dx: 0,
- dy: 0,
- dscale: 1
- },
- map: {
- minX: -7071,
- minY: -7071,
- maxX: 7071,
- maxY: 7071,
- dimension: 14142
- },
- sound: {
- message: "message",
- send: "send",
- connected: "connected",
- disconnected: "disconnected"
- }
- },
- cache: {
- nick: [],
- mass: []
- },
- offset: {
- switch: false,
- arrow: 0
- },
- connect: (address) => {
- $(".control-connect").html(`<i class="fas fa-spin fa-circle-notch"></i>`);
- $("#chat-hud").html("");
- multibox.a.self = [];
- multibox.b.self = [];
- multibox.a.entities = [];
- multibox.b.entities = [];
- if (multibox.a.socket) {
- multibox.a.socket.close();
- }
- if (multibox.b.socket) {
- multibox.b.socket.close();
- }
- setTimeout(() => {
- multibox.a.socket = new WebSocket(address);
- multibox.b.socket = new WebSocket(address);
- multibox.a.socket.binaryType = "arraybuffer";
- multibox.b.socket.binaryType = "arraybuffer";
- multibox.a.socket.onopen = () => {
- $(".control-connect").html("Connect");
- multibox.a.send(Buffer.from([254, 5, 0, 0, 0]));
- multibox.a.send(Buffer.from([255, 0, 0, 0, 0]));
- multibox.ctrl = multibox.a;
- console.log("Tab A Connected");
- };
- multibox.b.socket.onopen = () => {
- multibox.b.send(Buffer.from([254, 5, 0, 0, 0]));
- multibox.b.send(Buffer.from([255, 0, 0, 0, 0]));
- console.log("Tab B Connected");
- };
- multibox.a.socket.onmessage = ({ data }) => {
- const buffer = new Reader(data);
- const packet = buffer.readUInt8();
- switch (packet) {
- case 16:
- const E = buffer.readUInt16();
- buffer.skipBytes(E * 8);
- while (true) {
- const id = buffer.readUInt32();
- if (id === 0) break;
- let entity;
- if (arrayHasID(multibox.a.entities, id)) {
- entity = multibox.a.entities[indexInArray(multibox.a.entities, id)];
- } else {
- entity = new Entity(id);
- }
- entity.id = id;
- entity.x = buffer.readInt32();
- entity.y = buffer.readInt32();
- entity.r = buffer.readInt16();
- entity.rgb = [];
- entity.rgb[0] = buffer.readUInt8();
- entity.rgb[1] = buffer.readUInt8();
- entity.rgb[2] = buffer.readUInt8();
- const type = buffer.readUInt8();
- if (type & 1) {
- entity.type = "VIRUS";
- }
- if (type & 2) {
- buffer.readUInt32();
- }
- if (type & 4) {
- buffer.readZeroUTF8String()
- }
- if (type & 128) {
- entity.type = "EJECTED";
- }
- if (entity.r < 20) {
- entity.type = "PELLET";
- }
- const nick = buffer.readZeroUTF16String();
- if (nick) {
- entity.nick = nick;
- }
- if (arrayHasID(multibox.a.entities, id)) {
- multibox.a.entities[indexInArray(multibox.a.entities, id)] = entity;
- } else if (arrayHasID(multibox.b.entities, id)) {
- multibox.a.entities.push(multibox.b.entities[indexInArray(multibox.b.entities, id)]);
- multibox.b.entities.splice(indexInArray(multibox.b.entities, id), 1);
- } else {
- multibox.a.entities.push(entity);
- }
- if (arrayHasID(multibox.a.self, id)) {
- if (typeof entity.nick != "undefined") {
- multibox.a.nick = entity.nick;
- }
- multibox.a.self[indexInArray(multibox.a.self, id)].nick = entity.nick;
- multibox.a.self[indexInArray(multibox.a.self, id)].x = entity.x;
- multibox.a.self[indexInArray(multibox.a.self, id)].y = entity.y;
- multibox.a.self[indexInArray(multibox.a.self, id)].r = entity.r;
- }
- }
- const D = buffer.readUInt32();
- for (let i = 0; i < D; i++) {
- const id = buffer.readUInt32();
- if (arrayHasID(multibox.a.entities, id)) {
- multibox.a.entities.splice(indexInArray(multibox.a.entities, id), 1);
- }
- if (arrayHasID(multibox.a.self, id)) {
- multibox.a.self.splice(indexInArray(multibox.a.self, id), 1);
- if (!multibox.a.self.length) {
- //death
- }
- }
- }
- break;
- case 17:
- multibox.a.camera = {
- x: buffer.readFloat(),
- y: buffer.readFloat(),
- scale: buffer.readFloat()
- }
- break;
- case 20:
- multibox.a.self = [];
- multibox.a.entities = [];
- break;
- case 32:
- multibox.a.self.push(new Entity(buffer.readUInt32()));
- break;
- case 49:
- const count = buffer.readUInt32();
- $("#leaderboard-ul").html("");
- for (let i = 0; i < count; i++) {
- const id = buffer.readUInt32();
- let nick = "";
- while (true) {
- const char = buffer.readUInt16();
- if (char === 0) break;
- nick += String.fromCharCode(char);
- }
- $("#leaderboard-ul").append(`<li class="leaderboard-li leaderboard-li-${(arrayHasID(multibox.a.self, id) ? arrayHasID(multibox.a.self, id) : arrayHasID(multibox.b.self, id))}">${nick} <div class="leaderboard-position">${(i + 1)}</div></li>`)
- }
- break;
- case 64:
- boxer.core.map.minX = buffer.readDouble();
- boxer.core.map.minY = buffer.readDouble();
- boxer.core.map.maxX = buffer.readDouble();
- boxer.core.map.maxY = buffer.readDouble();
- boxer.core.map.dimension = (boxer.core.map.maxX + boxer.core.map.maxY) / 2;
- break;
- case 99:
- $("#chat-hud").append(`<div class="chat-message"><strong>${buffer["readZeroUTF16String"]()}</strong>: ${buffer["readZeroUTF16String"]()}</div>`).animate({scrollTop: $("#chat-hud").prop("scrollHeight")}, 1e3);
- createjs.Sound.play(boxer.core.sound.message);
- break;
- }
- };
- multibox.b.socket.onmessage = ({ data }) => {
- const buffer = new Reader(data);
- const packet = buffer.readUInt8();
- switch (packet) {
- case 16:
- const E = buffer.readUInt16();
- buffer.skipBytes(E * 8);
- while (true) {
- const id = buffer.readUInt32();
- if (id === 0) break;
- let entity;
- if (arrayHasID(multibox.b.entities, id)) {
- entity = multibox.b.entities[indexInArray(multibox.b.entities, id)];
- } else {
- entity = new Entity(id);
- }
- entity.id = id;
- entity.x = buffer.readInt32();
- entity.y = buffer.readInt32();
- entity.r = buffer.readInt16();
- entity.rgb = [];
- entity.rgb[0] = buffer.readUInt8();
- entity.rgb[1] = buffer.readUInt8();
- entity.rgb[2] = buffer.readUInt8();
- const type = buffer.readUInt8();
- if (type & 1) {
- entity.type = "VIRUS";
- }
- if (type & 2) {
- buffer.readUInt32();
- }
- if (type & 4) {
- buffer.readZeroUTF8String()
- }
- if (type & 128) {
- entity.type = "EJECTED";
- }
- if (entity.r < 20) {
- entity.type = "PELLET";
- }
- const nick = buffer.readZeroUTF16String();
- if (nick) {
- entity.nick = nick;
- }
- if (arrayHasID(multibox.b.entities, id)) {
- multibox.b.entities[indexInArray(multibox.b.entities, id)] = entity;
- } else {
- multibox.b.entities.push(entity);
- }
- if (arrayHasID(multibox.b.self, id)) {
- if (typeof entity.nick != "undefined") {
- multibox.b.nick = entity.nick;
- }
- multibox.b.self[indexInArray(multibox.b.self, id)].nick = entity.nick;
- multibox.b.self[indexInArray(multibox.b.self, id)].x = entity.x;
- multibox.b.self[indexInArray(multibox.b.self, id)].y = entity.y;
- multibox.b.self[indexInArray(multibox.b.self, id)].r = entity.r;
- }
- }
- const D = buffer.readUInt32();
- for (let i = 0; i < D; i++) {
- const id = buffer.readUInt32();
- if (arrayHasID(multibox.b.entities, id)) {
- multibox.b.entities.splice(indexInArray(multibox.b.entities, id), 1);
- }
- if (arrayHasID(multibox.b.self, id)) {
- multibox.b.self.splice(indexInArray(multibox.b.self, id), 1);
- if (!multibox.b.self.length) {
- //death
- }
- }
- }
- break;
- case 17:
- multibox.b.camera = {
- x: buffer.readFloat(),
- y: buffer.readFloat(),
- scale: buffer.readFloat()
- }
- break;
- case 20:
- multibox.b.self = [];
- multibox.b.entities = [];
- break;
- case 32:
- multibox.b.self.push(new Entity(buffer.readUInt32()));
- break;
- }
- };
- }, 5e2);
- },
- sendMouseMove: () => {
- if (!$("#content").is(":visible")) {
- let buffer = new Writer();
- buffer.writeUInt8(16);
- buffer.writeDouble((mouseX - width * 0.5) / boxer.core.camera.dscale + boxer.core.camera.dx);
- buffer.writeDouble((mouseY - height * 0.5) / boxer.core.camera.dscale + boxer.core.camera.dy);
- buffer.writeUInt32(0);
- if (multibox.ctrl) {
- multibox.ctrl.send(buffer.getBuffer());
- }
- }
- },
- setCamera: () => {
- if (multibox.a.self.length || multibox.b.self.length) {
- boxer.core.camera.x = 0;
- boxer.core.camera.y = 0;
- let c = 0, x = 0, y = 0;
- for (let i = 0; i < multibox.a.self.length; i++) {
- if (!isNaN(multibox.a.self[i].x) && !isNaN(multibox.a.self[i].y)) {
- boxer.core.camera.x += multibox.a.self[i].x;
- boxer.core.camera.y += multibox.a.self[i].y;
- x += multibox.a.self[i].x;
- y += multibox.a.self[i].y;
- c += 1;
- }
- }
- x /= c;
- y /= c;
- if (!isNaN(x) && !isNaN(y)) {
- multibox.a.node = {x: x, y: y};
- }
- x = 0;
- y = 0;
- for (let i = 0; i < multibox.b.self.length; i++) {
- if (!isNaN(multibox.b.self[i].x) && !isNaN(multibox.b.self[i].y)) {
- boxer.core.camera.x += multibox.b.self[i].x;
- boxer.core.camera.y += multibox.b.self[i].y;
- x += multibox.b.self[i].x;
- y += multibox.b.self[i].y;
- c += 1;
- }
- }
- x /= c - multibox.a.self.length;
- y /= c - multibox.a.self.length;
- if (!isNaN(x) && !isNaN(y)) {
- multibox.b.node = {x: x, y: y};
- }
- boxer.core.camera.x /= c;
- boxer.core.camera.y /= c;
- }
- if (isNaN(boxer.core.camera.x) || isNaN(boxer.core.camera.y)) {
- boxer.core.camera.x = 0;
- boxer.core.camera.y = 0;
- }
- },
- set: (a, b) => localStorage.setItem(a, b),
- get: (a) => localStorage.getItem(a)
- };
- multibox = {
- a: {
- socket: null,
- self: [],
- entities: [],
- node: {
- x: 0,
- y: 0
- },
- spawn: () => {
- let buffer = new Writer();
- buffer.writeUInt8(0);
- buffer.writeZeroUTF16String(document.getElementsByClassName("data-nick-a")[0].value);
- multibox.a.send(buffer.getBuffer());
- },
- send: (packet) => {
- if (multibox.a.socket && multibox.a.socket.readyState === WebSocket.OPEN) {
- multibox.a.socket.send(packet);
- }
- }
- },
- b: {
- socket: null,
- self: [],
- entities: [],
- node: {
- x: 0,
- y: 0
- },
- spawn: () => {
- let buffer = new Writer();
- buffer.writeUInt8(0);
- buffer.writeZeroUTF16String(document.getElementsByClassName("data-nick-b")[0].value);
- multibox.b.send(buffer.getBuffer());
- },
- send: (packet) => {
- if (multibox.b.socket && multibox.b.socket.readyState === WebSocket.OPEN) {
- multibox.b.socket.send(packet);
- }
- }
- },
- ctrl: null
- };
- class Entity {
- constructor (id) {
- this.id = id;
- }
- render () {
- if (!isNaN(this.dx) && !isNaN(this.dy) && !isNaN(this.dr)) {
- push();
- translate(this.dx, this.dy);
- switch (this.type) {
- case "VIRUS": {
- fill(boxer.theme.virus);
- stroke("#FFFFFF");
- strokeWeight(3 * boxer.core.camera.dscale);
- ellipse(0, 0, this.dr * 2, this.dr * 2, 50);
- } break;
- case "EJECTED": {
- fill(this.rgb);
- noStroke();
- ellipse(0, 0, this.dr * 2, this.dr * 2, 8);
- } break;
- case "PELLET": {
- if (boxer.settings.pellet) {
- fill(boxer.theme.pellet);
- noStroke();
- ellipse(this.dx, this.dy, 30, 30, 8);
- }
- } break;
- default: {
- if ((this.dr * this.dr) / 1e2 < 20 && !boxer.settings.smallbots) {
- break;
- }
- fill(this.rgb);
- noStroke();
- ellipse(0, 0, this.dr * 2, this.dr * 2, 50);
- if (arrayHasID(multibox.a.self, this.id) || arrayHasID(multibox.b.self, this.id)) {
- if (arrayHasID(multibox.ctrl.self, this.id) && (this.dr * this.dr) / 1e2 <= 6e2) {
- if (boxer.settings.activecellindicator == "arrow") {
- fill("#FF1555");
- noStroke();
- triangle(- 40, - this.dr - 60 - boxer.offset.arrow, 40, - this.dr - 60 - boxer.offset.arrow, 0, - this.dr - 20 - boxer.offset.arrow);
- }
- } else if ((this.dr * this.dr) / 1e2 <= 6e2) {
- if (boxer.settings.activecellindicator == "arrow") {
- fill("#FFFFFF");
- noStroke();
- triangle(- 35, - this.dr - 55, 35, - this.dr - 55, 0, - this.dr - 20);
- }
- }
- }
- if (boxer.settings.skin) {
- if (arrayHasID(multibox.a.self, this.id)) {
- renderMultiboxSkin(boxer.user.profile[boxer.user.index].skina, this.dr * 2);
- } else if (arrayHasID(multibox.b.self, this.id)) {
- renderMultiboxSkin(boxer.user.profile[boxer.user.index].skinb, this.dr * 2);
- }
- }
- if (boxer.settings.names && this.nick) {
- if (this.dr * boxer.core.camera.dscale > 18) {
- if (arrayHasID(boxer.cache.nick, this.nick)) {
- noFill();
- noStroke();
- texture(boxer.cache.nick[indexInArray(boxer.cache.nick, this.nick)]);
- plane(this.dr * 2);
- } else if (this.nick != "") {
- let nick = createGraphics(512, 512);
- nick.background(0, 0, 0, 0);
- nick.translate(nick.width * 0.5, nick.height * 0.5);
- nick.fill("#FFFFFF");
- nick.noStroke();
- nick.textAlign(CENTER);
- nick.textFont("Roboto Condensed");
- nick.textSize(100);
- nick.text(this.nick, 0, textSize() * 0.25);
- nick.id = this.nick;
- boxer.cache.nick.push(nick);
- }
- }
- }
- if (boxer.settings.mass) {
- if (this.dr * boxer.core.camera.dscale > 18) {
- if (arrayHasID(boxer.cache.mass, Math.floor((this.dr * this.dr) / 1e2))) {
- noFill();
- noStroke();
- texture(boxer.cache.mass[indexInArray(boxer.cache.mass, Math.floor((this.dr * this.dr) / 1e2))]);
- plane(this.dr * 2);
- } else {
- let mass = createGraphics(512, 512);
- mass.background(0, 0, 0, 0);
- mass.translate(mass.width * 0.5, mass.height * 0.75);
- mass.fill("#FFFFFF");
- mass.noStroke();
- mass.textAlign(CENTER);
- mass.textFont("Roboto Condensed");
- mass.textSize(125);
- mass.text(Math.floor((this.dr * this.dr) / 1e2), 0, textSize() * 0.25);
- mass.id = Math.floor((this.dr * this.dr) / 1e2);
- boxer.cache.mass.push(mass);
- }
- /*(fill("#FFFFFF");
- noStroke();
- textAlign(CENTER);
- textFont("Roboto Condensed");
- textSize(this.dr);
- let mass = Math.floor((this.dr * this.dr) / 1e2);
- if (Math.floor((this.dr * this.dr) / 1e2) >= 1e3 && boxer.settings.abbreviate) {
- mass = Math.floor(mass * Math.pow(10, 1) / Math.pow(10, 3)) / Math.pow(10, 1) + "k";
- }
- text(mass, 0, this.dr * 0.6 + (textSize() * 0.25));*/
- }
- }
- } break;
- }
- pop();
- }
- }
- update () {
- if (typeof this.x != "undefined" && typeof this.y != "undefined") {
- if (this.dx == undefined || this.dy == undefined || this.dr == undefined) {
- this.dx = this.x;
- this.dy = this.y;
- this.dr = this.r;
- }
- this.dx += (this.x - this.dx) / ((boxer.settings.linear - 50) / 10);
- this.dy += (this.y - this.dy) / ((boxer.settings.linear - 50) / 10);
- this.dr += (this.r - this.dr) / ((boxer.settings.linear - 50) / 10);
- this.dx = Math.round(this.dx);
- this.dy = Math.round(this.dy);
- this.dr = Math.round(this.dr);
- }
- }
- }
- function setup () {
- createCanvas(windowWidth, windowHeight, WEBGL);
- $("canvas").attr("id", "P5Canvas");
- $("#minimap-hud").append(`<canvas id="minimap-nodes"></canvas>`);
- imageMode(CENTER);
- setInterval(() => {
- boxer.sendMouseMove();
- }, 25);
- createjs.Sound.registerSound("Sounds/message.wav", boxer.core.sound.message);
- boxer.user.index = !isNaN(boxer.get("index")) ? boxer.get("index") : 0;
- for (let i = 0; i < 5; i++) {
- boxer.user.profile.push({
- nicka: boxer.get(`profile#${i + 1}nicka`) ? boxer.get(`profile#${i + 1}nicka`) : `Profile #${i + 1}`,
- nickb: boxer.get(`profile#${i + 1}nickb`) ? boxer.get(`profile#${i + 1}nickb`) : `Profile #${i + 1}`,
- urla: boxer.get(`profile#${i + 1}urla`) ? boxer.get(`profile#${i + 1}urla`) : "https://i.imgur.com/HIPT5O0.png",
- urlb: boxer.get(`profile#${i + 1}urlb`) ? boxer.get(`profile#${i + 1}urlb`) : "https://i.imgur.com/HIPT5O0.png",
- });
- if (boxer.util.check(boxer.user.profile[i].urla)) {
- $(".profile-preview").eq(i).css({"background-image": `url(${boxer.user.profile[i].urla})`});
- }
- }
- $(".emote").on("click", function () {
- let message = $("#message").val() + $(this).html();
- $("#message").val(message).focus();
- })
- $(".control-connect").on("click", () => {
- if ($(".data-ip-address").val() != "") {
- boxer.connect(`ws://${$(".data-ip-address").val()}`);
- }
- });
- $(".data-ip-address").on("keyup", () => {
- boxer.set("address", $(".data-ip-address").val());
- }).val(boxer.get("address") || "");
- $(".control-spawn").on("click", () => {
- multibox.a.spawn();
- $("#content").fadeOut("fast");
- });
- $(".data-nick-a").on("keyup", () => {
- boxer.set(`profile#${(boxer.user.index + 1)}nicka`, $(".data-nick-a").val());
- boxer.user.profile[boxer.user.index].nicka = $(".data-nick-a").val();
- }).val(boxer.user.profile[boxer.user.index].nicka);
- $(".data-nick-b").on("keyup", () => {
- boxer.set(`profile#${(boxer.user.index + 1)}nickb`, $(".data-nick-b").val());
- boxer.user.profile[boxer.user.index].nickb = $(".data-nick-b").val();
- }).val(boxer.user.profile[boxer.user.index].nickb);
- $(".data-url-a").on("keyup", () => {
- boxer.set(`profile#${(boxer.user.index + 1)}urla`, $(".data-url-a").val());
- boxer.user.profile[boxer.user.index].urla = $(".data-url-a").val();
- if (boxer.util.check($(".data-url-a").val())) {
- boxer.user.setProfile("a", $(".data-url-a").val());
- } else {
- boxer.user.setProfile("a", false);
- }
- }).val(boxer.get(`profile#${boxer.user.index + 1}urla`) || boxer.user.profile[boxer.user.index].urla);
- $(".data-url-b").on("keyup", () => {
- boxer.set(`profile#${(boxer.user.index + 1)}urlb`, $(".data-url-b").val());
- boxer.user.profile[boxer.user.index].urlb = $(".data-url-b").val();
- if (boxer.util.check($(".data-url-b").val())) {
- boxer.user.setProfile("b", $(".data-url-b").val());
- } else {
- boxer.user.setProfile("b", false);
- }
- }).val(boxer.get(`profile#${boxer.user.index + 1}urlb`) || boxer.user.profile[boxer.user.index].urlb);
- $(".profile-box").on("click", function () {
- $(".profile-box").attr("value", "false");
- $(this).attr("value", "true");
- boxer.user.index = Number($(this).attr("data-id")) - 1;
- boxer.set("index", boxer.user.index);
- $(".data-nick-a").val(boxer.user.profile[boxer.user.index].nicka);
- $(".data-nick-b").val(boxer.user.profile[boxer.user.index].nickb);
- $(".data-url-a").val(boxer.user.profile[boxer.user.index].urla);
- $(".data-url-b").val(boxer.user.profile[boxer.user.index].urlb);
- boxer.user.setProfile("a", $(".data-url-a").val());
- boxer.user.setProfile("b", $(".data-url-b").val());
- });
- $(".profile-box").eq(boxer.user.index).attr("value", "true");
- boxer.user.setProfile("a", $(".data-url-a").val());
- boxer.user.setProfile("b", $(".data-url-b").val());
- boxer.render = {
- border: () => {
- noFill();
- stroke(boxer.theme.border);
- strokeWeight(100 * boxer.core.camera.dscale);
- rectMode(CENTER);
- rect(0, 0, (boxer.core.map.dimension * 2) + 100, (boxer.core.map.dimension * 2) + 100);
- },
- sector: () => {
- push();
- noFill();
- stroke("#252529");
- strokeWeight(200);
- strokeCap(SQUARE);
- rectMode(CENTER);
- rect(0, 0, (boxer.core.map.dimension * 2) - 100, (boxer.core.map.dimension * 2) - 100);
- rectMode(CORNER);
- for (let i = - boxer.core.map.dimension / 5 * 3; i < boxer.core.map.dimension; i += (boxer.core.map.dimension * 2) / 5) {
- line(i, - boxer.core.map.dimension, i, boxer.core.map.dimension);
- for (let j = - boxer.core.map.dimension / 5 * 3; j < boxer.core.map.dimension; j += (boxer.core.map.dimension * 2) / 5) {
- line(- boxer.core.map.dimension, j, boxer.core.map.dimension, j);
- }
- }
- fill("#252529");
- noStroke();
- textSize(3250);
- textAlign(CENTER);
- textFont("Roboto Condensed");
- let SECTOR = "ABCDE", NUMBER = 1, INDEX = 0;
- for (let i = - boxer.core.map.dimension; i < boxer.core.map.dimension; i += (boxer.core.map.dimension * 2) / 5) {
- for (let j = - boxer.core.map.dimension; j < boxer.core.map.dimension; j += (boxer.core.map.dimension * 2) / 5) {
- text(SECTOR.charAt(INDEX) + NUMBER, i + ((boxer.core.map.dimension / 5)), j + ((boxer.core.map.dimension / 5) * (textSize() * 0.000435)));
- INDEX += 1;
- }
- INDEX = INDEX > SECTOR.length - 1 ? 0 : INDEX;
- NUMBER += 1;
- }
- pop();
- }
- }
- }
- function draw () {
- background(boxer.theme.background);
- //translate(width * 0.5, height * 0.5);
- scale(boxer.core.camera.dscale);
- boxer.setCamera();
- translate(- boxer.core.camera.dx, - boxer.core.camera.dy);
- if (boxer.settings.border) {
- boxer.render.border();
- }
- if (boxer.settings.sector) {
- //boxer.render.sector();
- }
- boxer.core.camera.dx = lerp(boxer.core.camera.dx, boxer.core.camera.x, 0.1);
- boxer.core.camera.dy = lerp(boxer.core.camera.dy, boxer.core.camera.y, 0.1);
- boxer.core.camera.dscale = lerp(boxer.core.camera.dscale, boxer.core.camera.scale, 0.1);
- boxer.core.camera.scale = constrain(boxer.core.camera.scale, 0.01, 1);
- boxer.settings.linear = constrain(boxer.settings.linear, 100, 200);
- let a = multibox.a.entities, b = multibox.b.entities;
- for (let i = b.length - 1; i >= 0; i--) {
- if (arrayHasID(a, b[i].id)) {
- if (typeof a[indexInArray(a, b[i].id)].dx == "undefined" || typeof a[indexInArray(a, b[i].id)].dy == "undefined" || typeof a[indexInArray(a, b[i].id)].dr == "undefined") {
- a[indexInArray(a, b[i].id)].dx = b[indexInArray(b, b[i].id)].dx;
- a[indexInArray(a, b[i].id)].dy = b[indexInArray(b, b[i].id)].dy;
- a[indexInArray(a, b[i].id)].dr = b[indexInArray(b, b[i].id)].dr;
- }
- b.splice(indexInArray(b, b[i].id), 1);
- }
- }
- let c = a.concat(b);
- let sorted = c.slice(0).sort((a, b) => {
- return (a.dr ? a.dr : a.r) === (b.dr ? b.dr : b.r) ? a.id - b.id : (a.dr ? a.dr : a.r) - (b.dr ? b.dr : b.r);
- });
- sorted.forEach((entity) => {
- entity.render();
- entity.update();
- });
- if (keyIsDown(boxer.keybind.eject)) {
- multibox.ctrl.send(new Uint8Array([21]));
- }
- $("#minimap-nodes")[0].width = $("#minimap-nodes")[0].height = Number($("#minimap-hud").css("width").match(/\d*/)[0]);
- $("#minimap-nodes")[0].getContext("2d").clearRect(0, 0, $("#minimap-nodes")[0].width, $("#minimap-nodes")[0].height);
- $("#minimap-nodes")[0].getContext("2d").translate(($("#minimap-nodes")[0].width * 0.5), ($("#minimap-nodes")[0].height * 0.5));
- if (multibox.a.node instanceof Object) {
- let position = coordsToScale(multibox.a.node.x, multibox.a.node.y, $("#minimap-nodes")[0].width, boxer.core.map.dimension * 2);
- renderMinimapNode(position.x, position.y, multibox.ctrl == multibox.a, multibox.a.nick);
- }
- if (multibox.b.node instanceof Object) {
- let position = coordsToScale(multibox.b.node.x, multibox.b.node.y, $("#minimap-nodes")[0].width, boxer.core.map.dimension * 2);
- renderMinimapNode(position.x, position.y, multibox.ctrl == multibox.b, multibox.b.nick);
- }
- if (boxer.settings.minimapguide) {
- let ctrl = multibox.ctrl == multibox.a ? multibox.a : multibox.b, position = coordsToScale(ctrl.node.x, ctrl.node.y, $("#minimap-nodes")[0].width, boxer.core.map.dimension * 2);
- renderMinimapGuide(position.x, position.y);
- }
- if (!boxer.offset.switch) {
- boxer.offset.arrow += 2;
- if (boxer.offset.arrow >= 40) {
- boxer.offset.switch = true;
- }
- } else {
- boxer.offset.arrow -= 2;
- if (boxer.offset.arrow <= 0) {
- boxer.offset.switch = false;
- }
- }
- }
- function windowResized () {
- resizeCanvas(windowWidth, windowHeight);
- }
- function mouseWheel (event) {
- if (event.delta > 0) {
- boxer.core.camera.scale -= boxer.core.camera.scale / 15;
- } else {
- boxer.core.camera.scale += boxer.core.camera.scale / 15;
- }
- }
- function arrayHasID (array, id) {
- return array.findIndex(index => index.id == id) >= 0;
- }
- function indexInArray (array, id) {
- return array.findIndex(index => index.id == id);
- }
- function renderMultiboxSkin (skin, r) {
- push();
- texture(skin);
- ellipse(0, 0, r, r, 50);
- pop();
- }
- function renderMinimapNode (x, y, a, n) {
- let context = $("#minimap-nodes")[0].getContext("2d");
- context.beginPath();
- context.fillStyle = a ? "#FF1555" : "#FFFFFF";
- context.arc(x, y, 4.5, 1, Math.PI * 2);
- context.fill();
- if (!a) {
- context.fillStyle = "#FFFFFF";
- context.font = `${(innerWidth * 0.005)}px Roboto Condensed`;
- context.textAlign = "center";
- context.fillText(n, x, y + 10);
- }
- context.closePath();
- }
- function renderMinimapGuide (x, y) {
- let context = $("#minimap-nodes")[0].getContext("2d"), w = $("#minimap-nodes")[0].width, h = $("#minimap-nodes")[0].height;
- context.strokeStyle = "#FF1555";
- context.beginPath();
- context.moveTo(- w * 0.5, y);
- context.lineTo(x - 7, y);
- context.stroke();
- context.moveTo(w * 0.5, y);
- context.lineTo(x + 7, y);
- context.stroke();
- context.moveTo(x, - h * 0.5);
- context.lineTo(x, y - 7);
- context.stroke();
- context.moveTo(x, h * 0.5);
- context.lineTo(x, y + 7);
- context.stroke();
- context.closePath();
- }
- function coordsToScale (x, y, d, m) {
- return {x: x * (d / m), y: y * (d / m)};
- }
- function keyPressed () {
- if (!$("#content").is(":visible")) {
- if ($("#message").is(":focus")) {
- switch (keyCode) {
- case 13: {
- if ($("#message").val().length) {
- let buffer = new Writer();
- buffer.writeUInt8(0x63);
- buffer.writeUInt8(0);
- buffer.writeZeroUTF16String($("#message").val());
- multibox.ctrl.send(buffer.getBuffer());
- }
- $("#message").val("");
- $("#message-hud").toggle();
- } break;
- }
- } else {
- switch (keyCode) {
- case boxer.keybind.split: {
- multibox.ctrl.send(new Uint8Array([17]));
- } break;
- case boxer.keybind.double: {
- for (let i = 0; i < 2; i++) {
- setTimeout(() => {
- multibox.ctrl.send(new Uint8Array([17]));
- }, i * 45);
- }
- } break;
- case boxer.keybind.quad: {
- for (let i = 0; i < 4; i++) {
- setTimeout(() => {
- multibox.ctrl.send(new Uint8Array([17]));
- }, i * 45);
- }
- } break;
- case boxer.keybind.names: {
- boxer.settings.names = !boxer.settings.names;
- } break;
- case boxer.keybind.mass: {
- boxer.settings.mass = !boxer.settings.mass;
- } break;
- case boxer.keybind.sector: {
- boxer.settings.sector = !boxer.settings.sector;
- } break;
- case boxer.keybind.smallbots: {
- boxer.settings.smallbots = !boxer.settings.smallbots;
- } break;
- case boxer.keybind.pellet: {
- boxer.settings.pellet = !boxer.settings.pellet;
- } break;
- case boxer.keybind.skin: {
- boxer.settings.skin = !boxer.settings.skin;
- } break;
- case boxer.keybind.sector: {
- boxer.settings.sector = !boxer.settings.sector;
- } break;
- case boxer.keybind.clearchat: {
- $("#chat-hud").html("");
- } break;
- case boxer.keybind.bot: {
- multibox.ctrl.send(new Uint8Array([19]));
- multibox.ctrl.send(new Uint8Array([18]));
- } break;
- case boxer.keybind.box: {
- if (multibox.ctrl == multibox.a) {
- multibox.ctrl = multibox.b;
- multibox.b.spawn();
- } else {
- multibox.ctrl = multibox.a;
- multibox.a.spawn();
- }
- } break;
- case 27: {
- $("#content").fadeIn("fast");
- } break;
- case 13: {
- $("#message-hud").toggle();
- $("#message").focus();
- } break;
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement