function alteration test

suffixes a function to drawPixels that makes burning pixels have a red overlay like shocked pixels's yellow overlay
This commit is contained in:
O-01-67 2022-07-08 22:31:12 -04:00 committed by GitHub
parent c0625c669a
commit 89abf3659d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 0 deletions

39
mods/functest.js Normal file
View File

@ -0,0 +1,39 @@
oldDrawPixels = drawPixels;
suffixFunction = function() {
// newCurrentPixels = shuffled currentPixels
var newCurrentPixels = currentPixels;
var pixelsFirst = [];
var pixelsLast = [];
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 || currentPixels.indexOf(pixel) == -1) {continue}
if (pixel.del) {continue};
if (elements[pixel.element].isGas) {
pixelsLast.push(pixel);
}
else {
pixelsFirst.push(pixel);
}
}
var pixelDrawList = pixelsFirst.concat(pixelsLast);
for (var i = 0; i < pixelDrawList.length; i++) {
pixel = pixelDrawList[i];
if (pixelMap[pixel.x][pixel.y] == undefined) {continue}
if (pixel.burning && view !== 2) { // Red glow on burn
//if (!elements[pixel.element].colorOn) {
ctx.fillStyle = "rgba(255,0,0,0.5)";
ctx.fillRect(pixel.x*pixelSize, pixel.y*pixelSize, pixelSize, pixelSize);
//}
}
}
}
drawPixels = function(forceTick=false) {
oldDrawPixels(forceTick);
suffixFunction();
};