SocketIO allows you to connect to a socket connection to make multiple sketches speak in realtime. To use OpenProcessing Echo Socket Server, you can use the code below: var socket = io.connect($OP.getEchoServerURL(1281388));Learn moreSee an example
“Among Us Online (cheats)” by SJB
https://openprocessing.org/sketch/1281388
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
Invite a friend or open two windows side by side. Wait for the game to load then use WASD or Arrow Keys.
CC Attribution NonCommercial ShareAlike
Among Us Online (cheats)
xxxxxxxxxx
const socket = io.connect(":30000?sketch=1227299");
let mapImg, collisionMap, killButtonImg, killBackgroundImg, errorImg;
const generalSprites = {},
playerSprites = {};
const playerColors = {
red: {
light: [197, 17, 26],
shadow: [123, 8, 56]
},
blue: {
light: [19, 47, 208],
shadow: [9, 21, 142]
},
green: {
light: [16, 128, 45],
shadow: [10, 77, 45]
},
pink: {
light: [237, 83, 185],
shadow: [172, 44, 173]
},
orange: {
light: [239, 125, 14],
shadow: [178, 62, 21]
},
yellow: {
light: [245, 245, 88],
shadow: [195, 136, 35]
},
black: {
light: [63, 72, 78],
shadow: [30, 31, 37]
},
white: {
light: [213, 224, 239],
shadow: [131, 150, 191]
},
purple: {
light: [107, 48, 188],
shadow: [60, 23, 124]
},
brown: {
light: [114, 73, 28],
shadow: [95, 37, 20]
},
cyan: {
light: [57, 254, 219],
shadow: [36, 169, 190]
},
lime: {
light: [80, 239, 58],
shadow: [22, 168, 67]
}
};
let colorNames;
let recolorsThisFrame = 0;
const maxRecolorsPerFrame = 5;
const maxInstantRecolorsPerFrame = 3;
const players = [];
let player;
let spawnList;
let killBGtime = 0;
let killBGcolor = null;
// HEY DON'T LOOK AT THE SECRETS! DEFINITLEY DON'T FIND WHERE THEY APPEAR IN GAME!
var returnToThis = false;
const secretMessages = [
"Did you know this message changes every hour? It is midnight",
"Sussy",
"Sussy Baka",
"Breanon you sussy baka don't cut that among us inposter inhalf with a thousand degree knife!",
"Amogus is a disease",
"Bruh™",
"Dezz nuts",
"breakfast time",
"Bill gates is H U G E",
"sus",
"very sus",
"Go away, stop looking at secrets",
"lunch time",
"yiff, google it",
"I am sorry I made you google that",
"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"Why are you reading this?",
"ghostbob thicc",
"supper time",
"911 was an inside job",
"yee",
"nighty night",
"cum",
"fuuucccckkkkkkkk (sexxy voice)"
];
function preload() {
errorImg = loadImage("error.png");
killButtonImg = loadImage("killButton.png");
killBackgroundImg = loadImage("killBG.png");
collisionMap = loadImage("collisionMapB.png");
loadImage("mapLow.jpg", img => {
mapImg = img;
setTimeout(() => {
loadImage("mapMid.jpg", img => {
mapImg = img;
// if mid quality has been loading for more than 20 seconds give up on higher qualities
if (millis() > 20000) return;
setTimeout(() => {
loadImage("mapHigh.jpg", img => {
mapImg = img;
});
}, 1000);
});
}, 1000);
});
}
function setup() {
createCanvas(windowWidth, windowHeight);
colorNames = Object.keys(playerColors);
for (const name of colorNames) {
playerSprites[name] = {};
}
returnToThis = new Vector(4900, 2000);
spawnList = [
returnToThis
];
player = new Player();
setTimeout(() => {
loadImage("idle.png", img => generalSprites.idle = img);
for (let i = 0; i < 33; i++) {
loadImage(`Dead${String(i + 1).padStart(4, "0")}.png`, ((i, img) => generalSprites[`dead${i}`] = img).bind(null, i));
}
for (let i = 0; i < 48; i++) {
loadImage(`ghostbob${String(i + 1).padStart(4, "0")}.png`, ((i, img) => generalSprites[`ghost${i}`] = img).bind(null, i));
}
for (let i = 0; i < 12; i++) {
loadImage(`walkcolor${String(i + 1).padStart(4, "0")}.png`, ((i, img) => generalSprites[`walk${i}`] = img).bind(null, i));
}
}, 100);
socket.on("player", showRemotePlayer);
//socket.on("kill", receiveKill);
}
function draw() {
spawnList = [
returnToThis
];
recolorsThisFrame = 0;
player.kill();
player.update();
for (let i = 0; i < players.length; i++) {
const updatelessTime = players[i].corpse ? 240 : 90;
if (players[i].lastUpdated < frameCount - updatelessTime) {
players.splice(i, 1);
i--;
} else {
players[i].update()
}
}
background("black");
push();
translate(width / 2, height / 2);
scale(1);
translate(- player.position.x, - player.position.y);
image(mapImg, 0, 0, 8753, 5217);
if (false) {
fill(255, 0, 0, 50);
noStroke();
arc(player.position.x, player.position.y, 320, 320, 0, TWO_PI * (1 - max(0, player.killCountdown / killTime)));
}
for (const remotePlayer of players) remotePlayer.draw();
player.draw();
textAlign(CENTER, CENTER);
textSize(16);
fill("white");
noStroke();
text(secretMessages[hour() % 24], 7000, 5200);
pop();
textAlign(LEFT, TOP);
textSize(24);
fill("red");
noStroke();
const playerCount = players.filter(p => !p.corpse).length;
text("Other Players Online: " + playerCount, 16, 16);
if (player.killCountdown <= 0) {
image(killButtonImg, width - 200, height - 200, 150, 150);
}
killBGtime--;
if (killBGtime > 0) {
image(killBackgroundImg, 0, 0, width, height); //killBGcolor
drawPlayer(killBGcolor, "idle", new Vector(width / 2, height / 2 + 50));
}
}
function mousePressed() {
if (mouseX > width - 200 && mouseY > height - 200 && player.killCountdown <= 0) {
player.kill();
}
}
function drawPlayer(color, frame, position, flipped = false) {
const img = getImage(color, frame);
push();
translate(position.x, position.y - img.height / 2 + 10);
imageMode(CENTER);
if (flipped) scale(-1, 1);
image(img, 0, 0);
pop();
}
function sampleCollision(position) {
return collisionMap.get(position.x / 8753 * collisionMap.width, position.y / 5217 * collisionMap.height)[0] >= 128;
}
function getImage(color, name) {
if (playerSprites[color][name] == null || playerSprites[color][name] == false) {
if (recolorsThisFrame < maxRecolorsPerFrame && playerSprites[color][name] != false && generalSprites[name] != null) {
playerSprites[color][name] = false;
recolorsThisFrame++;
if (recolorsThisFrame <= maxInstantRecolorsPerFrame) {
playerSprites[color][name] = recolorImage(generalSprites[name], playerColors[color]);
return playerSprites[color][name];
} else {
setTimeout(() => {
playerSprites[color][name] = recolorImage(generalSprites[name], playerColors[color]);
}, 0);
}
}
if (generalSprites[name] == null || generalSprites[name] == false) {
return errorImg;
}
return generalSprites[name];
}
return playerSprites[color][name];
}
function recolorImage(source, colors) {
source.loadPixels();
const img = createImage(source.width, source.height);
img.loadPixels();
for (let x = 0; x < img.width; x++) {
for (let y = 0; y < img.height; y++) {
const index = (x + y * source.width) * 4;
const r = source.pixels[index + 0];
const g = source.pixels[index + 1];
const b = source.pixels[index + 2];
const a = source.pixels[index + 3];
img.pixels[index + 3] = a;
if (a === 0) continue;
if (g > 40) {
if (abs(r - g) < 10 && abs(r - b) < 10 && abs(g - b) < 10) {
img.pixels[index + 0] = source.pixels[index + 0];
img.pixels[index + 1] = source.pixels[index + 1];
img.pixels[index + 2] = source.pixels[index + 2];
continue;
}
const brightness = (r + g + b) / 255;
img.pixels[index + 0] = 149 * brightness;
img.pixels[index + 1] = 201 * brightness;
img.pixels[index + 2] = 218 * brightness;
continue;
}
img.pixels[index + 0] = r / 255 * colors.light[0] + b / 255 * colors.shadow[0];
img.pixels[index + 1] = r / 255 * colors.light[1] + b / 255 * colors.shadow[1];
img.pixels[index + 2] = r / 255 * colors.light[2] + b / 255 * colors.shadow[2];
}
}
img.updatePixels();
return img;
}
function showRemotePlayer(id, position, velocity, color, alive, corpse) {
if (id === player.id) return;
position = new Vector(position[0], position[1]);
velocity = new Vector(velocity[0], velocity[1]);
returnToThis = position;
let match = players.findIndex(player => player.id === id);
if (match === -1) {
const newPlayer = new RemotePlayer();
newPlayer.id = id;
match = players.push(newPlayer) - 1;
}
players[match].position = position;
players[match].velocity = velocity;
players[match].color = color;
players[match].alive = alive;
players[match].corpse = corpse;
players[match].lastUpdated = frameCount;
}
function receiveKill(id, color) {
if (id !== player.id) return;
//player.die(color);
}
var socket = io.connect($OP.getEchoServerURL(1281388));
Learn more See an exampleSee More Shortcuts
Please verify your email to comment
Verify Email