From 89abf3659d27e686639e994e95071562cad8770c Mon Sep 17 00:00:00 2001 From: O-01-67 <68935009+O-01-67@users.noreply.github.com> Date: Fri, 8 Jul 2022 22:31:12 -0400 Subject: [PATCH] function alteration test suffixes a function to drawPixels that makes burning pixels have a red overlay like shocked pixels's yellow overlay --- mods/functest.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 mods/functest.js diff --git a/mods/functest.js b/mods/functest.js new file mode 100644 index 00000000..782caf5d --- /dev/null +++ b/mods/functest.js @@ -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(); +}; \ No newline at end of file