Merge branch 'main' of https://github.com/slweeb/sandboxels
This commit is contained in:
commit
28de8e7093
|
|
@ -0,0 +1,121 @@
|
||||||
|
elements.bacteria = {
|
||||||
|
color: ["#e6d3f2", "#c098d9", "#6e318f", "#6e318f"],
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tick: function(pixel) {
|
||||||
|
neighbors = [[-1,0],[0,-1],[1,0],[0,1]]
|
||||||
|
if(pixel.charge) { //when shocked
|
||||||
|
if(!outOfBounds(pixel.x,pixel.y+1) && !isEmpty(pixel.x,pixel.y+1)) { //check if a pixel exists below to store the element of
|
||||||
|
if(!pixel.active && !pixel.target && pixelMap[pixel.x][pixel.y+1].element != pixel.element) { //exclude self and only fire once
|
||||||
|
pixel.target = pixelMap[pixel.x][pixel.y+1].element
|
||||||
|
pixel.active = true
|
||||||
|
} else if(pixel.active || pixel.target || pixelMap[pixel.x][pixel.y+1].element == pixel.element) {
|
||||||
|
pixel.active = pixel.active
|
||||||
|
pixel.target = pixel.target
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pixel.active) {
|
||||||
|
if(pixel.target) { //safety
|
||||||
|
for(i = 0; i < neighbors.length; i++) { //iterate through neighbor spots
|
||||||
|
if(!isEmpty(pixel.x+neighbors[i][0],pixel.y+neighbors[i][1],true)) { //check for neighbors
|
||||||
|
if(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].element == pixel.target) { //if neighbor element is the target
|
||||||
|
changePixel(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]],pixel.element) //change neighbors to itself
|
||||||
|
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].target = pixel.target //set new bacteria target
|
||||||
|
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].active = true //activate new bacteria
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Math.random() < 0.02) { //decay
|
||||||
|
if(!isEmpty(pixel.x,pixel.y)) { //check if position is empty
|
||||||
|
if(pixelMap[pixel.x][pixel.y].element == pixel.element) { //check if position is still bacteria
|
||||||
|
deletePixel(pixel.x,pixel.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*if(pixel.active && pixel.target) { //debug
|
||||||
|
pixel.color = "rgb(255,0,0)"
|
||||||
|
}*/
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
|
state: "solid",
|
||||||
|
density: 1,
|
||||||
|
conduct: elements.water.conduct + 0.1,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.replacer_bacteria = {
|
||||||
|
color: ["#fcbbc0", "#f28089", "#f04f5c", "#f04f5c"],
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tick: function(pixel) {
|
||||||
|
neighbors = [[-1,0],[0,-1],[1,0],[0,1]]
|
||||||
|
if(pixel.charge) { //when shocked
|
||||||
|
if(!outOfBounds(pixel.x,pixel.y+1) && !isEmpty(pixel.x,pixel.y+1) && !outOfBounds(pixel.x,pixel.y-1) && !isEmpty(pixel.x,pixel.y-1)) { //check if pixels exists above and below to store the elements of
|
||||||
|
if(!pixel.active && !pixel.target && !pixel.replacement && pixelMap[pixel.x][pixel.y+1].element != pixel.element) { //exclude self and only fire once
|
||||||
|
pixel.target = pixelMap[pixel.x][pixel.y+1].element
|
||||||
|
pixel.replacement = pixelMap[pixel.x][pixel.y-1].element
|
||||||
|
pixel.active = true
|
||||||
|
} else if(pixel.active || pixel.target || pixel.replacement || pixelMap[pixel.x][pixel.y+1].element == pixel.element) {
|
||||||
|
pixel.active = pixel.active
|
||||||
|
pixel.target = pixel.target
|
||||||
|
pixel.replacement = pixel.replacement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pixel.active) {
|
||||||
|
if(pixel.target && pixel.replacement) { //safety
|
||||||
|
for(i = 0; i < neighbors.length; i++) { //iterate through neighbor spots
|
||||||
|
if(!isEmpty(pixel.x+neighbors[i][0],pixel.y+neighbors[i][1],true)) { //check for neighbors
|
||||||
|
if(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].element == pixel.target) { //if neighbor element is the target
|
||||||
|
changePixel(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]],pixel.element) //change neighbors to itself
|
||||||
|
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].target = pixel.target //set new bacteria target
|
||||||
|
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].replacement = pixel.replacement //set new bacteria replacement
|
||||||
|
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].active = true //activate new bacteria
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isEmpty(pixel.x,pixel.y)) { //check if own position is empty
|
||||||
|
if(pixelMap[pixel.x][pixel.y].element == pixel.element) { //check if own position is still bacteria
|
||||||
|
changePixel(pixelMap[pixel.x][pixel.y],pixel.replacement)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*if(pixel.active && pixel.target && pixel.replacement) { //debug
|
||||||
|
pixel.color = "rgb(0,255,0)"
|
||||||
|
}*/
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
|
state: "solid",
|
||||||
|
density: 1,
|
||||||
|
conduct: elements.water.conduct + 0.1,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.jammer_block = {
|
||||||
|
color: "#c0cf7e",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tick: function(pixel) {
|
||||||
|
neighbors = [[-1,0],[0,-1],[1,0],[0,1]]
|
||||||
|
if(pixel.charge) { //when shocked
|
||||||
|
for (var i = 0; i < width; i++) {
|
||||||
|
for (var j = 0; j < height; j++) {
|
||||||
|
if(isEmpty(i,j,true) == false) {
|
||||||
|
if(pixelMap[i][j].element == "bacteria") {
|
||||||
|
if(isEmpty(i,j,true) == false) { deletePixel(i,j) }
|
||||||
|
} else if(pixelMap[i][j].element == "replacer_bacteria") {
|
||||||
|
if(pixelMap[i][j].replacement) {
|
||||||
|
if(isEmpty(i,j,true) == false) { changePixel(pixelMap[i][j],pixelMap[i][j].replacement) }
|
||||||
|
} else {
|
||||||
|
if(isEmpty(i,j,true) == false) { deletePixel(i,j) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
|
state: "solid",
|
||||||
|
density: 1,
|
||||||
|
conduct: elements.water.conduct + 0.1,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
elements.bioooze = {
|
||||||
|
color: ["#53FF4F", "#53FF4F", "#06DE00", "#04A600", "#036E00"],
|
||||||
|
behavior: behaviors.LIQUID,
|
||||||
|
tempHigh: 100,
|
||||||
|
stateHigh: ["plague","slime","steam","poison"],
|
||||||
|
//tempLow: -4,
|
||||||
|
//stateLow: "bioooze_ice",
|
||||||
|
category: "liquids",
|
||||||
|
heatCapacity: 3.52, //unimplemented feature
|
||||||
|
name: "bio-ooze",
|
||||||
|
reactions: {
|
||||||
|
"water": { "elem1":"slime", "elem2":"slime" }, //balance
|
||||||
|
"poison": { "elem1":"slime", "elem2":"slime" }, //balance
|
||||||
|
//"acid": { "elem1":"wastestone" }, //acid should be sulfuric acid and product should be wastestone
|
||||||
|
//"elder_fluid": { "elem1":"corrupt_slime" }, //acid should be sulfuric acid and product should be wastestone
|
||||||
|
//"mercury": { "elem1":"liquid_protocite" }, //acid should be sulfuric acid and product should be wastestone
|
||||||
|
//"blue_grav_liquid": { "elem1":"blue_grav_liquid" }, //bgl would set gravity to upwards gravity
|
||||||
|
//thank fuck that elements are rotatable in sandboxels or else this
|
||||||
|
//would be meaningless and unimplementable
|
||||||
|
"blood": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "infection" },
|
||||||
|
"soap": { "elem1": "slime", "chance": 0.02 },
|
||||||
|
"plant": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"grass": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"algae": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"mushroom_spore": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"lichen": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"rat": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"frog": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"fish": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"bird": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"head": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"body": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"ant": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "dust" },
|
||||||
|
"worm": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "dust" },
|
||||||
|
"fly": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "dust" },
|
||||||
|
"firefly": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "dust" },
|
||||||
|
"bee": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "dust" },
|
||||||
|
"slug": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "dust" },
|
||||||
|
"snail": { "elem1": ["bioooze","bioooze","bioooze","bioooze","poison","slime",null], "elem2": "calcium" },
|
||||||
|
"sapling": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"root": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"flower_seed": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"pistil": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"petal": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"grass_seed": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "dead_plant" },
|
||||||
|
"meat": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "rotten_meat" },
|
||||||
|
"wood": { "elem1": ["bioooze","bioooze","poison","slime",null], "elem2": "sawdust", "chance": 0.25 }
|
||||||
|
},
|
||||||
|
/*reactions: {
|
||||||
|
"dirt": { // React with (water reacts with dirt to make mud)
|
||||||
|
"elem1": null, // First element transforms into; in this case, water deletes itself
|
||||||
|
"elem2": "mud", // Second element transforms into; in this case, dirt turns to mud
|
||||||
|
},
|
||||||
|
"sand": { "elem1": null, "elem2": "wet_sand", },
|
||||||
|
"salt": { "elem1": "salt_water", "elem2": null },
|
||||||
|
"sugar": { "elem1": "sugar_water", "elem2": null, },
|
||||||
|
"dust": { "elem1": "dirty_water", "elem2": null, },
|
||||||
|
"ash": { "elem1": "dirty_water", "elem2": null, },
|
||||||
|
"cyanide": { "elem1": "dirty_water", "elem2": null, },
|
||||||
|
"carbon_dioxide": { "elem1": "seltzer", "elem2": null, "oneway":true },
|
||||||
|
"sulfur": { "elem1": "dirty_water", "elem2": null, },
|
||||||
|
"rat": { "elem1": "dirty_water", chance:0.005 },
|
||||||
|
"plague": { "elem1": "dirty_water", "elem2": null, },
|
||||||
|
"rust": { "elem1": "dirty_water", chance:0.005 },
|
||||||
|
"fallout": { "elem1": "dirty_water", chance:0.25 },
|
||||||
|
"radiation": { "elem1": "dirty_water", chance:0.25 },
|
||||||
|
"uranium": { "elem1": "dirty_water", chance:0.25 },
|
||||||
|
"quicklime": { "elem1": null, "elem2": "slaked_lime", },
|
||||||
|
"rock": { "elem2": "wet_sand", "chance": 0.00035 },
|
||||||
|
"ruins": { "elem2": "rock", "chance": 0.00035 },
|
||||||
|
"mudstone": { "elem2": "mud", "chance": 0.00035 },
|
||||||
|
"methane": { "elem1":"primordial_soup", "elem2":"primordial_soup", tempMin:60, charged:true },
|
||||||
|
"ammonia": { "elem1":"primordial_soup", "elem2":"primordial_soup", tempMin:60, charged:true },
|
||||||
|
},*/
|
||||||
|
state: "liquid",
|
||||||
|
density: 1.03,
|
||||||
|
conduct: 0.0008,
|
||||||
|
stain: 0.2,
|
||||||
|
viscosity: 60,
|
||||||
|
description: "A particularly potent toxic sludge loaded with parasites and ickiness.",
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
function _rgbToHex(color) {
|
||||||
|
if(typeof(color) == "object") { //Expects object like "{r: 172, g: 11, b: 34}"
|
||||||
|
//console.log("Loading colors");
|
||||||
|
//console.log("Loading R");
|
||||||
|
var red = color.r;
|
||||||
|
//console.log("Loading G");
|
||||||
|
var green = color.g;
|
||||||
|
//console.log("Loading B");
|
||||||
|
var blue = color.b;
|
||||||
|
//console.log("Rounding R");
|
||||||
|
red = Math.round(red);
|
||||||
|
//console.log("Rounding G");
|
||||||
|
green = Math.round(green);
|
||||||
|
//console.log("Rounding B");
|
||||||
|
blue = Math.round(blue);
|
||||||
|
//console.log("Bounding R");
|
||||||
|
red = Math.min(255,Math.max(0,red));
|
||||||
|
//console.log("Bounding G");
|
||||||
|
green = Math.min(255,Math.max(0,green));
|
||||||
|
//console.log("Bounding B");
|
||||||
|
blue = Math.min(255,Math.max(0,blue));
|
||||||
|
//console.log("Converting R");
|
||||||
|
red = red.toString(16);
|
||||||
|
//console.log("Converting G");
|
||||||
|
green = green.toString(16);
|
||||||
|
//console.log("Converting B");
|
||||||
|
blue = blue.toString(16);
|
||||||
|
//console.log("Padding R");
|
||||||
|
while(red.length < 2) {
|
||||||
|
red = "0" + red;
|
||||||
|
};
|
||||||
|
//console.log("Padding G");
|
||||||
|
while(green.length < 2) {
|
||||||
|
green = "0" + green;
|
||||||
|
};
|
||||||
|
//console.log("Padding B");
|
||||||
|
while(blue.length < 2) {
|
||||||
|
blue = "0" + blue;
|
||||||
|
};
|
||||||
|
//console.log("Concatenating");
|
||||||
|
return "#" + red + green + blue;
|
||||||
|
} else if(typeof(color) == "string") { //Expects string like "rgb(20,137,4)".
|
||||||
|
//console.log("Splitting string")
|
||||||
|
color = color.split(",");
|
||||||
|
//console.log("Getting R");
|
||||||
|
var red = parseFloat(color[0].substring(4))
|
||||||
|
//console.log("Getting G");
|
||||||
|
var green = parseFloat(color[1])
|
||||||
|
//console.log("Getting B");
|
||||||
|
var blue = parseFloat(color[2].slice(0,-1))
|
||||||
|
//console.log("Rounding R");
|
||||||
|
red = Math.round(red);
|
||||||
|
//console.log("Rounding G");
|
||||||
|
green = Math.round(green);
|
||||||
|
//console.log("Rounding B");
|
||||||
|
blue = Math.round(blue);
|
||||||
|
//console.log("Bounding R");
|
||||||
|
red = Math.min(255,Math.max(0,red));
|
||||||
|
//console.log("Bounding G");
|
||||||
|
green = Math.min(255,Math.max(0,green));
|
||||||
|
//console.log("Bounding B");
|
||||||
|
blue = Math.min(255,Math.max(0,blue));
|
||||||
|
//console.log("Converting R");
|
||||||
|
red = red.toString(16);
|
||||||
|
//console.log("Converting G");
|
||||||
|
green = green.toString(16);
|
||||||
|
//console.log("Converting B");
|
||||||
|
blue = blue.toString(16);
|
||||||
|
//console.log("Padding R");
|
||||||
|
while(red.length < 2) {
|
||||||
|
red = "0" + red;
|
||||||
|
};
|
||||||
|
//console.log("Padding G");
|
||||||
|
while(green.length < 2) {
|
||||||
|
green = "0" + green;
|
||||||
|
};
|
||||||
|
//console.log("Padding B");
|
||||||
|
while(blue.length < 2) {
|
||||||
|
blue = "0" + blue;
|
||||||
|
};
|
||||||
|
//console.log("Concatenating");
|
||||||
|
return "#" + red + green + blue;
|
||||||
|
} else {
|
||||||
|
throw "error: Only objects and strings are supported."
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
elements.multiply_color = {
|
||||||
|
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var rgb = currentColor.replace("#","").match(/.{1,2}/g);
|
||||||
|
for (var i = 0; i < rgb.length; i++) {
|
||||||
|
rgb[i] = parseInt(rgb[i],16);
|
||||||
|
}
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [Math.round(oldColor.r * (rgb[0] / 255)), Math.round(oldColor.g * (rgb[1] / 255)), Math.round(oldColor.b * (rgb[2] / 255))]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
customColor: true,
|
||||||
|
category: "color tools", //the toolbar is getting cluttered
|
||||||
|
excludeRandom: true, //the toolbar is getting cluttered
|
||||||
|
}
|
||||||
|
|
||||||
|
/*elements.divide_color = { //can't get it to work how I want it to work
|
||||||
|
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var rgb = currentColor.replace("#","").match(/.{1,2}/g);
|
||||||
|
for (var i = 0; i < rgb.length; i++) {
|
||||||
|
rgb[i] = parseInt(rgb[i],16);
|
||||||
|
}
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [Math.round(256 / ((rgb[0] + 1) / (oldColor.r + 1))), Math.round(256 / ((rgb[1] + 1) / (oldColor.g + 1))), Math.round(256 / ((rgb[2] + 1) / (oldColor.b + 1)))]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
customColor: true,
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}*/
|
||||||
|
|
||||||
|
elements.add_color = {
|
||||||
|
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var rgb = currentColor.replace("#","").match(/.{1,2}/g);
|
||||||
|
for (var i = 0; i < rgb.length; i++) {
|
||||||
|
rgb[i] = parseInt(rgb[i],16);
|
||||||
|
}
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [Math.min(oldColor.r + rgb[0], 255), Math.min(oldColor.g + rgb[1], 255), Math.min(oldColor.b + rgb[2], 255)]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
customColor: true,
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.subtract_color = {
|
||||||
|
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var rgb = currentColor.replace("#","").match(/.{1,2}/g);
|
||||||
|
for (var i = 0; i < rgb.length; i++) {
|
||||||
|
rgb[i] = parseInt(rgb[i],16);
|
||||||
|
}
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [Math.max(oldColor.r - rgb[0], 0), Math.max(oldColor.g - rgb[1], 0), Math.max(oldColor.b - rgb[2], 0)]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
customColor: true,
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.grayscale = {
|
||||||
|
color: ["#7f7f7f"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var lightness = Math.round((oldColor.r * 0.299) + (oldColor.g * 0.587) + (oldColor.b * 0.114))
|
||||||
|
var finalColor = [lightness, lightness, lightness]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.invert = {
|
||||||
|
color: ["#ff0000", "#00ffff"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [(255 - oldColor.r), (255 - oldColor.g), (255 - oldColor.b)]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.reverse_R_G_B = {
|
||||||
|
color: ["#7f7f7f"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [oldColor.b, oldColor.g, oldColor.r]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.shift_R_G_B = {
|
||||||
|
color: ["#7f7f7f"],
|
||||||
|
tool: function(pixel) {
|
||||||
|
// convert the hex of currentColor to rgb and set it as a string
|
||||||
|
var oldColor = hexToRGB(_rgbToHex(pixel.color))
|
||||||
|
var finalColor = [oldColor.g, oldColor.b, oldColor.r]
|
||||||
|
pixel.color = "rgb(" + finalColor.join(",") + ")"
|
||||||
|
},
|
||||||
|
category: "color tools",
|
||||||
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
sussyKey = null;
|
||||||
|
isShift = false;
|
||||||
|
isAlt = false;
|
||||||
|
|
||||||
|
document.addEventListener("keydown", function(modifierDownListener) {
|
||||||
|
// User presses shift
|
||||||
|
if (modifierDownListener.keyCode == 16) {
|
||||||
|
isShift = true;
|
||||||
|
}
|
||||||
|
// User presses alt
|
||||||
|
if (modifierDownListener.keyCode == 18) {
|
||||||
|
isAlt = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("keyup", function(modifierUpListener) {
|
||||||
|
// User releases shift
|
||||||
|
if (modifierUpListener.keyCode == 16) {
|
||||||
|
isShift = false;
|
||||||
|
}
|
||||||
|
// User releases alt
|
||||||
|
if (modifierUpListener.keyCode == 18) {
|
||||||
|
isAlt = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("keyup", function(sussyListener) {
|
||||||
|
switch (sussyListener.keyCode) {
|
||||||
|
case 87:
|
||||||
|
sussyKey = "W";
|
||||||
|
break;
|
||||||
|
case 65:
|
||||||
|
sussyKey = "A";
|
||||||
|
break;
|
||||||
|
case 83:
|
||||||
|
sussyKey = "S";
|
||||||
|
break;
|
||||||
|
case 68:
|
||||||
|
sussyKey = "D";
|
||||||
|
break;
|
||||||
|
case 81:
|
||||||
|
sussyKey = "Q";
|
||||||
|
break;
|
||||||
|
case 88:
|
||||||
|
sussyKey = "X";
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
sussyKey = "Z";
|
||||||
|
break;
|
||||||
|
case 72:
|
||||||
|
sussyKey = "H";
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function tryCreatePixel(_element,_x,_y) {
|
||||||
|
if(!elements[_element]) {
|
||||||
|
throw new Error("Element " + _element + " doesn't exist!");
|
||||||
|
};
|
||||||
|
if(isEmpty(_x,_y)) {
|
||||||
|
createPixel(_element,_x,_y);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function controllablePixelTryCreatePixelNullCheck(_element,_x,_y) {
|
||||||
|
if(!elements[_element]) { //catch the null
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if(isEmpty(_x,_y)) {
|
||||||
|
tryCreatePixel(_element,_x,_y);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.controllable_pixel = {
|
||||||
|
color: "#FFFFFF",
|
||||||
|
colorOn: "#FFFF00",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
state: "solid",
|
||||||
|
density: 2000,
|
||||||
|
maxSize: 1,
|
||||||
|
conduct: 1,
|
||||||
|
hardness: 1,
|
||||||
|
tick: function(pixel) {
|
||||||
|
var xx = pixel.x;
|
||||||
|
var yy = pixel.y;
|
||||||
|
userElement = currentElement;
|
||||||
|
if(userElement === pixel.element) {
|
||||||
|
userElement = null;
|
||||||
|
};
|
||||||
|
if(isShift && !isAlt) {
|
||||||
|
sussyKey === "Z" ? pixel.color = "rgb(255,191,127)" : pixel.color = "rgb(255,127,127)";
|
||||||
|
}
|
||||||
|
if(isAlt && !isShift) {
|
||||||
|
sussyKey === "Z" ? pixel.color = "rgb(191,255,127)" : pixel.color = "rgb(127,255,127)";
|
||||||
|
}
|
||||||
|
if(isAlt && isShift) {
|
||||||
|
sussyKey === "Z" ? pixel.color = "rgb(255,255,0)" : pixel.color = "rgb(255,255,127)";
|
||||||
|
}
|
||||||
|
if(!isAlt && !isShift) {
|
||||||
|
sussyKey === "Z" ? pixel.color = "rgb(255,255,191)" : pixel.color = "rgb(255,255,255)";
|
||||||
|
}
|
||||||
|
if(sussyKey !== null) {
|
||||||
|
switch (sussyKey) {
|
||||||
|
case "W":
|
||||||
|
isAlt ? controllablePixelTryCreatePixelNullCheck(userElement,xx,yy-1) : tryMove(pixel,xx,yy-1);
|
||||||
|
if(!isShift) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "A":
|
||||||
|
isAlt ? controllablePixelTryCreatePixelNullCheck(userElement,xx-1,yy) : tryMove(pixel,xx-1,yy);
|
||||||
|
if(!isShift) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "S":
|
||||||
|
isAlt ? controllablePixelTryCreatePixelNullCheck(userElement,xx,yy+1) : tryMove(pixel,xx,yy+1);
|
||||||
|
if(!isShift) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "D":
|
||||||
|
tryMove(pixel,xx+1,yy);
|
||||||
|
if(!isShift) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "H": //Alt+D is something else in some browsers.
|
||||||
|
if(isAlt) {
|
||||||
|
controllablePixelTryCreatePixelNullCheck(userElement,xx+1,yy);
|
||||||
|
};
|
||||||
|
if(!isShift) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "X":
|
||||||
|
explodeAt(xx,yy,5)
|
||||||
|
if(!isShift) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Z":
|
||||||
|
if (!pixel.charge && !pixel.chargeCD && !isEmpty(pixel.x,pixel.y,true)) {
|
||||||
|
pixel.charge = 1;
|
||||||
|
}
|
||||||
|
if(!isShift === 0) {
|
||||||
|
sussyKey = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Q": //Use if a key gets stuck
|
||||||
|
sussyKey = null;
|
||||||
|
isShift = null;
|
||||||
|
isAlt = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
function highBloodColumn(xx,yy) {
|
||||||
|
//console.log("from " + xx + "," + yy)
|
||||||
|
if(!outOfBounds(xx,yy)) {
|
||||||
|
for(i = yy; i < pixelMap[xx].length; i++) {
|
||||||
|
if(isEmpty(xx,i,false)) {
|
||||||
|
if(Math.random() < 0.5) {
|
||||||
|
createPixel("blood",xx,i)
|
||||||
|
}
|
||||||
|
if(Math.random() < 0.3) {
|
||||||
|
if(!isEmpty(xx,yy,true)) {
|
||||||
|
deletePixel(xx,yy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(!isEmpty(xx,i,false) && !outOfBounds(xx,i)) {
|
||||||
|
break;
|
||||||
|
} else if(!isEmpty(xx,i,false) && outOfBounds(xx,i)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//cliche'
|
||||||
|
elements.blood_cloud = {
|
||||||
|
color: "#9c3e35",
|
||||||
|
behavior: [
|
||||||
|
"XX|XX|XX",
|
||||||
|
"XX|CH:blood%0.05|M1%2.5 AND BO",
|
||||||
|
"XX|XX|XX",
|
||||||
|
],
|
||||||
|
category:"gases",
|
||||||
|
temp: 30,
|
||||||
|
state: "gas",
|
||||||
|
density: 0.5,
|
||||||
|
ignoreAir: true,
|
||||||
|
conduct: 0.03,
|
||||||
|
stain: 0.02,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.heavy_blood_cloud = {
|
||||||
|
color: "#c22d23",
|
||||||
|
behavior: [
|
||||||
|
"XX|XX|XX",
|
||||||
|
"XX|CH:blood%0.1|M1%2.5 AND BO",
|
||||||
|
"XX|CR:blood%0.05|XX",
|
||||||
|
],
|
||||||
|
category:"gases",
|
||||||
|
temp: 30,
|
||||||
|
state: "gas",
|
||||||
|
density: 0.7,
|
||||||
|
ignoreAir: true,
|
||||||
|
conduct: 0.03,
|
||||||
|
stain: 0.03,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.heavier_blood_cloud = {
|
||||||
|
color: "#b02219",
|
||||||
|
behavior: [
|
||||||
|
"XX|XX|XX",
|
||||||
|
"XX|CH:blood%0.2|M1%2.5 AND BO",
|
||||||
|
"XX|CR:blood%0.1|XX",
|
||||||
|
],
|
||||||
|
category:"gases",
|
||||||
|
temp: 30,
|
||||||
|
state: "gas",
|
||||||
|
density: 0.9,
|
||||||
|
ignoreAir: true,
|
||||||
|
conduct: 0.03,
|
||||||
|
stain: 0.04,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.heaviest_blood_cloud = {
|
||||||
|
color: "#910f07",
|
||||||
|
behavior: [
|
||||||
|
"XX|XX|XX",
|
||||||
|
"XX|CH:blood%0.4|M1%2.5 AND BO",
|
||||||
|
"XX|CR:blood%0.2|XX",
|
||||||
|
],
|
||||||
|
category:"gases",
|
||||||
|
temp: 30,
|
||||||
|
state: "gas",
|
||||||
|
density: 1.1,
|
||||||
|
ignoreAir: true,
|
||||||
|
conduct: 0.03,
|
||||||
|
stain: 0.05,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.heaviester_blood_cloud = {
|
||||||
|
color: "#690600",
|
||||||
|
behavior: [
|
||||||
|
"XX|XX|XX",
|
||||||
|
"XX|CH:blood%0.8|M1%2.5 AND BO",
|
||||||
|
"XX|CR:blood%0.4|XX",
|
||||||
|
],
|
||||||
|
tick: function(pixel) {
|
||||||
|
if(Math.random() < 0.01) {
|
||||||
|
for(i = pixel.y + 1; i < pixelMap[i].length; i++) {
|
||||||
|
if(isEmpty(pixel.x,i,false)) {
|
||||||
|
if(Math.random() < 0.5) {
|
||||||
|
createPixel("blood",pixel.x,i)
|
||||||
|
}
|
||||||
|
if(Math.random() < 0.3) {
|
||||||
|
if(!isEmpty(pixel.x,pixel.y,true)) {
|
||||||
|
deletePixel(pixel.x,pixel.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(!isEmpty(pixel.x,i,false) && !outOfBounds(pixel.x,i)) {
|
||||||
|
break;
|
||||||
|
} else if(!isEmpty(pixel.x,i,false) && outOfBounds(pixel.x,i)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category:"gases",
|
||||||
|
temp: 30,
|
||||||
|
state: "gas",
|
||||||
|
density: 1.15,
|
||||||
|
ignoreAir: true,
|
||||||
|
conduct: 0.03,
|
||||||
|
stain: 0.06,
|
||||||
|
},
|
||||||
|
|
||||||
|
elements.heaviestest_blood_cloud = {
|
||||||
|
color: "#330301",
|
||||||
|
behavior: [
|
||||||
|
"XX|CR:blood%0.8|XX",
|
||||||
|
"CR:blood%0.05|CH:blood%3|CR:blood%0.05 AND M1%2.5 AND BO",
|
||||||
|
"XX|CR:blood%0.8|XX",
|
||||||
|
],
|
||||||
|
tick: function(pixel) {
|
||||||
|
if(Math.random() < 0.02) {
|
||||||
|
highBloodColumn(pixel.x-1,pixel.y + 1)
|
||||||
|
highBloodColumn(pixel.x,pixel.y + 1)
|
||||||
|
highBloodColumn(pixel.x+1,pixel.y + 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category:"gases",
|
||||||
|
temp: 30,
|
||||||
|
state: "gas",
|
||||||
|
density: 1.2,
|
||||||
|
ignoreAir: true,
|
||||||
|
conduct: 0.03,
|
||||||
|
stain: 0.07,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
elements.fire_slime = {
|
||||||
|
color: ["#e6683e", "#e37636", "#e38f3b", "#e3b039"],
|
||||||
|
behavior: [
|
||||||
|
"XX|CR:fire%5|XX",
|
||||||
|
"M2|XX|M2",
|
||||||
|
"M1%1 AND M2|M1|M1%1 AND M2"
|
||||||
|
],
|
||||||
|
reactions: {
|
||||||
|
"bomb": { "elem2":"sticky_bomb", "elem2":null },
|
||||||
|
},
|
||||||
|
tick: function(pixel) {
|
||||||
|
if(Math.random() < 0.01) {
|
||||||
|
pixel.temp++;
|
||||||
|
pixelTempCheck(pixel);
|
||||||
|
};
|
||||||
|
if(pixel.temp < 700) {
|
||||||
|
if(Math.random() < 0.02) {
|
||||||
|
pixel.temp++;
|
||||||
|
pixelTempCheck(pixel);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
},
|
||||||
|
viscosity: 3000,
|
||||||
|
temp: 700,
|
||||||
|
tempHigh: 6000,
|
||||||
|
stateHigh: "plasma",
|
||||||
|
tempLow: -13,
|
||||||
|
stateLow: "suppressed_fire_slime",
|
||||||
|
category: "liquids",
|
||||||
|
state: "liquid",
|
||||||
|
burning: true,
|
||||||
|
burnTime: Number.MAX_SAFE_INTEGER,
|
||||||
|
burn: 85,
|
||||||
|
burnInto: "fire_slime",
|
||||||
|
density: 1400,
|
||||||
|
stain: 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.suppressed_fire_slime = {
|
||||||
|
color: "#bf6a4e",
|
||||||
|
behavior: [
|
||||||
|
"XX|CR:smoke%1|XX",
|
||||||
|
"M2|XX|M2",
|
||||||
|
"M1%0.5 AND M2|M1|M1%0.5 AND M2"
|
||||||
|
],
|
||||||
|
reactions: {
|
||||||
|
"bomb": { "elem2":"sticky_bomb", "elem2":null },
|
||||||
|
},
|
||||||
|
tick: function(pixel) {
|
||||||
|
if(Math.random() < 0.001) {
|
||||||
|
pixel.temp++;
|
||||||
|
pixelTempCheck(pixel);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
viscosity: 4000,
|
||||||
|
temp: -20,
|
||||||
|
tempHigh: -13,
|
||||||
|
stateHigh: "fire_slime",
|
||||||
|
category: "liquids",
|
||||||
|
state: "liquid",
|
||||||
|
burning: false,
|
||||||
|
burnTime: 1000,
|
||||||
|
burn: 1,
|
||||||
|
burnInto: "fire_slime",
|
||||||
|
density: 1550,
|
||||||
|
stain: 0.04,
|
||||||
|
hidden: true
|
||||||
|
}
|
||||||
|
|
@ -3,9 +3,9 @@ for (var i = 3; i <= 15; i++) {
|
||||||
name: `${i}- cluster bomb`,
|
name: `${i}- cluster bomb`,
|
||||||
color: "#7d776d",
|
color: "#7d776d",
|
||||||
behavior: [
|
behavior: [
|
||||||
`XX|EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb_${i-1}|XX`,
|
`XX|EX:8>smoke,smoke,smoke,smoke,smoke,cluster_bomb_${i-1}%10|XX`,
|
||||||
"XX|XX|XX",
|
"XX|XX|XX",
|
||||||
`M2|M1 AND EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb_${i-1}|M2`,
|
`M2|M1 AND EX:8>smoke,smoke,smoke,smoke,smoke,cluster_bomb_${i-1}%10|M2`,
|
||||||
],
|
],
|
||||||
category: "weapons",
|
category: "weapons",
|
||||||
state: "solid",
|
state: "solid",
|
||||||
|
|
@ -19,9 +19,9 @@ for (var i = 3; i <= 15; i++) {
|
||||||
elements.cluster_bomb_2 = {
|
elements.cluster_bomb_2 = {
|
||||||
color: "#7d776d",
|
color: "#7d776d",
|
||||||
behavior: [
|
behavior: [
|
||||||
"XX|EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb|XX",
|
"XX|EX:8>smoke,smoke,smoke,smoke,smoke,cluster_bomb%10|XX",
|
||||||
"XX|XX|XX",
|
"XX|XX|XX",
|
||||||
"M2|M1 AND EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb|M2",
|
"M2|M1 AND EX:8>smoke,smoke,smoke,smoke,smoke,cluster_bomb%10|M2",
|
||||||
],
|
],
|
||||||
category: "weapons",
|
category: "weapons",
|
||||||
state: "solid",
|
state: "solid",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
if(!settings) {
|
||||||
|
settings = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!settings.bg) {
|
||||||
|
settings.bg = "#000000"
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.invisible_dye = {
|
||||||
|
color: settings.bg,
|
||||||
|
behavior: behaviors.LIQUID,
|
||||||
|
tick: function(pixel) {
|
||||||
|
var backgroundColor = hexToRGB(settings.bg);
|
||||||
|
var rgbValue = "rgb("+backgroundColor.r+","+backgroundColor.g+","+backgroundColor.b+")";
|
||||||
|
pixel.color = rgbValue;
|
||||||
|
},
|
||||||
|
hardness: 0.8,
|
||||||
|
breakInto: "invisible_dye_gas",
|
||||||
|
tempHigh: 110,
|
||||||
|
stateHigh: "invisible_dye_gas",
|
||||||
|
category: "special",
|
||||||
|
state: "liquid",
|
||||||
|
density: 1,
|
||||||
|
stain: elements.dye.stain,
|
||||||
|
};
|
||||||
|
|
||||||
|
elements.invisible_dye_gas = {
|
||||||
|
color: settings.bg,
|
||||||
|
behavior: behaviors.GAS,
|
||||||
|
tick: function(pixel) {
|
||||||
|
var backgroundColor = hexToRGB(settings.bg);
|
||||||
|
var rgbValue = "rgb("+backgroundColor.r+","+backgroundColor.g+","+backgroundColor.b+")";
|
||||||
|
pixel.color = rgbValue;
|
||||||
|
},
|
||||||
|
hardness: 0.5,
|
||||||
|
breakInto: "invisible_dye_gas",
|
||||||
|
tempLow: 109,
|
||||||
|
stateLow: "invisible_dye",
|
||||||
|
category: "special",
|
||||||
|
state: "liquid",
|
||||||
|
density: 1,
|
||||||
|
stain: elements.spray_paint.stain,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
if(!settings) {
|
||||||
|
settings = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!settings.bg) {
|
||||||
|
settings.bg = "#000000"
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.invisible_wall = {
|
||||||
|
color: settings.bg,
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tick: function(pixel) {
|
||||||
|
var backgroundColor = hexToRGB(settings.bg);
|
||||||
|
var rgbValue = "rgb("+backgroundColor.r+","+backgroundColor.g+","+backgroundColor.b+")";
|
||||||
|
pixel.color = rgbValue;
|
||||||
|
},
|
||||||
|
insulate: true,
|
||||||
|
hardness: 1,
|
||||||
|
category: "special",
|
||||||
|
state: "solid",
|
||||||
|
};
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
if(enabledMods.includes("mods/fey_and_more.js")) {
|
if(enabledMods.includes("mods/fey_and_more.js")) {
|
||||||
elements.birthpool.density = elements.primordial_soup.density;
|
elements.birthpool.density = 1250
|
||||||
|
elements.primordial_soup.density = 1250
|
||||||
elements.birthpool.state = "liquid";
|
elements.birthpool.state = "liquid";
|
||||||
};
|
};
|
||||||
|
|
||||||
runAfterLoad(function() {
|
runAfterLoad(function() {
|
||||||
if(enabledMods.includes("mods/fey_and_more.js")) {
|
if(enabledMods.includes("mods/fey_and_more.js")) {
|
||||||
elements.birthpool.density = elements.primordial_soup.density;
|
elements.birthpool.density = 1250
|
||||||
|
elements.primordial_soup.density = 1250
|
||||||
elements.birthpool.state = "liquid";
|
elements.birthpool.state = "liquid";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ elements.move_up = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x,pixel.y-1);
|
tryMove(pixel,pixel.x,pixel.y-1);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_down = {
|
elements.move_down = {
|
||||||
|
|
@ -11,7 +12,8 @@ elements.move_down = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x,pixel.y+1);
|
tryMove(pixel,pixel.x,pixel.y+1);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_left = {
|
elements.move_left = {
|
||||||
|
|
@ -19,7 +21,8 @@ elements.move_left = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x-1,pixel.y);
|
tryMove(pixel,pixel.x-1,pixel.y);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_right = {
|
elements.move_right = {
|
||||||
|
|
@ -27,7 +30,8 @@ elements.move_right = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x+1,pixel.y);
|
tryMove(pixel,pixel.x+1,pixel.y);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_up_left = {
|
elements.move_up_left = {
|
||||||
|
|
@ -35,7 +39,8 @@ elements.move_up_left = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x-1,pixel.y-1);
|
tryMove(pixel,pixel.x-1,pixel.y-1);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_down_left = {
|
elements.move_down_left = {
|
||||||
|
|
@ -43,7 +48,8 @@ elements.move_down_left = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x-1,pixel.y+1);
|
tryMove(pixel,pixel.x-1,pixel.y+1);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_up_right = {
|
elements.move_up_right = {
|
||||||
|
|
@ -51,7 +57,8 @@ elements.move_up_right = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x+1,pixel.y-1);
|
tryMove(pixel,pixel.x+1,pixel.y-1);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.move_down_right = {
|
elements.move_down_right = {
|
||||||
|
|
@ -59,5 +66,6 @@ elements.move_down_right = {
|
||||||
tool: function(pixel) {
|
tool: function(pixel) {
|
||||||
tryMove(pixel,pixel.x+1,pixel.y+1);
|
tryMove(pixel,pixel.x+1,pixel.y+1);
|
||||||
},
|
},
|
||||||
category: "tools",
|
category: "movement tools",
|
||||||
|
excludeRandom: true,
|
||||||
}
|
}
|
||||||
|
|
@ -1,121 +1,3 @@
|
||||||
elements.bacteria = {
|
|
||||||
color: ["#e6d3f2", "#c098d9", "#6e318f", "#6e318f"],
|
|
||||||
behavior: behaviors.WALL,
|
|
||||||
tick: function(pixel) {
|
|
||||||
neighbors = [[-1,0],[0,-1],[1,0],[0,1]]
|
|
||||||
if(pixel.charge) { //when shocked
|
|
||||||
if(!outOfBounds(pixel.x,pixel.y+1) && !isEmpty(pixel.x,pixel.y+1)) { //check if a pixel exists below to store the element of
|
|
||||||
if(!pixel.active && !pixel.target && pixelMap[pixel.x][pixel.y+1].element != pixel.element) { //exclude self and only fire once
|
|
||||||
pixel.target = pixelMap[pixel.x][pixel.y+1].element
|
|
||||||
pixel.active = true
|
|
||||||
} else if(pixel.active || pixel.target || pixelMap[pixel.x][pixel.y+1].element == pixel.element) {
|
|
||||||
pixel.active = pixel.active
|
|
||||||
pixel.target = pixel.target
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(pixel.active) {
|
|
||||||
if(pixel.target) { //safety
|
|
||||||
for(i = 0; i < neighbors.length; i++) { //iterate through neighbor spots
|
|
||||||
if(!isEmpty(pixel.x+neighbors[i][0],pixel.y+neighbors[i][1],true)) { //check for neighbors
|
|
||||||
if(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].element == pixel.target) { //if neighbor element is the target
|
|
||||||
changePixel(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]],pixel.element) //change neighbors to itself
|
|
||||||
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].target = pixel.target //set new bacteria target
|
|
||||||
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].active = true //activate new bacteria
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Math.random() < 0.02) { //decay
|
|
||||||
if(!isEmpty(pixel.x,pixel.y)) { //check if position is empty
|
|
||||||
if(pixelMap[pixel.x][pixel.y].element == pixel.element) { //check if position is still bacteria
|
|
||||||
deletePixel(pixel.x,pixel.y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*if(pixel.active && pixel.target) { //debug
|
|
||||||
pixel.color = "rgb(255,0,0)"
|
|
||||||
}*/
|
|
||||||
},
|
|
||||||
category: "special",
|
|
||||||
state: "solid",
|
|
||||||
density: 1,
|
|
||||||
conduct: elements.water.conduct + 0.1,
|
|
||||||
},
|
|
||||||
|
|
||||||
elements.replacer_bacteria = {
|
|
||||||
color: ["#fcbbc0", "#f28089", "#f04f5c", "#f04f5c"],
|
|
||||||
behavior: behaviors.WALL,
|
|
||||||
tick: function(pixel) {
|
|
||||||
neighbors = [[-1,0],[0,-1],[1,0],[0,1]]
|
|
||||||
if(pixel.charge) { //when shocked
|
|
||||||
if(!outOfBounds(pixel.x,pixel.y+1) && !isEmpty(pixel.x,pixel.y+1) && !outOfBounds(pixel.x,pixel.y-1) && !isEmpty(pixel.x,pixel.y-1)) { //check if pixels exists above and below to store the elements of
|
|
||||||
if(!pixel.active && !pixel.target && !pixel.replacement && pixelMap[pixel.x][pixel.y+1].element != pixel.element) { //exclude self and only fire once
|
|
||||||
pixel.target = pixelMap[pixel.x][pixel.y+1].element
|
|
||||||
pixel.replacement = pixelMap[pixel.x][pixel.y-1].element
|
|
||||||
pixel.active = true
|
|
||||||
} else if(pixel.active || pixel.target || pixel.replacement || pixelMap[pixel.x][pixel.y+1].element == pixel.element) {
|
|
||||||
pixel.active = pixel.active
|
|
||||||
pixel.target = pixel.target
|
|
||||||
pixel.replacement = pixel.replacement
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(pixel.active) {
|
|
||||||
if(pixel.target && pixel.replacement) { //safety
|
|
||||||
for(i = 0; i < neighbors.length; i++) { //iterate through neighbor spots
|
|
||||||
if(!isEmpty(pixel.x+neighbors[i][0],pixel.y+neighbors[i][1],true)) { //check for neighbors
|
|
||||||
if(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].element == pixel.target) { //if neighbor element is the target
|
|
||||||
changePixel(pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]],pixel.element) //change neighbors to itself
|
|
||||||
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].target = pixel.target //set new bacteria target
|
|
||||||
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].replacement = pixel.replacement //set new bacteria replacement
|
|
||||||
pixelMap[pixel.x+neighbors[i][0]][pixel.y+neighbors[i][1]].active = true //activate new bacteria
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!isEmpty(pixel.x,pixel.y)) { //check if own position is empty
|
|
||||||
if(pixelMap[pixel.x][pixel.y].element == pixel.element) { //check if own position is still bacteria
|
|
||||||
changePixel(pixelMap[pixel.x][pixel.y],pixel.replacement)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*if(pixel.active && pixel.target && pixel.replacement) { //debug
|
|
||||||
pixel.color = "rgb(0,255,0)"
|
|
||||||
}*/
|
|
||||||
},
|
|
||||||
category: "special",
|
|
||||||
state: "solid",
|
|
||||||
density: 1,
|
|
||||||
conduct: elements.water.conduct + 0.1,
|
|
||||||
},
|
|
||||||
|
|
||||||
elements.test337 = {
|
|
||||||
color: "#7f7f7f",
|
|
||||||
conduct: 1,
|
|
||||||
viscosity: 0.000001,
|
|
||||||
colorOn: ["#cf7fff"],
|
|
||||||
density: 2000,
|
|
||||||
behavior: behaviors.POWDER,
|
|
||||||
state: "solid",
|
|
||||||
category: "solids",
|
|
||||||
tick: function(pixel) {
|
|
||||||
for(i = 0; i < 3; i++) {
|
|
||||||
var moveSpotsA = [[0,1]]
|
|
||||||
var moveSpotsB = [[-1,1],[1,1]]
|
|
||||||
var msaChoice = randomArrayChoice(moveSpotsA)
|
|
||||||
var msbChoice = randomArrayChoice(moveSpotsB)
|
|
||||||
if(isEmpty(msaChoice[0],pixel.y+msaChoice[1],true)) {
|
|
||||||
if(!tryMove(pixel,pixel.x+msaChoice[0],pixel.y+msaChoice[1])) {
|
|
||||||
tryMove(pixel,pixel.x+msbChoice[0],pixel.y+msbChoice[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pixelTick(pixel)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
elements.sencc = { //same element neighbor count check
|
elements.sencc = { //same element neighbor count check
|
||||||
color: "#000000",
|
color: "#000000",
|
||||||
uwu: 0,
|
uwu: 0,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
elements.replace_all = {
|
||||||
|
color: "#ef7f3f",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tick: function(pixel) {
|
||||||
|
if(pixel.charge) { //when shocked
|
||||||
|
//console.log("ouch")
|
||||||
|
if(!outOfBounds(pixel.x,pixel.y+1) && !isEmpty(pixel.x,pixel.y+1) && !outOfBounds(pixel.x,pixel.y-1) && !isEmpty(pixel.x,pixel.y-1)) { //check if pixels exists above and below to store the elements of
|
||||||
|
//console.log("elems stored")
|
||||||
|
if(pixelMap[pixel.x][pixel.y-1].element != pixel.element) { //exclude self and only fire once
|
||||||
|
//console.log("self excluded from replacement")
|
||||||
|
pixel.target = pixelMap[pixel.x][pixel.y+1].element
|
||||||
|
//console.log("target set to " + pixel.target)
|
||||||
|
pixel.replacement = pixelMap[pixel.x][pixel.y-1].element
|
||||||
|
//console.log("replacement set to " + pixel.replacement)
|
||||||
|
pixel.active = true
|
||||||
|
//console.log("replacer activated")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pixel.active) {
|
||||||
|
//console.log("is this on now?")
|
||||||
|
if(pixel.target && pixel.replacement) { //safety
|
||||||
|
//console.log("target and replacement exist, iterating...")
|
||||||
|
for (var i = 0; i < width; i++) {
|
||||||
|
for (var j = 0; j < height; j++) {
|
||||||
|
if(isEmpty(i,j,true) == false) {
|
||||||
|
//console.log("pixel at (" + i + "," + j + ") exists")
|
||||||
|
if(pixelMap[i][j].element == pixel.target) {
|
||||||
|
//console.log(pixel.target + " detected, replacing")
|
||||||
|
if(isEmpty(i,j,true) == false) { changePixel(pixelMap[i][j],pixel.replacement) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pixel.active = false //de-activate
|
||||||
|
if(pixel.charge) { delete pixel.charge}
|
||||||
|
if(pixel.chargeCD) { delete pixel.chargeCD}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
|
state: "solid",
|
||||||
|
density: 1,
|
||||||
|
conduct: elements.water.conduct + 0.1,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
elements.solid_rock = {
|
||||||
|
color: ["#808080","#4f4f4f","#949494"],
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
reactions: {
|
||||||
|
"water": {elem1: "wet_sand", chance: 0.00035},
|
||||||
|
"salt_water": {elem1: "wet_sand", chance: 0.0005},
|
||||||
|
"sugar_water": {elem1: "wet_sand", chance: 0.0004},
|
||||||
|
"seltzer": {elem1: "wet_sand", chance: 0.0004},
|
||||||
|
"dirty_water": {elem1: "wet_sand", chance: 0.0004},
|
||||||
|
"soda": {elem1: "wet_sand", chance: 0.0004},
|
||||||
|
"lichen": {elem1: "dirt", chance: 0.0025},
|
||||||
|
"grape": {elem2: "juice", chance: 0.1, color2: "#291824"},
|
||||||
|
"root": {elem1: "sand", chance: 0.0004},
|
||||||
|
"wheat": {elem2: "flour"},
|
||||||
|
"primordial_soup": {elem1: "wet_sand", chance: 0.001}
|
||||||
|
},
|
||||||
|
tempHigh: 950,
|
||||||
|
stateHigh: "magma",
|
||||||
|
category: "land",
|
||||||
|
state: "solid",
|
||||||
|
density: 2600,
|
||||||
|
hardness: 0.55,
|
||||||
|
breakInto: "rock",
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue