Uploaded wavy sine draw function redefinition thing

I didn't expect this to be possible.
This commit is contained in:
Lily-129 2022-01-20 21:06:50 -05:00 committed by GitHub
parent 086fb55572
commit 41bf2d82de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

31
mods/acidboxels.js Normal file
View File

@ -0,0 +1,31 @@
runAfterLoad(function() {
drawPixels = function(forceTick=false) {
// newCurrentPixels = shuffled currentPixels
var newCurrentPixels = currentPixels.slice();
newCurrentPixels.sort(function() {return 0.5 - Math.random()});
for (var i = 0; i < newCurrentPixels.length; i++) {
pixel = newCurrentPixels[i];
//if (pixelMap[pixel.x][pixel.y] == undefined || currentPixels.indexOf(pixel) == -1) {continue}
if (pixel.del) {continue}
if ((!paused) || forceTick) {pixelTick(pixel);};
}
// Draw the current pixels
if (!hiding) {
var canvas = document.getElementById("game");
var ctx = canvas.getContext("2d");
for (var i = 0; i < newCurrentPixels.length; i++) {
pixel = newCurrentPixels[i];
if (pixelMap[pixel.x][pixel.y] == undefined) {continue}
ctx.fillStyle = pixel.color;
ctx.fillRect(pixel.x*pixelSize+(18*Math.sin((pixel.y)/4.4)), pixel.y*pixelSize+(18*Math.sin((pixel.x)/4.4)), pixelSize, pixelSize);
if (pixel.charge) { // Yellow glow on charge
if (!elements[pixel.element].colorOn) {
ctx.fillStyle = "rgba(255,255,0,0.5)";
ctx.fillRect(pixel.x*pixelSize, pixel.y*pixelSize, pixelSize, pixelSize);
}
}
}
}
if ((!paused) || forceTick) {pixelTicks++};
}
});