Merge branch 'main' of https://github.com/slweeb/sandboxels
This commit is contained in:
commit
ff17ed8578
|
|
@ -1,3 +1,10 @@
|
|||
currentColor = "#80ffff";
|
||||
function deletecoconut() {
|
||||
throw "The game crashed, because you deleted the coconut."
|
||||
}
|
||||
let rPOWDER = behaviors.POWDER
|
||||
console.log("Welcome to the console.");
|
||||
console.log(rPOWDER);
|
||||
elements.test = {
|
||||
color: "#ff0000",
|
||||
behavior: behaviors.POWDER,
|
||||
|
|
@ -481,7 +488,7 @@ temp: -150
|
|||
elements.mythril = {
|
||||
color: "#51bd89",
|
||||
behavior: behaviors.WALL,
|
||||
category: "solids",
|
||||
category: "mythical",
|
||||
density: 7750,
|
||||
state: "solid",
|
||||
tempHigh: 2500,
|
||||
|
|
@ -491,12 +498,12 @@ conduct: 0.93
|
|||
elements.molten_mythril = {
|
||||
color: ["#eda724", "#f0eabd"],
|
||||
behavior: behaviors.LIQUID,
|
||||
category: "liquids",
|
||||
category: "mythical",
|
||||
reactions: {
|
||||
"molten_mithril": { "elem1": "molten_mithril_mythril_alloy", "elem2":null },
|
||||
},
|
||||
density: 6855,
|
||||
state: "liquid",
|
||||
state: "mythical",
|
||||
tempLow: 2500,
|
||||
stateLow: "mythril",
|
||||
temp: 3000,
|
||||
|
|
@ -529,7 +536,7 @@ elements.molten_mithril_mythril_alloy = {
|
|||
name: "Molten Mithril/Mythril Alloy",
|
||||
color: "#ebd8a4",
|
||||
behavior: behaviors.LIQUID,
|
||||
category: "liquids",
|
||||
category: "mythical",
|
||||
density: 3922.5,
|
||||
state: "liquid",
|
||||
tempLow: 1975,
|
||||
|
|
@ -542,7 +549,7 @@ conduct: 0.965,
|
|||
name: "Mithril/Mythril Alloy",
|
||||
color: "#bfd8d9",
|
||||
behavior: behaviors.WALL,
|
||||
category: "solids",
|
||||
category: "mythical",
|
||||
density: 4425,
|
||||
state: "solid",
|
||||
tempHigh: 1975,
|
||||
|
|
@ -1134,6 +1141,82 @@ tempHigh: 1131,
|
|||
stateHigh: "molten_uranium238",
|
||||
density: 20,
|
||||
};
|
||||
elements.butter = {
|
||||
color: "#fcf1b1",
|
||||
category: "food",
|
||||
state: "solid",
|
||||
behavior: ["XX|XX|XX","M2%5|XX|M2%5","M2|M1|M2"],
|
||||
tempHigh: 38,
|
||||
stateHigh: "molten_butter",
|
||||
density: 911,
|
||||
};
|
||||
elements.molten_butter = {
|
||||
color: "#f7e997",
|
||||
category: "food",
|
||||
state: "liquid",
|
||||
behavior: behaviors.LIQUID,
|
||||
tempLow: 38,
|
||||
stateLow: "butter",
|
||||
density: 910,
|
||||
};
|
||||
behaviors.GROW_PETALS = ["XX|CR:petal%5|XX", "CR:petal%5|XX|CR:petal%5", "XX|CR:petal%5|XX"]
|
||||
elements.cactus_seed = {
|
||||
color: "#2e5931",
|
||||
category: "life",
|
||||
state: "solid",
|
||||
behavior: ["XX|M2%5|XX","CR:cactus%0.5|CH:cactus%0.01|CR:cactus%0.5","XX|M1,L2:cactus|XX"],
|
||||
density: 1000,
|
||||
tempHigh: 200,
|
||||
stateHigh: ["steam", "nut"]
|
||||
};
|
||||
elements.sugar_cactus_seed = {
|
||||
color: "#db9ed4",
|
||||
category: "mythical",
|
||||
state: "solid",
|
||||
behavior: ["XX|M2%5|XX","CR:sugar_cactus%0.5|CH:sugar_cactus%0.01|CR:sugar_cactus%0.5","XX|M1,L2:sugar_cactus|XX"],
|
||||
density: 1000,
|
||||
stateHigh: ["caramel", "water"],
|
||||
tempHigh: 150,
|
||||
};
|
||||
elements.cactus = {
|
||||
color: "#2e5931",
|
||||
category: "life",
|
||||
state: "solid",
|
||||
behavior: ["XX|XX|XX", "XX|CH:flowering_cactus%0.1|XX", "XX|XX|XX"],
|
||||
tempHigh: 200,
|
||||
stateHigh: ["steam", "wood"]
|
||||
};
|
||||
elements.sugar_cactus = {
|
||||
color: "#db9ed4",
|
||||
category: "mythical",
|
||||
state: "solid",
|
||||
behavior: ["XX|XX|XX", "XX|CH:flowering_sugar_cactus%0.1|XX", "XX|XX|XX"],
|
||||
stateHigh: ["caramel", "water"],
|
||||
tempHigh: 150,
|
||||
};
|
||||
elements.flowering_cactus = {
|
||||
color: "#2f5a32",
|
||||
category: "life",
|
||||
state: "solid",
|
||||
behavior: behaviors.GROW_PETALS,
|
||||
tempHigh: 200,
|
||||
stateHigh: ["steam", "wood"]
|
||||
};
|
||||
elements.flowering_sugar_cactus = {
|
||||
color: "#dc9fd5",
|
||||
category: "mythical",
|
||||
state: "solid",
|
||||
behavior: behaviors.GROW_PETALS,
|
||||
tempHigh: 150,
|
||||
stateHigh: ["caramel", "water"],
|
||||
};
|
||||
elements.nut = {
|
||||
color: "#807353",
|
||||
category: "food",
|
||||
state: "solid",
|
||||
behavior: behaviors.POWDER,
|
||||
density: 500,
|
||||
};
|
||||
/* Unfinished:
|
||||
magnesium
|
||||
hematite mixture
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
incrementt = 0;
|
||||
|
||||
interval = setInterval( increment, 500/30);
|
||||
|
||||
function increment(){
|
||||
incrementt = incrementt % (Math.PI*8.8) + (Math.PI/30);
|
||||
}
|
||||
|
||||
function drawPixels(forceTick=false) {
|
||||
// newCurrentPixels = shuffled currentPixels
|
||||
var newCurrentPixels = currentPixels.slice();
|
||||
var pixelsFirst = [];
|
||||
var pixelsLast = [];
|
||||
if (!paused || forceTick) {
|
||||
shuffleArray(newCurrentPixels);
|
||||
}
|
||||
/*{newCurrentPixels.sort(function(p) { // shuffle the pixels but keep elements[p.element].isGas last
|
||||
return 0.5 - Math.random();
|
||||
})} // shuffle the pixels if not paused*/
|
||||
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 (!paused || forceTick) {
|
||||
if (elements[pixel.element].tick) { // Run tick function if it exists
|
||||
elements[pixel.element].tick(pixel);
|
||||
}
|
||||
if (pixel.del) {continue}
|
||||
if (elements[pixel.element].behavior) { // Parse behavior if it exists
|
||||
pixelTick(pixel);
|
||||
}
|
||||
};
|
||||
if (elements[pixel.element].isGas) {
|
||||
pixelsLast.push(pixel);
|
||||
}
|
||||
else {
|
||||
pixelsFirst.push(pixel);
|
||||
}
|
||||
}
|
||||
adjacentCoords = [
|
||||
[0,1],
|
||||
[0,-1],
|
||||
[1,0],
|
||||
[-1,0]
|
||||
];
|
||||
biCoords = [
|
||||
[0,1],
|
||||
[1,0]
|
||||
];
|
||||
// Draw the current pixels
|
||||
var canvas = document.getElementById("game");
|
||||
var ctx = canvas.getContext("2d");
|
||||
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 (view===null || view===3) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else if (view === 2) { // thermal view
|
||||
// set the color to pixel.temp, from hottest at 0 hue to coldest 225 hue, with the minimum being -273, max being 6000
|
||||
var temp = pixel.temp;
|
||||
if (temp < -273) {temp = -273}
|
||||
if (temp > 6000) {temp = 6000}
|
||||
var hue = 225 - (temp/6000)*225;
|
||||
if (hue < 0) {hue = 0}
|
||||
if (hue > 225) {hue = 225}
|
||||
ctx.fillStyle = "hsl("+hue+",100%,50%)";
|
||||
}
|
||||
else if (view === 4) { // smooth view, average of surrounding pixels
|
||||
var colorlist = [];
|
||||
// check adjacent coords on the pixelMap, add the color to the list if the pixel is not empty and the color indexOf "rgb" is not -1
|
||||
for (var j = 0; j < biCoords.length; j++) {
|
||||
var x = pixel.x + biCoords[j][0];
|
||||
var y = pixel.y + biCoords[j][1];
|
||||
if (isEmpty(x,y,true) || elements[pixelMap[x][y].element].state !== elements[pixel.element].state) {continue}
|
||||
var color = pixelMap[x][y].color;
|
||||
if (color.indexOf("rgb") !== -1) {
|
||||
colorlist.push(color.match(/\d+/g));
|
||||
}
|
||||
}
|
||||
if (colorlist.length === 0) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else {
|
||||
ctx.fillStyle = averageRGB(colorlist);
|
||||
}
|
||||
}
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.globalAlpha = 0.66;
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)), (pixel.y+0.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)), pixelSize*1.5, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
else { // draw the pixel (default)
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)), (pixel.y+0.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)), pixelSize/2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
}
|
||||
if (pixel.charge && view !== 2) { // Yellow glow on charge
|
||||
if (!elements[pixel.element].colorOn) {
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)), (pixel.y+0.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)), pixelSize*1.5, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
} else {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)), (pixel.y+0.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)), pixelSize/2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!paused) || forceTick) {pixelTicks++};
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
incrementt = 0;
|
||||
|
||||
interval = setInterval( increment, 500/30);
|
||||
|
||||
function increment(){
|
||||
incrementt = incrementt % (Math.PI*8.8) + (Math.PI/30);
|
||||
}
|
||||
|
||||
function drawPixels(forceTick=false) {
|
||||
// newCurrentPixels = shuffled currentPixels
|
||||
var newCurrentPixels = currentPixels.slice();
|
||||
var pixelsFirst = [];
|
||||
var pixelsLast = [];
|
||||
if (!paused || forceTick) {
|
||||
shuffleArray(newCurrentPixels);
|
||||
}
|
||||
/*{newCurrentPixels.sort(function(p) { // shuffle the pixels but keep elements[p.element].isGas last
|
||||
return 0.5 - Math.random();
|
||||
})} // shuffle the pixels if not paused*/
|
||||
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 (!paused || forceTick) {
|
||||
if (elements[pixel.element].tick) { // Run tick function if it exists
|
||||
elements[pixel.element].tick(pixel);
|
||||
}
|
||||
if (pixel.del) {continue}
|
||||
if (elements[pixel.element].behavior) { // Parse behavior if it exists
|
||||
pixelTick(pixel);
|
||||
}
|
||||
};
|
||||
if (elements[pixel.element].isGas) {
|
||||
pixelsLast.push(pixel);
|
||||
}
|
||||
else {
|
||||
pixelsFirst.push(pixel);
|
||||
}
|
||||
}
|
||||
adjacentCoords = [
|
||||
[0,1],
|
||||
[0,-1],
|
||||
[1,0],
|
||||
[-1,0]
|
||||
];
|
||||
biCoords = [
|
||||
[0,1],
|
||||
[1,0]
|
||||
];
|
||||
// Draw the current pixels
|
||||
var canvas = document.getElementById("game");
|
||||
var ctx = canvas.getContext("2d");
|
||||
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 (view===null || view===3) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else if (view === 2) { // thermal view
|
||||
// set the color to pixel.temp, from hottest at 0 hue to coldest 225 hue, with the minimum being -273, max being 6000
|
||||
var temp = pixel.temp;
|
||||
if (temp < -273) {temp = -273}
|
||||
if (temp > 6000) {temp = 6000}
|
||||
var hue = 225 - (temp/6000)*225;
|
||||
if (hue < 0) {hue = 0}
|
||||
if (hue > 225) {hue = 225}
|
||||
ctx.fillStyle = "hsl("+hue+",100%,50%)";
|
||||
}
|
||||
else if (view === 4) { // smooth view, average of surrounding pixels
|
||||
var colorlist = [];
|
||||
// check adjacent coords on the pixelMap, add the color to the list if the pixel is not empty and the color indexOf "rgb" is not -1
|
||||
for (var j = 0; j < biCoords.length; j++) {
|
||||
var x = pixel.x + biCoords[j][0];
|
||||
var y = pixel.y + biCoords[j][1];
|
||||
if (isEmpty(x,y,true) || elements[pixelMap[x][y].element].state !== elements[pixel.element].state) {continue}
|
||||
var color = pixelMap[x][y].color;
|
||||
if (color.indexOf("rgb") !== -1) {
|
||||
colorlist.push(color.match(/\d+/g));
|
||||
}
|
||||
}
|
||||
if (colorlist.length === 0) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else {
|
||||
ctx.fillStyle = averageRGB(colorlist);
|
||||
}
|
||||
}
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.globalAlpha = 0.66;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo((pixel.x-0.75)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y-1)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+1.75)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
else { // draw the pixel (default)
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pixel.x*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+1)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.fill();
|
||||
}
|
||||
if (pixel.charge && view !== 2) { // Yellow glow on charge
|
||||
if (!elements[pixel.element].colorOn) {
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo((pixel.x-0.75)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y-1)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+1.75)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1.5)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.fill();
|
||||
} else {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pixel.x*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.lineTo((pixel.x+1)*pixelSize+(18*Math.sin((pixel.y+incrementt)/4.4)),(pixel.y+1)*pixelSize+(18*Math.sin((pixel.x+incrementt)/4.4)));
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!paused) || forceTick) {pixelTicks++};
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
elements.alcohol.name = "ethanol"
|
||||
elements.alcohol.viscosity = elements.alcohol.viscosity * (1.074/1.0016)
|
||||
|
||||
elements.methanol = {
|
||||
color: "#c9c5b1",
|
||||
behavior: behaviors.LIQUID,
|
||||
reactions: {
|
||||
"virus": { "elem2":null },
|
||||
"plague": { "elem2":null },
|
||||
"head": { "elem2":"rotten_meat", "chance": 0.8 },
|
||||
"body": { "elem2":"rotten_meat", "chance": 0.8 },
|
||||
},
|
||||
viscosity: 1*(0.553/1.0016),
|
||||
tempHigh: 64.7,
|
||||
stateHigh: ["steam","carbon_dioxide"], //todo: alcohols' phase transitions
|
||||
burn: 100,
|
||||
burnTime: 2,
|
||||
fireColor: "#b2c5d1",
|
||||
category: "liquids",
|
||||
state: "liquid",
|
||||
density: 792,
|
||||
stain: -0.25,
|
||||
}
|
||||
|
||||
|
||||
elements.methanol = {
|
||||
color: "#c9c5b1",
|
||||
behavior: behaviors.LIQUID,
|
||||
reactions: {
|
||||
"virus": { "elem2":null },
|
||||
"plague": { "elem2":null },
|
||||
"head": { "elem2":"rotten_meat", "chance": 0.8 },
|
||||
"body": { "elem2":"rotten_meat", "chance": 0.8 },
|
||||
},
|
||||
viscosity: 1*(0.553/1.0016),
|
||||
tempHigh: 64.7,
|
||||
stateHigh: ["steam","carbon_dioxide"], //todo: alcohols' phase transitions
|
||||
burn: 100,
|
||||
burnTime: 2,
|
||||
fireColor: "#b2c5d1",
|
||||
category: "liquids",
|
||||
state: "liquid",
|
||||
density: 792,
|
||||
stain: -0.25,
|
||||
}
|
||||
|
||||
elements.propanol = {
|
||||
color: "#c9c5b1",
|
||||
behavior: behaviors.LIQUID,
|
||||
reactions: {
|
||||
"virus": { "elem2":null },
|
||||
"plague": { "elem2":null },
|
||||
},
|
||||
viscosity: 1*(1.945/1.0016),
|
||||
tempHigh: 97,
|
||||
stateHigh: ["steam","carbon_dioxide"],
|
||||
burn: 100,
|
||||
burnTime: 3,
|
||||
fireColor: "#ced8de",
|
||||
category: "liquids",
|
||||
state: "liquid",
|
||||
density: 803,
|
||||
stain: -0.25,
|
||||
}
|
||||
|
||||
elements.isopropanol = {
|
||||
color: "#c9c5b1",
|
||||
behavior: behaviors.LIQUID,
|
||||
reactions: {
|
||||
"virus": { "elem2":null },
|
||||
"plague": { "elem2":null },
|
||||
},
|
||||
viscosity: 1*(2.052/1.0016),
|
||||
tempHigh: 82.5,
|
||||
stateHigh: ["steam","carbon_dioxide"],
|
||||
burn: 100,
|
||||
burnTime: 3,
|
||||
fireColor: "#d1c958",
|
||||
category: "liquids",
|
||||
state: "liquid",
|
||||
density: 786,
|
||||
stain: -0.25,
|
||||
}
|
||||
|
||||
elements.butanol = {
|
||||
color: "#c9c5b1",
|
||||
behavior: behaviors.LIQUID,
|
||||
reactions: {
|
||||
"virus": { "elem2":null },
|
||||
"plague": { "elem2":null },
|
||||
},
|
||||
viscosity: 1*(2.53/1.0016),
|
||||
tempHigh: 118,
|
||||
stateHigh: ["steam","carbon_dioxide"],
|
||||
burn: 100,
|
||||
burnTime: 3,
|
||||
category: "liquids",
|
||||
state: "liquid",
|
||||
density: 810,
|
||||
stain: -0.25,
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
function drawPixels(forceTick=false) {
|
||||
// newCurrentPixels = shuffled currentPixels
|
||||
var newCurrentPixels = currentPixels.slice();
|
||||
var pixelsFirst = [];
|
||||
var pixelsLast = [];
|
||||
if (!paused || forceTick) {
|
||||
shuffleArray(newCurrentPixels);
|
||||
}
|
||||
/*{newCurrentPixels.sort(function(p) { // shuffle the pixels but keep elements[p.element].isGas last
|
||||
return 0.5 - Math.random();
|
||||
})} // shuffle the pixels if not paused*/
|
||||
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 (!paused || forceTick) {
|
||||
if (elements[pixel.element].tick) { // Run tick function if it exists
|
||||
elements[pixel.element].tick(pixel);
|
||||
}
|
||||
if (pixel.del) {continue}
|
||||
if (elements[pixel.element].behavior) { // Parse behavior if it exists
|
||||
pixelTick(pixel);
|
||||
}
|
||||
};
|
||||
if (elements[pixel.element].isGas) {
|
||||
pixelsLast.push(pixel);
|
||||
}
|
||||
else {
|
||||
pixelsFirst.push(pixel);
|
||||
}
|
||||
}
|
||||
adjacentCoords = [
|
||||
[0,1],
|
||||
[0,-1],
|
||||
[1,0],
|
||||
[-1,0]
|
||||
];
|
||||
biCoords = [
|
||||
[0,1],
|
||||
[1,0]
|
||||
];
|
||||
// Draw the current pixels
|
||||
var canvas = document.getElementById("game");
|
||||
var ctx = canvas.getContext("2d");
|
||||
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 (view===null || view===3) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else if (view === 2) { // thermal view
|
||||
// set the color to pixel.temp, from hottest at 0 hue to coldest 225 hue, with the minimum being -273, max being 6000
|
||||
var temp = pixel.temp;
|
||||
if (temp < -273) {temp = -273}
|
||||
if (temp > 6000) {temp = 6000}
|
||||
var hue = 225 - (temp/6000)*225;
|
||||
if (hue < 0) {hue = 0}
|
||||
if (hue > 225) {hue = 225}
|
||||
ctx.fillStyle = "hsl("+hue+",100%,50%)";
|
||||
}
|
||||
else if (view === 4) { // smooth view, average of surrounding pixels
|
||||
var colorlist = [];
|
||||
// check adjacent coords on the pixelMap, add the color to the list if the pixel is not empty and the color indexOf "rgb" is not -1
|
||||
for (var j = 0; j < biCoords.length; j++) {
|
||||
var x = pixel.x + biCoords[j][0];
|
||||
var y = pixel.y + biCoords[j][1];
|
||||
if (isEmpty(x,y,true) || elements[pixelMap[x][y].element].state !== elements[pixel.element].state) {continue}
|
||||
var color = pixelMap[x][y].color;
|
||||
if (color.indexOf("rgb") !== -1) {
|
||||
colorlist.push(color.match(/\d+/g));
|
||||
}
|
||||
}
|
||||
if (colorlist.length === 0) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else {
|
||||
ctx.fillStyle = averageRGB(colorlist);
|
||||
}
|
||||
}
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.globalAlpha = 0.66;
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize, (pixel.y+0.5)*pixelSize, pixelSize*1.5, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
else { // draw the pixel (default)
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize, (pixel.y+0.5)*pixelSize, pixelSize/2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
}
|
||||
if (pixel.charge && view !== 2) { // Yellow glow on charge
|
||||
if (!elements[pixel.element].colorOn) {
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize, (pixel.y+0.5)*pixelSize, pixelSize*1.5, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
} else {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.arc((pixel.x+0.5)*pixelSize, (pixel.y+0.5)*pixelSize, pixelSize/2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!paused) || forceTick) {pixelTicks++};
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ elements.crimgravel = { //break from canon for crimstone breakInto
|
|||
state: "solid",
|
||||
density: 1680,
|
||||
hardness: 0.2,
|
||||
}
|
||||
},
|
||||
|
||||
elements.crimwater = { //you shouldn't be able to purify ice by melting it
|
||||
color: "#e45c7c",
|
||||
|
|
@ -275,6 +275,8 @@ elements.crimwater = { //you shouldn't be able to purify ice by melting it
|
|||
},
|
||||
tempLow: 0,
|
||||
stateLow: "red_ice",
|
||||
tempHigh: 100,
|
||||
stateHigh: "steam",
|
||||
viscosity: 1,
|
||||
category: "liquids",
|
||||
reactions: {
|
||||
|
|
|
|||
|
|
@ -178,6 +178,14 @@ elements.turquoise_dust = {
|
|||
density: 1600,
|
||||
}
|
||||
|
||||
if(!settings) {
|
||||
settings = {}
|
||||
}
|
||||
|
||||
if(!settings.bg) {
|
||||
settings.bg = "#000000"
|
||||
}
|
||||
|
||||
elements.black_damp = {
|
||||
color: "#000000",
|
||||
behavior: [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
elements.granite = {
|
||||
color: ["#F3C3AD", "#F0AB75", "#DDA888", "#BD927E", "#998473", "#5C5E53", "#BD8366"],
|
||||
behavior: behaviors.WALL,
|
||||
category: "land",
|
||||
tempHigh: 1215,
|
||||
density: 2691,
|
||||
hardness: 0.75,
|
||||
breakInto: "granite_gravel",
|
||||
};
|
||||
|
||||
elements.granite_gravel = {
|
||||
color: ["#E3B39D", "#E09B65", "#CD9878", "#AD826E", "#897463", "#4C4E43", "#AD7356", "#F3C3AD", "#F0AB75", "#DDA888", "#BD927E", "#998473", "#5C5E53", "#BD8366", "#FFD3BD", "#FFBB85", "#EDB898", "#CDA28E", "#A99483", "#6C6E63", "#CD9376"],
|
||||
behavior: behaviors.POWDER,
|
||||
category: "land",
|
||||
tempHigh: 1215,
|
||||
stateHigh: "molten_granite",
|
||||
density: 1320,
|
||||
};
|
||||
|
||||
elements.molten_granite = {
|
||||
"reactions": {
|
||||
"magma": { "elem1": "molten_andesite", "elem2": "molten_andesite" },
|
||||
"ash": { "elem1": null, "elem2": "molten_slag" },
|
||||
"dust": { "elem1": null, "elem2": "molten_slag" },
|
||||
},
|
||||
"name": "granitic_magma",
|
||||
"color": ["#FFF457", "#FF9257", "#FF9200", "#FFD63B", "#FFAB3B", "#FF8000", "#FFD244", "#FFA844", "#FF7E00", "#FFB73F", "#FF923F", "#FF6E00", "#FFA53A", "#FF843A", "#FF6300", "#B8762A", "#B85E2A", "#B84700", "#FFA433", "#FF8333", "#FF6200"],
|
||||
"behavior": behaviors.MOLTEN,
|
||||
"temp": 1215,
|
||||
"tempLow": 1115,
|
||||
"stateLow": "granite",
|
||||
"viscosity": 10000,
|
||||
"hidden": true,
|
||||
"state": "liquid",
|
||||
"category": "molten",
|
||||
"density": 2421.9
|
||||
};
|
||||
|
||||
elements.andesite = {
|
||||
color: ["#6F7575", "#C5C9CB", "#818787", "#797F7F", "#B5B9BA", "#6D7371", "#909696"],
|
||||
behavior: behaviors.WALL,
|
||||
category: "land",
|
||||
tempHigh: 1215,
|
||||
density: 2474, //it varies very widely, so I made the last 2 digits up.
|
||||
hardness: 0.75,
|
||||
breakInto: "andesite_gravel",
|
||||
};
|
||||
|
||||
elements.andesite_gravel = {
|
||||
color: ['#5f6565', '#b5b9bb', '#717777', '#696f6f', '#a5a9aa', '#5d6361', '#808686', '#6f7575', '#c5c9cb', '#818787', '#797f7f', '#b5b9ba', '#6d7371', '#909696', '#7f8585', '#d5d9db', '#919797', '#898f8f', '#c5c9ca', '#7d8381', '#a0a6a6'],
|
||||
behavior: behaviors.POWDER,
|
||||
category: "land",
|
||||
tempHigh: 1260,
|
||||
stateHigh: "molten_andesite",
|
||||
density: 1214, //approximated from granite values
|
||||
};
|
||||
|
||||
elements.molten_andesite = {
|
||||
"reactions": {
|
||||
"ash": { "elem1": null, "elem2": "molten_slag" },
|
||||
"dust": { "elem1": null, "elem2": "molten_slag" },
|
||||
},
|
||||
"name": "andesitic_magma",
|
||||
"color": ["#de923b", "#de753b", "#de5800", "#fffb66", "#ffc966", "#ff9700", "#ffa944", "#ff8744", "#ff6500", "#f29f40", "#f27f40", "#f25f00", "#ffe75d", "#ffb95d", "#ff8b00", "#da9039", "#da7339", "#da5600", "#ffbc4b", "#ff964b", "#ff7100"],
|
||||
"behavior": behaviors.MOLTEN,
|
||||
"temp": 1215,
|
||||
"tempLow": 1115,
|
||||
"stateLow": "andesite",
|
||||
"viscosity": 10000,
|
||||
"hidden": true,
|
||||
"state": "liquid",
|
||||
"category": "molten",
|
||||
"density": 2226.6
|
||||
}
|
||||
|
||||
elements.magma.name = "basaltic_magma" //because it cools into basalt
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
for (var i = 3; i <= 15; i++) {
|
||||
elements[`cluster_bomb_${i}`] = {
|
||||
name: `${i}- cluster bomb`,
|
||||
color: "#7d776d",
|
||||
behavior: [
|
||||
`XX|EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb_${i-1}|XX`,
|
||||
"XX|XX|XX",
|
||||
`M2|M1 AND EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb_${i-1}|M2`,
|
||||
],
|
||||
category: "weapons",
|
||||
state: "solid",
|
||||
density: 1300,
|
||||
tempHigh: 1455.5,
|
||||
stateHigh: "molten_steel",
|
||||
excludeRandom: true,
|
||||
}
|
||||
}
|
||||
|
||||
elements.cluster_bomb_2 = {
|
||||
color: "#7d776d",
|
||||
behavior: [
|
||||
"XX|EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb|XX",
|
||||
"XX|XX|XX",
|
||||
"M2|M1 AND EX:10>smoke,smoke,smoke,smoke,smoke,cluster_bomb|M2",
|
||||
],
|
||||
category: "weapons",
|
||||
state: "solid",
|
||||
density: 1300,
|
||||
tempHigh: 1455.5,
|
||||
stateHigh: "molten_steel",
|
||||
excludeRandom: true,
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
elements.codeine_phosphate = {
|
||||
density: 1320, //pure codeine density, couldn't find phosphate's D
|
||||
tempHigh: 157.5,
|
||||
color: "#e0e0e0",
|
||||
behavior: behaviors.POWDER,
|
||||
category: "powders",
|
||||
state: "solid",
|
||||
reactions: {
|
||||
"promethazine_hydrochloride": { elem1: null, elem2: "cp_ph_mixture" },
|
||||
"wet_promethazine_hydrochloride": { elem1: null, elem2: "cp_ph_mixture" },
|
||||
},
|
||||
}
|
||||
|
||||
elements.promethazine_hydrochloride = {
|
||||
density: 1100, //see above density
|
||||
tempHigh: 223, //decomps?
|
||||
color: "#e0e7e0",
|
||||
behavior: behaviors.POWDER,
|
||||
category: "powders",
|
||||
state: "solid",
|
||||
reactions: {
|
||||
"water": { elem1: null, elem2: "wet_promethazine_hydrochloride" },
|
||||
"steam": { elem1: null, elem2: "wet_promethazine_hydrochloride" },
|
||||
},
|
||||
}
|
||||
|
||||
elements.wet_promethazine_hydrochloride = {
|
||||
density: 1600, //guess
|
||||
tick: function(pixel) { //thermal splitting function
|
||||
var neighbors = [ [-1,0], [1,0], [0,-1], [0,1] ]
|
||||
var randomNeighbor = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var rnx = randomNeighbor[0]
|
||||
var rny = randomNeighbor[1]
|
||||
if(pixel.temp >= 100) {
|
||||
if(isEmpty(pixel.x+rnx, pixel.y+rny, false)) {
|
||||
createPixel("steam", pixel.x+rnx, pixel.y+rny)
|
||||
changePixel(pixel, "promethazine_hydrochloride")
|
||||
}
|
||||
}
|
||||
},
|
||||
color: "#b0b7e0",
|
||||
behavior: behaviors.POWDER,
|
||||
category: "powders",
|
||||
hidden: true,
|
||||
state: "solid",
|
||||
}
|
||||
|
||||
elements.cp_ph_mixture = {
|
||||
density: 1230, //using the 6.25/10 ratio from a CP/PH cough syrup from Morton Grove Pharmaceuticals, Inc. because it was in hot on r/lean (of course there’s a subreddit for that) | this is 6.25 mg pr.hy. and 10 mg co.ph. per 5mL dose, but ratios and reactions aren’t possible and implementing them to this accuracy would also require an accurate cough syrup density
|
||||
tick: function(pixel) { //thermal splitting function
|
||||
var neighbors = [ [-1,0], [1,0], [0,-1], [0,1] ]
|
||||
var randomNeighbor = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var rnx = randomNeighbor[0]
|
||||
var rny = randomNeighbor[1]
|
||||
if(pixel.temp >= 157.5) {
|
||||
if(isEmpty(pixel.x+rnx, pixel.y+rny, false)) {
|
||||
createPixel("molten_codeine_phosphate", pixel.x+rnx, pixel.y+rny)
|
||||
changePixel(pixel, "promethazine_hydrochloride")
|
||||
}
|
||||
}
|
||||
},
|
||||
color: "#e0e4e0",
|
||||
behavior: behaviors.POWDER,
|
||||
category: "powders",
|
||||
hidden: true,
|
||||
state: "solid",
|
||||
reactions: {
|
||||
"sugar_water": { elem1: "cough_syrup", elem2: "null" },
|
||||
},
|
||||
}
|
||||
|
||||
elements.cough_syrup = {
|
||||
density: 1200, //(made up)
|
||||
viscosity: 190, //https://www.dixonvalve.com/sites/default/files/product/files/brochures-literature/viscosity%20chart.pdf
|
||||
color: "#870870",
|
||||
behavior: behaviors.LIQUID,
|
||||
tick: function(pixel) { //thermal splitting function
|
||||
var neighbors = [ [-1,0], [1,0], [0,-1], [0,1] ]
|
||||
var randomNeighbor1 = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var randomNeighbor2 = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var rn1x = randomNeighbor1[0]
|
||||
var rn1y = randomNeighbor1[1]
|
||||
var rn2x = randomNeighbor2[0]
|
||||
var rn2y = randomNeighbor2[1]
|
||||
if(pixel.temp >= 100) {
|
||||
if(isEmpty(pixel.x+rn1x, pixel.y+rn1y, false) && isEmpty(pixel.x+rn2x, pixel.y+rn2y, false)) {
|
||||
createPixel("steam", pixel.x+rn1x, pixel.y+rn1y)
|
||||
createPixel("sugar", pixel.x+rn2x, pixel.y+rn2y)
|
||||
changePixel(pixel, "cp_ph_mixture")
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "liquids",
|
||||
hidden: true,
|
||||
state: "liquid",
|
||||
reactions: {
|
||||
"soda": { elem1: "lean", elem2: "lean" },
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
elements.lean = {
|
||||
density: (3*1037+1200)*4, //https://www.quora.com/How-do-I-make-a-cup-of-lean-And-how-many-millilteres-of-cough-syrup-usually-goes-into-a-standard-cup-of-lean ignoring ice and other things
|
||||
viscosity: 4, //made up
|
||||
color: "#a527db",
|
||||
behavior: [
|
||||
"XX|CR:foam%3|XX",
|
||||
"M2|XX|M2",
|
||||
"M1|M1|M1"
|
||||
],
|
||||
tick: function(pixel) { //thermal splitting function
|
||||
var neighbors = [ [-1,0], [1,0], [0,-1], [0,1] ]
|
||||
var randomNeighbor1 = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var randomNeighbor2 = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var randomNeighbor3 = neighbors[Math.floor(Math.random() * neighbors.length)]
|
||||
var rn1x = randomNeighbor1[0]
|
||||
var rn1y = randomNeighbor1[1]
|
||||
var rn2x = randomNeighbor2[0]
|
||||
var rn2y = randomNeighbor2[1]
|
||||
var rn3x = randomNeighbor3[0]
|
||||
var rn3y = randomNeighbor3[1]
|
||||
if(pixel.temp >= 100) {
|
||||
if(isEmpty(pixel.x+rn1x, pixel.y+rn1y, false) && isEmpty(pixel.x+rn2x, pixel.y+rn2y, false) && isEmpty(pixel.x+rn3x, pixel.y+rn3y, false)) {
|
||||
createPixel("steam", pixel.x+rn1x, pixel.y+rn1y)
|
||||
createPixel("sugar", pixel.x+rn2x, pixel.y+rn2y)
|
||||
createPixel("carbon_dioxide", pixel.x+rn3x, pixel.y+rn3y)
|
||||
changePixel(pixel, "cp_ph_mixture")
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "liquids",
|
||||
hidden: true, //for best results, play on unlock mode :eggTF:
|
||||
state: "liquid",
|
||||
stain: 0.03, //purple meme
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
//This script intentionally left blank.
|
||||
|
|
@ -0,0 +1 @@
|
|||
//This script intentionally left blank.
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
msColorArray = ["#a0a0a0", "#0000ff", "#008000", "#ff0000", "#000080", "#800000", "#008080", "#000000", "#808080"]
|
||||
|
||||
elements.msfield = {
|
||||
name: "minefield",
|
||||
color: "#c0c0c0",
|
||||
conduct: 1,
|
||||
insulate: true,
|
||||
properties: {
|
||||
uwu: 0,
|
||||
revealed: false,
|
||||
revealedAround: false,
|
||||
},
|
||||
tick: function(pixel) {
|
||||
if(typeof(pixel.revealed) === 'undefined') {
|
||||
pixel.revealed = false
|
||||
}
|
||||
if(typeof(pixel.uwu) === 'undefined') {
|
||||
pixel.uwu = 0
|
||||
}
|
||||
if(typeof(pixel.revealedAround) === 'undefined') {
|
||||
pixel.revealedAround = false
|
||||
}
|
||||
if(pixel.charge) {
|
||||
pixel.revealed = true
|
||||
delete pixel.charge
|
||||
if(pixel.chargeCD) {
|
||||
delete pixel.chargeCD
|
||||
}
|
||||
}
|
||||
if(pixel.revealed) {
|
||||
//count neighbors
|
||||
pixel.uwu = 0
|
||||
for (let i = -1; i < 2; i++) {
|
||||
for (let j = -1; j < 2; j++) {
|
||||
if (!isEmpty(pixel.x+j,pixel.y+i) && !outOfBounds(pixel.x+j,pixel.y+i)) {
|
||||
if (pixelMap[pixel.x+j][pixel.y+i].element == "msmine") {
|
||||
pixel.uwu += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(typeof(pixel.uwu) === 'number' && isFinite(pixel.uwu) && !isNaN(pixel.uwu)) {
|
||||
if(pixel.uwu >= 0 && pixel.uwu <= 8) {
|
||||
pixel.color = msColorArray[pixel.uwu]
|
||||
}
|
||||
} else {
|
||||
pixel.color = "#ff00ff"
|
||||
}
|
||||
} else {
|
||||
pixel.color = "#c0c0c0" //I feel bad suppressing the sand effect.
|
||||
}
|
||||
},
|
||||
category: "special",
|
||||
state: "solid",
|
||||
hidden: true,
|
||||
};
|
||||
|
||||
elements.msmine = {
|
||||
name: "minefield",
|
||||
color: "#c0c0c0",
|
||||
conduct: 1,
|
||||
insulate: true,
|
||||
properties: {
|
||||
uwu: 0,
|
||||
revealed: false,
|
||||
},
|
||||
tick: function(pixel) {
|
||||
if(pixel.charge) {
|
||||
pixel.revealed = true
|
||||
delete pixel.charge
|
||||
if(pixel.chargeCD) {
|
||||
delete pixel.chargeCD
|
||||
}
|
||||
}
|
||||
if(pixel.revealed) {
|
||||
pixel.color = ("#" + ((192 + Math.abs((pixelTicks * 4) % 64)).toString(16) + "c0c0").padStart(6, '0'));
|
||||
//oldFillStyle = ctx.fillStyle
|
||||
//ctx.fillStyle = "#ff0000";
|
||||
////ctx.fillRect(pixel.x*pixelSize, pixel.y*pixelSize, pixelSize/2, pixelSize);
|
||||
//ctx.fillRect(23*pixelSize, 23*pixelSize, pixelSize/2, pixelSize);
|
||||
//ctx.fillStyle = oldFillStyle;
|
||||
} else {
|
||||
pixel.color = "#c0c0c0"
|
||||
}
|
||||
},
|
||||
category: "special",
|
||||
state: "solid",
|
||||
hidden: true,
|
||||
};
|
||||
|
||||
elements.ms = { //minesweeper = {
|
||||
color: ["#c0c0c0", "#c0c0c0", "#ff0000", "#008000", "#ff0000", "#000080", "#800000", "#008080", "#000000", "#808080", "#808080"],
|
||||
behavior: [
|
||||
"XX|XX|XX",
|
||||
"XX|CH:msfield,msfield,msfield,msfield,msfield,msfield,msfield,msfield,msfield,msmine|XX",
|
||||
"XX|XX|XX"
|
||||
],
|
||||
category: "special",
|
||||
state: "solid",
|
||||
};
|
||||
|
|
@ -101,6 +101,7 @@ if(enabledMods.includes("mods/ketchup_mod.js")) {
|
|||
|
||||
if(enabledMods.includes("mods/randomness.js")) {
|
||||
regularMetalArray.push("tungstensteel")
|
||||
regularMetalArray.push("densinium")
|
||||
}
|
||||
|
||||
if(enabledMods.includes("mods/fey_and_more.js")) {
|
||||
|
|
@ -111,6 +112,10 @@ if(enabledMods.includes("mods/some_tf_liquids.js")) {
|
|||
regularMetalArray.push("signalum")
|
||||
}
|
||||
|
||||
if(enabledMods.includes("mods/laetium.js")) {
|
||||
regularMetalArray.push("laetium")
|
||||
}
|
||||
|
||||
elements.nitrogen_snow = {
|
||||
color: "#efefef",
|
||||
behavior: behaviors.POWDER,
|
||||
|
|
@ -141,4 +146,8 @@ runAfterLoad(function() {
|
|||
elements[regularMetalArray[i]].breakInto = `${regularMetalArray[i]}_scrap`
|
||||
};
|
||||
};
|
||||
if(enabledMods.includes("mods/randomness.js")) {
|
||||
elements.acid.ignore.push("densinium_scrap")
|
||||
elements.densinium_scrap.hardness = 0.99
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
arrayNameA = ["radiation", "alcohol", "soap", "acid", "ammonia", "acid_gas"]
|
||||
arrayNameB = ["plant", "frozen_plant", "grass", "algae", "sapling", "seeds", "grass_seed", "wheat_seed", "wheat", "flower_seed", "pistil", "petal", "vine", "bamboo", "bamboo_plant", "corn_seed", "potato_seed", "root", "berry_seed", "old_berry_leaf", "berry_leaf", "berry"]
|
||||
arrayNameA = ["radiation", "alcohol", "soap", "acid", "ammonia", "acid_gas"];
|
||||
arrayNameB = ["plant", "frozen_plant", "grass", "algae", "sapling", "seeds", "grass_seed", "wheat_seed", "wheat", "flower_seed", "pistil", "petal", "vine", "bamboo", "bamboo_plant", "corn_seed", "potato_seed", "root", "berry_seed", "old_berry_leaf", "berry_leaf", "berry"];
|
||||
if(enabledMods.includes("mods/alcohol.js")) {
|
||||
arrayNameA.push("methanol");
|
||||
arrayNameA.push("propanol");
|
||||
arrayNameA.push("isopropanol");
|
||||
arrayNameA.push("butanol");
|
||||
};
|
||||
|
||||
runAfterLoad(function() {
|
||||
for(i = 0; i < arrayNameA.length; i++) {
|
||||
if(!elements[arrayNameA[i]].reactions) {
|
||||
elements[arrayNameA[i]].reactions = {}
|
||||
|
|
@ -7,4 +15,5 @@ for(i = 0; i < arrayNameA.length; i++) {
|
|||
for(j = 0; j < arrayNameB.length; j++) {
|
||||
elements[arrayNameA[i]].reactions[arrayNameB[j]] = { "elem1":null, "elem2":"dead_plant" }
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
elements.up_pusher = {
|
||||
color: "#7f7f7f",
|
||||
tick: function(pixel) {
|
||||
for(i=9; i>=0; i--) {
|
||||
if (!isEmpty(pixel.x,pixel.y-1-i,true)) {
|
||||
tryMove(pixelMap[pixel.x][pixel.y-1-i],pixel.x,pixel.y-2-i)
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
state: "solid",
|
||||
}
|
||||
|
||||
elements.down_pusher = {
|
||||
color: "#7f7f7f",
|
||||
tick: function(pixel) {
|
||||
for(i=9; i>=0; i--) {
|
||||
if (!isEmpty(pixel.x,pixel.y+1+i,true)) {
|
||||
tryMove(pixelMap[pixel.x][pixel.y+1+i],pixel.x,pixel.y+2+i)
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
state: "solid",
|
||||
}
|
||||
|
||||
elements.left_pusher = {
|
||||
color: "#7f7f7f",
|
||||
tick: function(pixel) {
|
||||
for(i=9; i>=0; i--) {
|
||||
if (!isEmpty(pixel.x-1-i,pixel.y,true)) {
|
||||
tryMove(pixelMap[pixel.x-1-i][pixel.y],pixel.x-2-i,pixel.y)
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
state: "solid",
|
||||
}
|
||||
|
||||
elements.right_pusher = {
|
||||
color: "#7f7f7f",
|
||||
tick: function(pixel) {
|
||||
for(i=9; i>=0; i--) {
|
||||
if (!isEmpty(pixel.x+1+i,pixel.y,true)) {
|
||||
tryMove(pixelMap[pixel.x+1+i][pixel.y],pixel.x+2+i,pixel.y)
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
state: "solid",
|
||||
}
|
||||
|
|
@ -0,0 +1,328 @@
|
|||
urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
if(urlParams.get('liquidAmount') != null) { //null check
|
||||
liquidAmount = urlParams.get('liquidAmount')
|
||||
if(isNaN(liquidAmount) || liquidAmount === "" || liquidAmount === null) { //NaN check
|
||||
liquidAmount = 10
|
||||
}
|
||||
liquidAmount = parseInt(liquidAmount)
|
||||
liquidAmount = Math.min(10000,Math.max(liquidAmount,1))
|
||||
} else {
|
||||
liquidAmount = 10
|
||||
}
|
||||
|
||||
function _randomInt(max) {
|
||||
if(max >= 0) {
|
||||
return Math.floor(Math.random() * (max + 1))
|
||||
} else {
|
||||
return 0 - Math.floor(Math.random() * (Math.abs(max) + 1))
|
||||
}
|
||||
}
|
||||
|
||||
function _randomArrayChoice(array) {
|
||||
return array[_randomInt(array.length - 1)]
|
||||
}
|
||||
|
||||
//arbitrarily picked
|
||||
const initialArrayL = ["m","n","p","t","ch","k","b","d","j","g","f","th","s","sh","h","l","r","y","w","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","sl","fl","fr","pl","pr","tl","tr","kl","kr","shr","fl","fr","thr"] //:eggTF:
|
||||
const vowelArrayL = ["a","e","i","o","u","ay","ee","ie","oa","ew","oo","oi","ow"] //:eggTF:
|
||||
const medialArrayL = ["m","n","p","t","k","b","d","g","f","th","s","sh","h","l","r","y","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","sl","fl","fr","pl","pr","tl","tr","kl","kr","shr","fl","fr","thr"] //:eggTF:
|
||||
const finalArrayL = ["m","n","p","t","k","b","d","g","f","th","s","sh","l","r","y","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","pl","pr","tl","tr","bl","vr"] //:eggTF:
|
||||
|
||||
enabledMods.includes("mods/log_liquids.js") ? logLiquids = true : logLiquids = false
|
||||
//This is intended for people who want to copy their liquids from the console to a file for some reason. Technically, the empty enabler script doesn't even have to exist, but I'll make it just so that index.html doesn't spit out an ERR_FILE_NOT_FOUND.
|
||||
|
||||
function generateName() {
|
||||
//these are picked arbitrarily
|
||||
|
||||
//console.log("getting random type")
|
||||
var randomInt1 = _randomInt(6)
|
||||
|
||||
//console.log("generating type " + randomInt1)
|
||||
if(randomInt1 == 0) {
|
||||
var randomName = _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(finalArrayL)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 1) {
|
||||
var randomName = _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(medialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(finalArrayL)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 2) {
|
||||
var randomName = _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(finalArrayL) + "e"
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 3) {
|
||||
var randomName = _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(medialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(medialArrayL) + _randomArrayChoice(finalArrayL)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 4) {
|
||||
var randomName = _randomArrayChoice(vowelArrayL) + _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(finalArrayL)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 5) {
|
||||
var randomName = _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(medialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(medialArrayL) + _randomArrayChoice(vowelArrayL)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 6) {
|
||||
var randomName = _randomArrayChoice(initialArrayL) + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(medialArrayL) + _randomArrayChoice(vowelArrayL)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else {
|
||||
var randomName = randomArrayChoice(vowelArrayL) + randomArrayChoice(medialArrayL) + randomArrayChoice(vowelArrayL) + randomArrayChoice(finalArrayL)
|
||||
//console.log("warning: type was above 6 somehow")
|
||||
}
|
||||
//console.log(randomName)
|
||||
return randomName
|
||||
}
|
||||
|
||||
const whiteColor = {r: 255, g: 255, b: 255}
|
||||
const blackColor = {r: 0, g: 0, b: 0}
|
||||
|
||||
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)". Also doesn't round properly for some reason...
|
||||
//console.log("Splitting string")
|
||||
color = color.split(",");
|
||||
//console.log("Getting R");
|
||||
var red = parseInt(color[0].substring(4))
|
||||
//console.log("Getting G");
|
||||
var green = parseInt(color[1])
|
||||
//console.log("Getting B");
|
||||
var blue = parseInt(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."
|
||||
};
|
||||
};
|
||||
|
||||
function _multiplyColorObjects(color1,color2,weight1=0.5) { /*third argument is for color1 and expects a float from 0
|
||||
to 1, where 0 means "all color2" and 1 means "all color1"*/
|
||||
var w1 = Math.min(Math.max(weight1,0),1)
|
||||
var red1 = color1.r
|
||||
var green1 = color1.g
|
||||
var blue1 = color1.b
|
||||
var red2 = color2.r
|
||||
var green2 = color2.g
|
||||
var blue2 = color2.b
|
||||
var red3 = (red1 * w1) + (red2 * (1 - w1))
|
||||
var green3 = (green1 * w1) + (green2 * (1 - w1))
|
||||
var blue3 = (blue1 * w1) + (blue2 * (1 - w1))
|
||||
return {r: red3, g: green3, b: blue3}
|
||||
}
|
||||
|
||||
function generateColors() {
|
||||
var randomR = _randomInt(255)
|
||||
var randomG = _randomInt(255)
|
||||
var randomB = _randomInt(255)
|
||||
var randomColor = {r: randomR, g: randomG, b: randomB}
|
||||
var newLiquidColor = _multiplyColorObjects(whiteColor,randomColor,weight1=0.1)
|
||||
var newSolidColor = _multiplyColorObjects(whiteColor,randomColor,weight1=0.4)
|
||||
var newGasColor = _multiplyColorObjects(whiteColor,randomColor,weight1=0.7)
|
||||
var newLiquidColor = _rgbToHex(newLiquidColor)
|
||||
var newSolidColor = _rgbToHex(newSolidColor)
|
||||
var newGasColor = _rgbToHex(newGasColor)
|
||||
return [newLiquidColor, newSolidColor, newGasColor]
|
||||
}
|
||||
|
||||
function _add2(number1,number2) {
|
||||
return number1 + number2
|
||||
}
|
||||
|
||||
function _arrayAverage(array) {
|
||||
var total = array.reduce(_add2,0)
|
||||
return total / array.length
|
||||
}
|
||||
|
||||
function _generateAveragedRandoms() {
|
||||
return _arrayAverage([Math.random(),Math.random(),Math.random()])
|
||||
}
|
||||
|
||||
function avgRndToMult() {
|
||||
return 1 + (0.55 - _generateAveragedRandoms())
|
||||
}
|
||||
|
||||
|
||||
if(logLiquids == true) {
|
||||
liquidString = ""
|
||||
}
|
||||
|
||||
for(i = 0; i < liquidAmount; i++) {
|
||||
var name = generateName();
|
||||
var meltingAdjustment = avgRndToMult();
|
||||
var densityAdjustment = avgRndToMult();
|
||||
var hardnessAdjustment = avgRndToMult();
|
||||
var conductivity = Math.random() ** 1.8;
|
||||
var conductivityEnabled = Math.random();
|
||||
var conducts = null;
|
||||
conductivityEnabled < 1/3 ? conducts = true : conducts = false;
|
||||
var burn = (Math.random() ** 2) * 100;
|
||||
var burnTime = 10 ** ((0.5 + Math.random()) ** 3);
|
||||
var burningEnabled = Math.random();
|
||||
var burns = null;
|
||||
burningEnabled < 1/3 ? burns = true : burns = false;
|
||||
var colors = generateColors();
|
||||
var viscosity = (1 + Math.random()) ** 10;
|
||||
var solidDensityMultiplier = 1+(Math.abs(1-avgRndToMult()));
|
||||
var solidDensityRelationRandomizer = Math.random();
|
||||
var solidIsLessDense = null;
|
||||
var solidDensity = null;
|
||||
solidDensityRelationRandomizer < 0.1 ? solidIsLessDense = true : solidIsLessDense = false;
|
||||
solidIsLessDense == true ? solidDensity = (1000 / solidDensityMultiplier) * densityAdjustment : solidDensity = (1000 * solidDensityMultiplier) * densityAdjustment;
|
||||
var freezingPoint = (273 * (meltingAdjustment ** 10)) - 273;
|
||||
var boilingPoint = freezingPoint + Math.abs((273 * (avgRndToMult() ** 9)) - 273);
|
||||
var gasDensity = 0.00143 * avgRndToMult() * 1000 * densityAdjustment;
|
||||
if(typeof(elements[name]) != "undefined") {
|
||||
name = name + _randomArrayChoice(vowelArrayL) + _randomArrayChoice(finalArrayL);
|
||||
};
|
||||
liquidConductivityAdjust = 0.5 * Math.sqrt(avgRndToMult());
|
||||
|
||||
elements[name] = {
|
||||
name: name,
|
||||
color: colors[0],
|
||||
behavior: behaviors.LIQUID,
|
||||
tempLow: freezingPoint,
|
||||
temp: freezingPoint + 20,
|
||||
tempHigh: boilingPoint,
|
||||
stateLow: `${name}_ice`,
|
||||
stateHigh: `${name}_gas`,
|
||||
category: "random liquids",
|
||||
state: "liquid",
|
||||
density: 1000 * densityAdjustment,
|
||||
//conduct: goes here
|
||||
//burn and burnTime go here
|
||||
hardness: 0.3 * hardnessAdjustment,
|
||||
viscosity: viscosity,
|
||||
breakInto: `${name}_gas`,
|
||||
};
|
||||
|
||||
elements[`${name}_ice`] = {
|
||||
name: `${name} ice`,
|
||||
color: colors[1],
|
||||
behavior: behaviors.WALL,
|
||||
tempHigh: freezingPoint,
|
||||
temp: freezingPoint - 20,
|
||||
stateHigh: name,
|
||||
category: "random solids",
|
||||
state: "solid",
|
||||
density: solidDensity,
|
||||
//conduct: goes here
|
||||
//burn and burnTime go here
|
||||
hardness: 0.6 * hardnessAdjustment,
|
||||
breakInto: name,
|
||||
};
|
||||
|
||||
elements[`${name}_gas`] = {
|
||||
name: `${name} gas`,
|
||||
color: colors[2],
|
||||
behavior: behaviors.GAS,
|
||||
tempLow: boilingPoint,
|
||||
temp: boilingPoint + 20,
|
||||
stateLow: name,
|
||||
category: "random gases",
|
||||
state: "gas",
|
||||
density: gasDensity,
|
||||
//burn and burnTime go here
|
||||
hardness: 1,
|
||||
};
|
||||
|
||||
if(burns == true) {
|
||||
elements[name].burn = burn
|
||||
elements[name].burnTime = burnTime
|
||||
elements[`${name}_ice`].burn = burn
|
||||
elements[`${name}_ice`].burnTime = burnTime
|
||||
elements[`${name}_gas`].burn = burn
|
||||
elements[`${name}_gas`].burnTime = burnTime
|
||||
}
|
||||
|
||||
if(conducts == true) {
|
||||
elements[name].conduct = conductivity * liquidConductivityAdjust
|
||||
elements[`${name}_ice`].conduct = conductivity
|
||||
}
|
||||
|
||||
if(logLiquids == true) {
|
||||
//Append moddable code for the liquid state to liquidString
|
||||
liquidString = liquidString + `elements.${name} = {\n name: \"${name}\",\n color: \"${colors[0]}\",\n behavior: behaviors.LIQUID,\n tempLow: ${freezingPoint},\n temp: ${freezingPoint + 20},\n tempHigh: ${boilingPoint},\n stateLow: \"${name}_ice\",\n stateHigh: \"${name}_gas\",\n category: \"random liquids\",\n state: \"liquid\",\n density: ${1000 * densityAdjustment},\n `
|
||||
if(conducts == true) { liquidString = liquidString + `conduct: ${conductivity * liquidConductivityAdjust},\n ` }
|
||||
if(burns == true) { liquidString = liquidString + `burn: ${burn},\n burnTime: ${burnTime},\n ` }
|
||||
liquidString = liquidString + `hardness: ${0.3 * hardnessAdjustment},\n viscosity: ${viscosity},\n breakInto: \"${name}_gas\",\n};\n\n`
|
||||
|
||||
//Append moddable code for the solid state to liquidString
|
||||
liquidString = liquidString + `elements.${name}_ice = {\n name: \"${name} ice\",\n color: \"${colors[1]}\",\n behavior: behaviors.WALL,\n tempHigh: ${freezingPoint},\n temp: ${freezingPoint - 20},\n stateHigh: \"${name}\",\n category: \"random solids\",\n state: \"solid\",\n density: ${solidDensity},\n `
|
||||
if(conducts == true) { liquidString = liquidString + `conduct: ${conductivity},\n ` }
|
||||
if(burns == true) { liquidString = liquidString + `burn: ${burn},\n burnTime: ${burnTime},\n ` }
|
||||
liquidString = liquidString + `hardness: ${0.6 * hardnessAdjustment},\n breakInto: \"${name}\",\n};\n\n`
|
||||
|
||||
//Append moddable code for the gaseous state to liquidString
|
||||
liquidString = liquidString + `elements.${name}_gas = {\n name: \"${name} gas\",\n color: \"${colors[2]}\",\n behavior: behaviors.GAS,\n tempLow: ${boilingPoint},\n temp: ${boilingPoint + 20},\n stateLow: \"${name}\",\n category: \"random gases\",\n state: \"solid\",\n density: ${gasDensity},\n `
|
||||
if(burns == true) { liquidString = liquidString + `burn: ${burn},\n burnTime: ${burnTime},\n ` }
|
||||
liquidString = liquidString + `hardness: 1,\n};\n\n`
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(logLiquids == true) {
|
||||
console.log(`Liquids added to liquidString (length ${liquidString.length})`)
|
||||
}
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
if(urlParams.get('rockAmount') != null) { //null check
|
||||
rockAmount = urlParams.get('rockAmount')
|
||||
if(isNaN(rockAmount) || rockAmount === "" || rockAmount === null) { //NaN check
|
||||
rockAmount = 10
|
||||
}
|
||||
rockAmount = parseInt(rockAmount)
|
||||
rockAmount = Math.min(10000,Math.max(rockAmount,1))
|
||||
} else {
|
||||
rockAmount = 10
|
||||
}
|
||||
|
||||
function _randomInt(max) {
|
||||
if(max >= 0) {
|
||||
return Math.floor(Math.random() * (max + 1))
|
||||
} else {
|
||||
return 0 - Math.floor(Math.random() * (Math.abs(max) + 1))
|
||||
}
|
||||
}
|
||||
|
||||
function _randomArrayChoice(array) {
|
||||
return array[_randomInt(array.length - 1)]
|
||||
}
|
||||
|
||||
//arbitrarily picked
|
||||
const initialArrayR = ["m","n","p","t","ch","k","b","d","j","g","f","th","s","sh","h","l","r","y","w","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","sl","fl","fr","pl","pr","tl","tr","kl","kr","shr","fl","fr","thr"] //:eggTF:
|
||||
const vowelArrayR = ["a","e","i","o","u","ay","ee","ie","oa","ew","oo","oi","ow"] //:eggTF:
|
||||
const medialArrayR = ["m","n","p","t","k","b","d","g","f","th","s","sh","h","l","r","y","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","sl","fl","fr","pl","pr","tl","tr","kl","kr","shr","fl","fr","thr"] //:eggTF:
|
||||
const finalArrayR = ["m","n","p","t","k","b","d","g","f","th","s","sh","l","r","y","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","pl","pr","tl","tr","bl","vr"] //:eggTF:
|
||||
|
||||
enabledMods.includes("mods/log_rocks.js") ? logRocks = true : logRocks = false
|
||||
//This is intended for people who want to copy their rocks from the console to a file for some reason. Technically, the empty enabler script doesn't even have to exist, but I'll make it just so that index.html doesn't spit out an ERR_FILE_NOT_FOUND.
|
||||
|
||||
function generateName() {
|
||||
//these are picked arbitrarily
|
||||
|
||||
//console.log("getting random type")
|
||||
var randomInt1 = _randomInt(6)
|
||||
|
||||
//console.log("generating type " + randomInt1)
|
||||
if(randomInt1 == 0) {
|
||||
var randomName = _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(finalArrayR)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 1) {
|
||||
var randomName = _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(medialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(finalArrayR)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 2) {
|
||||
var randomName = _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(finalArrayR) + "e"
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 3) {
|
||||
var randomName = _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(medialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(medialArrayR) + _randomArrayChoice(finalArrayR)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 4) {
|
||||
var randomName = _randomArrayChoice(vowelArrayR) + _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(finalArrayR)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 5) {
|
||||
var randomName = _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(medialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(medialArrayR) + _randomArrayChoice(vowelArrayR)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else if(randomInt1 == 6) {
|
||||
var randomName = _randomArrayChoice(initialArrayR) + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(medialArrayR) + _randomArrayChoice(vowelArrayR)
|
||||
//console.log("generated T" + randomInt1 + " name")
|
||||
} else {
|
||||
var randomName = randomArrayChoice(vowelArrayR) + randomArrayChoice(medialArrayR) + randomArrayChoice(vowelArrayR) + randomArrayChoice(finalArrayR)
|
||||
//console.log("warning: type was above 6 somehow")
|
||||
}
|
||||
//console.log(randomName)
|
||||
return randomName
|
||||
}
|
||||
|
||||
const rockColor1 = {r: 128, g: 128, b: 128}
|
||||
const rockColor2 = {r: 79, g: 79, b: 79}
|
||||
const rockColor3 = {r: 148, g: 148, b: 148}
|
||||
const gravelColor1 = {r: 227, g: 224, b: 223}
|
||||
const gravelColor2 = {r: 177, g: 171, b: 163}
|
||||
const gravelColor3 = {r: 116, g: 115, b: 109}
|
||||
const gravelColor4 = {r: 82, g: 75, b: 71}
|
||||
|
||||
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)". Also doesn't round properly for some reason...
|
||||
//console.log("Splitting string")
|
||||
color = color.split(",");
|
||||
//console.log("Getting R");
|
||||
var red = parseInt(color[0].substring(4))
|
||||
//console.log("Getting G");
|
||||
var green = parseInt(color[1])
|
||||
//console.log("Getting B");
|
||||
var blue = parseInt(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."
|
||||
};
|
||||
};
|
||||
|
||||
function _multiplyColorObjects(color1,color2,weight1=0.5) { /*third argument is for color1 and expects a float from 0
|
||||
to 1, where 0 means "all color2" and 1 means "all color1"*/
|
||||
var w1 = Math.min(Math.max(weight1,0),1)
|
||||
var red1 = color1.r
|
||||
var green1 = color1.g
|
||||
var blue1 = color1.b
|
||||
var red2 = color2.r
|
||||
var green2 = color2.g
|
||||
var blue2 = color2.b
|
||||
var red3 = (red1 * w1) + (red2 * (1 - w1))
|
||||
var green3 = (green1 * w1) + (green2 * (1 - w1))
|
||||
var blue3 = (blue1 * w1) + (blue2 * (1 - w1))
|
||||
return {r: red3, g: green3, b: blue3}
|
||||
}
|
||||
|
||||
function generateColors() {
|
||||
var randomR = _randomInt(255)
|
||||
var randomG = _randomInt(255)
|
||||
var randomB = _randomInt(255)
|
||||
var randomColor = {r: randomR, g: randomG, b: randomB}
|
||||
var newRockColor1 = _multiplyColorObjects(rockColor1,randomColor,weight1=0.65)
|
||||
var newRockColor2 = _multiplyColorObjects(rockColor2,randomColor,weight1=0.65)
|
||||
var newRockColor3 = _multiplyColorObjects(rockColor3,randomColor,weight1=0.65)
|
||||
var newGravelColor1 = _multiplyColorObjects(gravelColor1,randomColor,weight1=0.675)
|
||||
var newGravelColor2 = _multiplyColorObjects(gravelColor2,randomColor,weight1=0.675)
|
||||
var newGravelColor3 = _multiplyColorObjects(gravelColor3,randomColor,weight1=0.675)
|
||||
var newGravelColor4 = _multiplyColorObjects(gravelColor4,randomColor,weight1=0.675)
|
||||
var newRockColor1 = _rgbToHex(newRockColor1)
|
||||
var newRockColor2 = _rgbToHex(newRockColor2)
|
||||
var newRockColor3 = _rgbToHex(newRockColor3)
|
||||
var newGravelColor1 = _rgbToHex(newGravelColor1)
|
||||
var newGravelColor2 = _rgbToHex(newGravelColor2)
|
||||
var newGravelColor3 = _rgbToHex(newGravelColor3)
|
||||
var newGravelColor4 = _rgbToHex(newGravelColor4)
|
||||
return [newRockColor1, newRockColor2, newRockColor3, newGravelColor1, newGravelColor2, newGravelColor3, newGravelColor4]
|
||||
}
|
||||
|
||||
function _add2(number1,number2) {
|
||||
return number1 + number2
|
||||
}
|
||||
|
||||
function _arrayAverage(array) {
|
||||
var total = array.reduce(_add2,0)
|
||||
return total / array.length
|
||||
}
|
||||
|
||||
function _generateAveragedRandoms() {
|
||||
return _arrayAverage([Math.random(),Math.random(),Math.random()])
|
||||
}
|
||||
|
||||
function avgRndToMult() {
|
||||
return 1 + (0.55 - _generateAveragedRandoms())
|
||||
}
|
||||
|
||||
elements.gravel.breakInto = "dust"
|
||||
|
||||
if(logRocks == true) {
|
||||
rockString = ""
|
||||
}
|
||||
|
||||
for(i = 0; i < rockAmount; i++) {
|
||||
var name = generateName()
|
||||
var meltingAdjustment = avgRndToMult()
|
||||
var densityAdjustment = avgRndToMult()
|
||||
var hardnessAdjustment = avgRndToMult()
|
||||
var colors = generateColors()
|
||||
if(typeof(elements[name]) != "undefined") {
|
||||
name = name + _randomArrayChoice(vowelArrayR) + _randomArrayChoice(finalArrayR)
|
||||
}
|
||||
elements[name] = {
|
||||
name: name,
|
||||
color: [colors[0], colors[1], colors[2]],
|
||||
behavior: behaviors.POWDER,
|
||||
tempHigh: 950 * meltingAdjustment,
|
||||
category: "random rocks",
|
||||
state: "solid",
|
||||
density: 2550 * densityAdjustment,
|
||||
hardness: 0.5 * hardnessAdjustment,
|
||||
breakInto: ["dust",`${name}_gravel`],
|
||||
}
|
||||
|
||||
if(logRocks == true) {
|
||||
rockString = rockString + `elements.${name} = {\n name: \"${name}\",\n color: [\"${colors[0]}\", \"${colors[1]}\", \"${colors[2]}\"],\n behavior: behaviors.POWDER,\n tempHigh: ${950 * meltingAdjustment},\n category: \"random rocks\",\n state: \"solid\",\n density: ${2550 * densityAdjustment},\n hardness: ${0.5 * hardnessAdjustment},\n breakInto: [\"dust\",\"${name}_gravel\"],\n};\n\n`
|
||||
}
|
||||
|
||||
elements[`${name}_gravel`] = {
|
||||
name: `${name} gravel`,
|
||||
color: [colors[3], colors[4], colors[5], colors[6]],
|
||||
behavior: behaviors.POWDER,
|
||||
tempHigh: 950 * meltingAdjustment,
|
||||
stateHigh: name,
|
||||
category: "random rocks",
|
||||
state: "solid",
|
||||
density: 1680 * densityAdjustment,
|
||||
hardness: 0.2 * (hardnessAdjustment ** (2/3)),
|
||||
breakInto: "dust",
|
||||
}
|
||||
|
||||
if(logRocks == true) {
|
||||
rockString = rockString + `elements.${name}_gravel = {\n name: \"${name} gravel\",\n color: [\"${colors[3]}\", \"${colors[4]}\", \"${colors[5]}\", \"${colors[6]}\"],\n behavior: behaviors.POWDER,\n tempHigh: ${950 * meltingAdjustment},\n stateHigh: \"${name}\",\n category: \"random rocks\",\n state: \"solid\",\n density: ${1680 * densityAdjustment},\n hardness: ${0.2 * (hardnessAdjustment ** (2/3))},\n breakInto: \"dust\",\n};\n\n`
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(logRocks == true) {
|
||||
console.log(`Rocks added to rockString (length ${rockString.length})`)
|
||||
}
|
||||
|
|
@ -723,6 +723,181 @@ elements.seb = {
|
|||
hardness: 0.3,
|
||||
}
|
||||
|
||||
elements.densinium = {
|
||||
color: ["#565656","#575657","#565257","#554d57","#554659"],
|
||||
tempHigh: 4712, //arbitrary
|
||||
hardness: 0.9991, //somewhat arbitrary
|
||||
density: 39180,
|
||||
conduct: 0.86, //arbitrary
|
||||
behavior: behaviors.WALL,
|
||||
state: "solid",
|
||||
category: "solids",
|
||||
} //this is effectively a mere interpretation of densinium
|
||||
|
||||
elements.molten_densinium = {
|
||||
hardness: 0.9991,
|
||||
}
|
||||
|
||||
elements.acid.ignore.push("densinium","molten_densinium")
|
||||
|
||||
//https://gist.github.com/kig/2115205
|
||||
function hslToHex(c) {
|
||||
var hue=0, saturation=0, lightness=0;
|
||||
var tmp = 0;
|
||||
for (var i=0,j=0,k=0; i<c.length; i++) {
|
||||
var ch = c.charCodeAt(i);
|
||||
if (ch >= 48 && ch <= 57) {
|
||||
tmp = tmp * 10 + (ch-48);
|
||||
k = 1;
|
||||
continue;
|
||||
} else if (k === 1) {
|
||||
switch(j) {
|
||||
case 0: hue = (tmp % 360) / 360; break;
|
||||
case 1:
|
||||
saturation = (tmp > 100 ? 100 : tmp) / 100; break;
|
||||
case 2:
|
||||
lightness = (tmp > 100 ? 100 : tmp) / 100; break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
k = 0;
|
||||
tmp = 0;
|
||||
}
|
||||
var h = (hue / (1/6));
|
||||
var c = (1-Math.abs(2*lightness-1))*saturation;
|
||||
var x = c * (1-Math.abs((h%2)-1));
|
||||
switch (h | 0) {
|
||||
case 0: r=c; g=x; b=0; break;
|
||||
case 1: r=x; g=c; b=0; break;
|
||||
case 2: r=0; g=c; b=x; break;
|
||||
case 3: r=0; g=x; b=c; break;
|
||||
case 4: r=x; g=0; b=c; break;
|
||||
case 5: r=c; g=0; b=x; break;
|
||||
}
|
||||
var m = lightness - 0.5*c;
|
||||
r+=m; g+=m; b+=m;
|
||||
r=r*255|0; g=g*255|0; b=b*255|0;
|
||||
var hex = '#';
|
||||
k = (r >> 4 & 0xf) + 48;
|
||||
if (k > 57) k += 7;
|
||||
hex += String.fromCharCode(k);
|
||||
k = (r & 0xf) + 48;
|
||||
if (k > 57) k += 7;
|
||||
hex += String.fromCharCode(k);
|
||||
k = (g >> 4 & 0xf) + 48;
|
||||
if (k > 57) k += 7;
|
||||
hex += String.fromCharCode(k);
|
||||
k = (g & 0xf) + 48;
|
||||
if (k > 57) k += 7;
|
||||
hex += String.fromCharCode(k);
|
||||
k = (b >> 4 & 0xf) + 48;
|
||||
if (k > 57) k += 7;
|
||||
hex += String.fromCharCode(k);
|
||||
k = (b & 0xf) + 48;
|
||||
if (k > 57) k += 7;
|
||||
hex += String.fromCharCode(k);
|
||||
return hex;
|
||||
}
|
||||
//e.g. hslToHex("hsl(60,100,100)")
|
||||
|
||||
rainbowDustArray = []
|
||||
for(i = 0; i < 24; i++) {
|
||||
rainbowDustArray.push("hsl(" + (i * 15) + ",15,45)")
|
||||
}
|
||||
|
||||
for(i = 0; i < rainbowDustArray.length; i++) {
|
||||
rainbowDustArray[i] = hslToHex(rainbowDustArray[i])
|
||||
}
|
||||
|
||||
rainbowStoneArray = []
|
||||
for(i = 0; i < 24; i++) {
|
||||
rainbowStoneArray.push("hsl(" + (i * 15) + ",40,48)")
|
||||
rainbowStoneArray.push("hsl(" + (i * 15) + ",48,38)")
|
||||
rainbowStoneArray.push("hsl(" + (i * 15) + ",52,47)")
|
||||
}
|
||||
|
||||
for(i = 0; i < rainbowStoneArray.length; i++) {
|
||||
rainbowStoneArray[i] = hslToHex(rainbowStoneArray[i])
|
||||
}
|
||||
|
||||
rainbowGravelArray = []
|
||||
for(i = 0; i < 24; i++) {
|
||||
rainbowGravelArray.push("hsl(" + (i * 15) + ",35,58)")
|
||||
rainbowGravelArray.push("hsl(" + (i * 15) + ",38,49)")
|
||||
rainbowGravelArray.push("hsl(" + (i * 15) + ",53,63)")
|
||||
rainbowGravelArray.push("hsl(" + (i * 15) + ",23,32)")
|
||||
}
|
||||
|
||||
for(i = 0; i < rainbowGravelArray.length; i++) {
|
||||
rainbowGravelArray[i] = hslToHex(rainbowGravelArray[i])
|
||||
}
|
||||
|
||||
elements.rainbow_stone = {
|
||||
color: rainbowStoneArray,
|
||||
behavior: behaviors.POWDER,
|
||||
tempHigh: 1271,
|
||||
stateHigh: "rainbow_magma",
|
||||
category: "land",
|
||||
state: "solid",
|
||||
density: 3201,
|
||||
hardness: 0.8,
|
||||
breakInto: ["rainbow_dust","rainbow_gravel"],
|
||||
};
|
||||
|
||||
elements.rainbow_magma = {
|
||||
color: ["#F14313", "#F17E13", "#F1AB13", "#C8C830", "#F53952", "#F63434", "#CF7932"],
|
||||
behavior: behaviors.MOLTEN,
|
||||
temp: 1300,
|
||||
tempLow: 1271,
|
||||
stateLow: ["rainbow_stone_2", "rainbow_stone_2", "rainbow_stone_2", "rainbow_stone_2", "rainbow_stone"],
|
||||
category: "liquids",
|
||||
state: "solid",
|
||||
density: 2562,
|
||||
hardness: 0.7,
|
||||
breakInto: "rainbow_magma",
|
||||
viscosity: 11000,
|
||||
};
|
||||
|
||||
elements.rainbow_stone_2 = {
|
||||
color: ["#503A2A","#443228","#533D2D","#4D422B","#433827","#53432D","#4B472B","#423E25","#4F4A2C","#494C2A","#414125","#4B512B","#475328","#3E4725","#4A592A","#40532C","#384529","#45582D","#3C522F","#35462A","#3F572F","#35552F","#2F472D","#375931","#2D5333","#28482E","#2F5836","#2F5138","#2A4634","#31563A","#2F5140","#2B4539","#2F5542","#2F5044","#2C443C","#325449","#30504A","#2D4340","#31544F","#34494B","#2E4040","#354E4E","#35424C","#2F3C40","#374551","#383E4B","#323641","#3D3E50","#3B374C","#352F42","#3C3951","#413649","#393041","#443750","#473548","#3D2E3F","#4A374D","#4B3546","#422F3C","#52364A","#503644","#452E3B","#593447","#50353F","#463137","#583643","#50363A","#463033","#57393B","#4F3832","#443130","#553B35"],
|
||||
behavior: [
|
||||
"XX|XX|XX",
|
||||
"XX|XX|XX",
|
||||
"M2%81|M1|M2%81"
|
||||
],
|
||||
tempHigh: 1276,
|
||||
stateHigh: "rainbow_magma",
|
||||
category: "land",
|
||||
state: "solid",
|
||||
density: 3717,
|
||||
hardness: 0.82,
|
||||
breakInto: ["rainbow_dust","rainbow_gravel"],
|
||||
};
|
||||
|
||||
elements.rainbow_dust = {
|
||||
color: rainbowDustArray,
|
||||
behavior: behaviors.POWDER,
|
||||
tempHigh: 1271,
|
||||
stateHigh: "rainbow_magma",
|
||||
category: "land",
|
||||
state: "solid",
|
||||
density: 3552,
|
||||
hardness: 0.4,
|
||||
breakInto: ["rainbow_dust","color_smoke","color_smoke","color_smoke","smoke","rainbow_dust","color_smoke","color_smoke","color_smoke","smoke","rainbow_magma"],
|
||||
};
|
||||
|
||||
elements.rainbow_gravel = {
|
||||
color: rainbowGravelArray,
|
||||
behavior: behaviors.POWDER,
|
||||
tempHigh: 1271,
|
||||
stateHigh: "rainbow_magma",
|
||||
category: "land",
|
||||
state: "solid",
|
||||
density: 3552,
|
||||
hardness: 0.4,
|
||||
breakInto: ["rainbow_dust","color_smoke","color_smoke","color_smoke","smoke","rainbow_dust","color_smoke","color_smoke","color_smoke","smoke","rainbow_magma"],
|
||||
};
|
||||
|
||||
if(!enabledMods.includes("mods/minecraft.js")) {
|
||||
elements.netherrack = {
|
||||
color: ["#802b2b","#4f1b1b","#943232"],
|
||||
|
|
|
|||
|
|
@ -1941,8 +1941,28 @@ elements.test293b = {
|
|||
burnInto: "cold_fire",
|
||||
}
|
||||
|
||||
elements.lower_color_copy = {
|
||||
behavior: behaviors.POWDER,
|
||||
tick: function(pixel) {
|
||||
if(!isEmpty(pixel.x,pixel.y+1,true)) {
|
||||
pixel.color = pixelMap[pixel.x][pixel.y+1].color;
|
||||
} else {
|
||||
if(settings.bg) {
|
||||
pixel.color = settings.bg;
|
||||
} else {
|
||||
pixel.color = "#000000";
|
||||
}
|
||||
}
|
||||
},
|
||||
color: ["#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#FF0000", "#FF7F00", "#FFFF00", "#00FF00", "#007FFF", "#0000FF", "#7F00FF"],
|
||||
density: 1250,
|
||||
breakInto: ["metal_scrap", "glass_shard"],
|
||||
hardness: 0.7,
|
||||
}
|
||||
|
||||
runAfterLoad(function() {
|
||||
if(enabledMods.includes("mods/fey_and_more.js")) {
|
||||
elements.lower_color_copy.breakInto.push("magic")
|
||||
aaa.push("poisonwater")
|
||||
aaa.push("poisonwater")
|
||||
aaa.push("poisonwater")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
//this is intended to simulate a substance at its triple point
|
||||
|
||||
elements.test2_s_1 = {
|
||||
color: "#0000FF",
|
||||
behavior: behaviors.POWDER,
|
||||
tick: function(pixel) {
|
||||
if(pixel.temp > elements[pixel.element].tempLow) {
|
||||
if(Math.random() < 0.1) {
|
||||
changePixel(pixel,elements[pixel.element].stateHigh[Math.floor(Math.random() * elements[pixel.element].stateHigh.length)])
|
||||
}
|
||||
}
|
||||
},
|
||||
density: 718.3,
|
||||
temp: 24,
|
||||
tempHigh: -232,
|
||||
stateHigh: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
tempLow: -232,
|
||||
stateLow: ["test2_s_1"],
|
||||
}
|
||||
|
||||
elements.test2_s_2 = {
|
||||
color: "#3000FF",
|
||||
behavior: behaviors.POWDER,
|
||||
tick: function(pixel) {
|
||||
if(Math.random() < 0.1) {
|
||||
changePixel(pixel,elements[pixel.element].stateHigh[Math.floor(Math.random() * elements[pixel.element].stateHigh.length)])
|
||||
}
|
||||
},
|
||||
density: 738.3,
|
||||
temp: 24,
|
||||
tempHigh: 24,
|
||||
stateHigh: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
tempLow: 24,
|
||||
stateLow: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
}
|
||||
|
||||
elements.test2_l = {
|
||||
color: "#0020EF",
|
||||
behavior: behaviors.LIQUID,
|
||||
tick: function(pixel) {
|
||||
if(Math.random() < 0.1) {
|
||||
changePixel(pixel,elements[pixel.element].stateHigh[Math.floor(Math.random() * elements[pixel.element].stateHigh.length)])
|
||||
}
|
||||
},
|
||||
density: 693.3,
|
||||
temp: 24,
|
||||
tempHigh: 24,
|
||||
stateHigh: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
tempLow: 24,
|
||||
stateLow: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
}
|
||||
|
||||
elements.test2_g = {
|
||||
color: "#2000CF",
|
||||
behavior: behaviors.GAS,
|
||||
tick: function(pixel) {
|
||||
if(pixel.temp < elements[pixel.element].tempHigh) {
|
||||
if(Math.random() < 0.1) {
|
||||
changePixel(pixel,elements[pixel.element].stateHigh[Math.floor(Math.random() * elements[pixel.element].stateHigh.length)])
|
||||
}
|
||||
}
|
||||
},
|
||||
density: 2.1,
|
||||
temp: 24,
|
||||
tempLow: 1738,
|
||||
stateLow: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
tempHigh: 1738,
|
||||
stateHigh: ["test2_g"],
|
||||
}
|
||||
|
||||
elements.test2 = {
|
||||
color: "#0000FF",
|
||||
behavior: [
|
||||
"XX|XX|XX",
|
||||
"XX|CH:test2_s_1,test2_s_2,test2_l,test2_g|XX",
|
||||
"M2|M1|M2"
|
||||
],
|
||||
density: 424.3,
|
||||
tempLow: 24,
|
||||
stateLow: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
tempHigh: 24,
|
||||
stateHigh: ["test2_s_1", "test2_s_2", "test2_l", "test2_g"],
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
function drawPixels(forceTick=false) {
|
||||
// newCurrentPixels = shuffled currentPixels
|
||||
var newCurrentPixels = currentPixels.slice();
|
||||
var pixelsFirst = [];
|
||||
var pixelsLast = [];
|
||||
if (!paused || forceTick) {
|
||||
shuffleArray(newCurrentPixels);
|
||||
}
|
||||
/*{newCurrentPixels.sort(function(p) { // shuffle the pixels but keep elements[p.element].isGas last
|
||||
return 0.5 - Math.random();
|
||||
})} // shuffle the pixels if not paused*/
|
||||
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 (!paused || forceTick) {
|
||||
if (elements[pixel.element].tick) { // Run tick function if it exists
|
||||
elements[pixel.element].tick(pixel);
|
||||
}
|
||||
if (pixel.del) {continue}
|
||||
if (elements[pixel.element].behavior) { // Parse behavior if it exists
|
||||
pixelTick(pixel);
|
||||
}
|
||||
};
|
||||
if (elements[pixel.element].isGas) {
|
||||
pixelsLast.push(pixel);
|
||||
}
|
||||
else {
|
||||
pixelsFirst.push(pixel);
|
||||
}
|
||||
}
|
||||
adjacentCoords = [
|
||||
[0,1],
|
||||
[0,-1],
|
||||
[1,0],
|
||||
[-1,0]
|
||||
];
|
||||
biCoords = [
|
||||
[0,1],
|
||||
[1,0]
|
||||
];
|
||||
// Draw the current pixels
|
||||
var canvas = document.getElementById("game");
|
||||
var ctx = canvas.getContext("2d");
|
||||
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 (view===null || view===3) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else if (view === 2) { // thermal view
|
||||
// set the color to pixel.temp, from hottest at 0 hue to coldest 225 hue, with the minimum being -273, max being 6000
|
||||
var temp = pixel.temp;
|
||||
if (temp < -273) {temp = -273}
|
||||
if (temp > 6000) {temp = 6000}
|
||||
var hue = 225 - (temp/6000)*225;
|
||||
if (hue < 0) {hue = 0}
|
||||
if (hue > 225) {hue = 225}
|
||||
ctx.fillStyle = "hsl("+hue+",100%,50%)";
|
||||
}
|
||||
else if (view === 4) { // smooth view, average of surrounding pixels
|
||||
var colorlist = [];
|
||||
// check adjacent coords on the pixelMap, add the color to the list if the pixel is not empty and the color indexOf "rgb" is not -1
|
||||
for (var j = 0; j < biCoords.length; j++) {
|
||||
var x = pixel.x + biCoords[j][0];
|
||||
var y = pixel.y + biCoords[j][1];
|
||||
if (isEmpty(x,y,true) || elements[pixelMap[x][y].element].state !== elements[pixel.element].state) {continue}
|
||||
var color = pixelMap[x][y].color;
|
||||
if (color.indexOf("rgb") !== -1) {
|
||||
colorlist.push(color.match(/\d+/g));
|
||||
}
|
||||
}
|
||||
if (colorlist.length === 0) {
|
||||
ctx.fillStyle = pixel.color;
|
||||
}
|
||||
else {
|
||||
ctx.fillStyle = averageRGB(colorlist);
|
||||
}
|
||||
}
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.globalAlpha = 0.66;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo((pixel.x-0.75)*pixelSize,(pixel.y+1.5)*pixelSize);
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize,(pixel.y-1)*pixelSize);
|
||||
ctx.lineTo((pixel.x+1.75)*pixelSize,(pixel.y+1.5)*pixelSize);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
else { // draw the pixel (default)
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pixel.x*pixelSize,(pixel.y+1)*pixelSize);
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize,(pixel.y)*pixelSize);
|
||||
ctx.lineTo((pixel.x+1)*pixelSize,(pixel.y+1)*pixelSize);
|
||||
ctx.fill();
|
||||
}
|
||||
if (pixel.charge && view !== 2) { // Yellow glow on charge
|
||||
if (!elements[pixel.element].colorOn) {
|
||||
if ((view === null || view === 4) && elements[pixel.element].state === "gas") {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo((pixel.x-0.75)*pixelSize,(pixel.y+1.5)*pixelSize);
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize,(pixel.y-1)*pixelSize);
|
||||
ctx.lineTo((pixel.x+1.75)*pixelSize,(pixel.y+1.5)*pixelSize);
|
||||
ctx.fill();
|
||||
} else {
|
||||
ctx.fillStyle = "rgba(255,255,0,0.5)";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pixel.x*pixelSize,(pixel.y+1)*pixelSize);
|
||||
ctx.lineTo((pixel.x+0.5)*pixelSize,(pixel.y)*pixelSize);
|
||||
ctx.lineTo((pixel.x+1)*pixelSize,(pixel.y+1)*pixelSize);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!paused) || forceTick) {pixelTicks++};
|
||||
}
|
||||
|
|
@ -123,3 +123,48 @@ elements.troll5 = {
|
|||
state: "solid",
|
||||
excludeRandom: true,
|
||||
}
|
||||
|
||||
elements.troll6 = {
|
||||
color: "#eeeeee",
|
||||
tick: function() {
|
||||
if(pixel.temp < -273) {
|
||||
pixel.temp = -273;
|
||||
};
|
||||
if(isNaN(pixel.temp)) {
|
||||
pixel.temp = -1;
|
||||
};
|
||||
pixel.bemp = Math.floor(pixel.temp);
|
||||
if(pixel.bemp > 273) {
|
||||
pixel.bemp = 273;
|
||||
};
|
||||
if(pixel.temp >= 4000) {
|
||||
pixelTicks = -1;
|
||||
pixel.temp = 4000;
|
||||
} else {
|
||||
pixelTicks += pixel.bemp;
|
||||
};
|
||||
},
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
state: "solid",
|
||||
excludeRandom: true,
|
||||
temp: -1,
|
||||
},
|
||||
|
||||
elements.troll7 = {
|
||||
color: "#eeeeee",
|
||||
tick: function(pixel) {
|
||||
for (var i = 1; i < width; i++) {
|
||||
for (var j = 1; j < height; j++) {
|
||||
if (!isEmpty(i,j)) {
|
||||
piskel = pixelMap[i][j]
|
||||
if(Math.random() < 0.003 && piskel.element != pixel.element) { piskel.temp += (Math.floor(Math.random() * 500 + 1) - 250) }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
state: "solid",
|
||||
excludeRandom: true,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue