healing serum better

This commit is contained in:
JustAGenericUsername 2025-01-18 23:36:29 -05:00
parent 27acdbd2c5
commit 2e32e421f4
1 changed files with 29 additions and 24 deletions

View File

@ -2676,33 +2676,38 @@ elements.healing_serum = {
}, },
tick: function(pixel){ tick: function(pixel){
if (pixel.waitReduce){pixel.wait -= 1} if (pixel.waitReduce){pixel.wait -= 1}
if (pixel.wait == 0){ if (!pixel.decidedPixel){
pixel.elementsSeen = {} for (var i = 0; i < squareCoords.length; i++) {
} var coord = squareCoords[i];
for (var i = 0; i < adjacentCoords.length; i++) { var x = pixel.x+coord[0];
var coord = adjacentCoords[i]; var y = pixel.y+coord[1];
var x = pixel.x+coord[0]; if (!isEmpty(x, y, true)){
var y = pixel.y+coord[1]; let otherPixel = pixelMap[x][y]
if (!isEmpty(x,y, true)){ if (otherPixel.element != "healing_serum"){
if (!pixel.waitReduce){ pixel.decidedPixel = otherPixel
pixel.waitReduce = true pixel.waitReduce = true
} break;
if (pixel.wait == 0){
if (!pixel.elementsSeen[pixelMap[x][y].element] && !(["healing_serum", "bless", "experience"].includes(pixelMap[x][y].element))){
pixel.elementsSeen[pixelMap[x][y].element] = 1
} else if (!(["healing_serum", "bless", "experience"].includes(pixelMap[x][y].element))) {
pixel.elementsSeen[pixelMap[x][y].element] += 1
} }
} }
} }
if (pixel.wait == 0){ }
if (Object.keys(pixel.elementsSeen).length == 0){ if (pixel.wait <= 0){
deletePixel(pixel.x, pixel.y) const { x, y, ...remainingProperties } = pixel.decidedPixel;
return; Object.assign(pixel, remainingProperties);
} else{ delete pixel.decidedPixel
changePixel(pixel, Object.keys(pixel.elementsSeen).reduce((a, b) => pixel.elementsSeen[a] > pixel.elementsSeen[b] ? a : b)) return;
} }
} },
renderer: function(pixel, ctx){
// interpolate pixel color and decidedpixel's color (if it has one!)
if (pixel.decidedPixel){
var color1 = pixel.color.match(/\d+/g);
var color2 = pixel.decidedPixel.color.match(/\d+/g);
var ratio = pixel.wait/15
drawSquare(ctx, `rgb(${color1[0]*ratio+color2[0]*(1-ratio)},${color1[1]*ratio+color2[1]*(1-ratio)},${color1[2]*ratio+color2[2]*(1-ratio)})`, pixel.x, pixel.y)
}
else{
drawSquare(ctx, pixel.color, pixel.x, pixel.y)
} }
} }
} }