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:
parent
c0625c669a
commit
89abf3659d
|
|
@ -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();
|
||||
};
|
||||
Loading…
Reference in New Issue