Skip to content

Instantly share code, notes, and snippets.

@fucksophie
Created August 28, 2021 19:29
Show Gist options
  • Save fucksophie/8863846f748b2621f94a5d7d9499224a to your computer and use it in GitHub Desktop.
Save fucksophie/8863846f748b2621f94a5d7d9499224a to your computer and use it in GitHub Desktop.
wow anime owooop
import OJS from "owop-js"
import pkg from 'canvas';
const { createCanvas, loadImage } = pkg;
const img = await loadImage('300.png')
const canvas = createCanvas(img.width, img.height)
const ctx = canvas.getContext('2d')
let pos1 = [1 - img.width/2,
1 - img.height/2]
let pos2 = [1 + img.width/2,
1 + img.height/2];
ctx.drawImage(img, 0, 0, img.width, img.height)
for (let i = 0; i < 5; i++) {
spawnBot()
}
function spawnBot() {
const client = new OJS.Client({
reconnect: true,
controller: true,
});
client.on("join", async () => {
client.placeInterval = setInterval(async () => {
let counter = 0;
client.world.setTool(1);
for (let x = pos1[0], xo = 0; x < pos2[0]; x++, xo++) {
for (let y = pos1[1], yo = 0; y < pos2[1]; y++, yo++) {
const rgb = ctx.getImageData(xo, yo, 1, 1).data
try {
const loc = await client.world.getPixel(x, y);
if(loc[0] != rgb[0] && loc[1] != rgb[1] && loc[2] != rgb[2]) {
setTimeout(() => {
client.world.setPixel(x, y, rgb)
}, ++counter)
}
} catch {
console.log(x, y, " couldn't be set.")
}
}
}
}, 1000)
client.goTo00 = setInterval(() => {
client.world.move(0, 0)
}, 10000)
});
client.on("close", () => {
if(client.placeInterval) {
clearInterval(client.placeInterval)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment