Merge pull request #548 from JustAGenericUsername/main

skin
This commit is contained in:
slweeb 2024-04-20 23:24:57 -04:00 committed by GitHub
commit 4b802d0e5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 59 additions and 0 deletions

View File

@ -9,10 +9,12 @@ elements.change_count = {
onSelect: function() {
var cans = prompt("Please input how many elements you would like to be generared each time.", 10000);
if (!cans) { return }
if (cans == "skin"){settings.randomcount = 10000; settings.skineasteregg = true; saveSettings(); alert("skin"); return}
if (cans > 2000000){alert("You have put too big of a number! This would surely crash your browser or eat up all your RAM! Element count will remain unchanged."); return}
if (cans < 1 && (parseInt(cans) > -1) ){alert("You have either put a decimal or zero. Why? Element count will remain unchanged."); return}
if (isNaN(parseInt(cans))){alert("Apparently your input isnt even a number. Try again. Element count will remain unchanged."); return}
settings.randomcount = parseInt(cans)
settings.skineasteregg = false;
saveSettings()
},
category: "random"
@ -34,6 +36,7 @@ var randomProperty = function (obj) {
return obj[keys[ keys.length* Math.random() << 0]];
};
if (Math.abs(settings.randomcount) == settings.randomcount){
if (!settings.skineasteregg){
for (var i = 1; i <= settings.randomcount; i++){
var f = Math.random() < 0.2
var co = Math.random() < 0.2
@ -72,6 +75,21 @@ if (Math.abs(settings.randomcount) == settings.randomcount){
}
}
}
} else {
for (var i = 1; i <= settings.randomcount; i++){
elements["skin_" + i] = {
color: elements.skin.color,
category: "skin",
tick: function(pixel){
changePixel(pixel, "skin", false)
},
density: elements.skin.color,
behavior: behaviors.WALL,
state: "solid",
name: "skin"
}
}
}
} else {
window.addEventListener('load', function() {
elementslist = []

View File

@ -2655,3 +2655,44 @@ elements.grid_brush = {
}
}
}
elements.healing_serum = {
color: ["#79d2c5", "#77d8c0", "#78ddb9", "#7de1b0", "#85e6a6", "#91e99a", "#9fec8e"],
behavior: behaviors.LIQUID,
category: "liquids",
state: "liquid",
properties: {
wait: 15,
waitReduce: false,
},
tick: function(pixel){
if (pixel.waitReduce){pixel.wait -= 1}
if (pixel.wait == 0){
pixel.elementsSeen = {}
}
for (var i = 0; i < adjacentCoords.length; i++) {
var coord = adjacentCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (!isEmpty(x,y, true)){
if (!pixel.waitReduce){
pixel.waitReduce = true
}
if (pixel.wait == 0){
if (!pixel.elementsSeen[pixelMap[x][y].element] && pixelMap[x][y].element != "healing_serum"){
pixel.elementsSeen[pixelMap[x][y].element] = 1
} else if (pixelMap[x][y].element != "healing_serum") {
pixel.elementsSeen[pixelMap[x][y].element] += 1
}
}
}
if (pixel.wait == 0){
if (Object.keys(pixel.elementsSeen).length == 0){
deletePixel(pixel.x, pixel.y)
return;
} else{
changePixel(pixel, Object.keys(pixel.elementsSeen).reduce((a, b) => pixel.elementsSeen[a] > pixel.elementsSeen[b] ? a : b))
}
}
}
}
}