This commit is contained in:
slweeb 2022-01-26 15:03:12 -05:00
parent b27529ef5e
commit 812a469d50
2 changed files with 142 additions and 60 deletions

View File

@ -2,6 +2,14 @@
+ Artists' Update (Painting, Lines, Shapes, etc.)
+ Machines Update
[Version 1.1.2]
+ Technical: New functions to use in coded elements
doBurning(pixel); // Using this function will allow burning simulation
doHeat(pixel); // Using this function will allow heat simulation
doElectricity(pixel); // Using this function will allow electricity simulation
+ Technical: New hidden example elements: tick_sand, tick_wood, tick_wall, tick_props
+ Technical: New "properties" element attribute. See the tick_props element
[Version 1.1.1]
+ Technical: "tick" element attribute, takes a function
tick: function(pixel) {

View File

@ -571,6 +571,56 @@
state: "solid",
density: 1602,
},
"tick_sand": {
color: "#e6d577",
tick: function(pixel) {
tryMove(pixel, pixel.x, pixel.y+1);
doHeat(pixel);
},
tempHigh: 1700,
stateHigh: "molten_glass",
category: "land",
state: "solid",
density: 1602,
hidden: true,
},
"tick_wood": {
color: "#a0522d",
tick: function(pixel) {
doBurning(pixel);
doHeat(pixel);
},
tempHigh: 400,
stateHigh: "fire",
category: "solids",
burn: 5,
burnTime: 300,
burnInto: ["ash","charcoal","fire"],
state: "solid",
hardness: 0.15,
breakInto: "sawdust",
hidden: true,
},
"tick_wall": {
color: "#808080",
hidden: true,
},
"tick_props": {
color: "#ffffff",
tick: function(pixel) {
if (tryMove(pixel, pixel.x, pixel.y+1)) {
pixel.moves += 1;
}
pixel.age += 1;
if (pixel.moves > 20) { // This pixel will delete itself if it moves 20 times
deletePixel(pixel.x, pixel.y);
}
},
properties: { // Default properties to set when the pixel is created:
"moves": 0,
"age": 0,
},
},
"water": {
color: "#2167ff",
behavior: behaviors.LIQUID,
@ -4171,6 +4221,12 @@
else if (elementInfo.rotatable) {
this.r = Math.floor(Math.random() * 4);
}
// If elementInfo.properties, set each key to its value
if (elementInfo.properties !== undefined) {
for (var key in elementInfo.properties) {
this[key] = elementInfo.properties[key];
}
}
pixelMap[x][y] = this;
}
}
@ -4928,7 +4984,30 @@
}
}
// Change tempearture if needed (unused)
/*if (info.tempChange != undefined) {
pixel.temp += info.tempChange;
pixelTempCheck(pixel);
}*/
// Burning
doBurning(pixel);
// Heat Transfer
if (info.insulate != true) {
doHeat(pixel);
}
// Electricity Transfer
doElectricity(pixel);
}
function doBurning(pixel) {
if (pixel.burning) { // Burning
var info = elements[pixel.element];
pixel.temp += 1;
pixelTempCheck(pixel);
var burnSpots = [
@ -4989,15 +5068,9 @@
}
}
}
// Change tempearture if needed (unused)
/*if (info.tempChange != undefined) {
pixel.temp += info.tempChange;
pixelTempCheck(pixel);
}*/
// Heat Transfer
if (info.insulate != true) {
function doHeat(pixel) {
// Check right and bottom adjacent pixels
var coordsToCheck = [
{x:pixel.x+1,y:pixel.y},
@ -5021,7 +5094,7 @@
}
}
// Electricity Transfer
function doElectricity(pixel) {
if (pixel.charge) {
// Check each adjacent pixel, if that pixel's charge is false, set it to the same charge
var coordsToCheck = [
@ -5066,9 +5139,8 @@
delete pixel.chargeCD;
}
}
}
function pixelColorPick(pixel,customColor=null) {
var element = pixel.element;
var elementInfo = elements[element];
@ -6152,14 +6224,15 @@ for (var k = 0; k < b0.split(" AND ").length; k++) {
// Loop through each element, final checks
for (key in elements) {
// If the element has no behavior, set it to behaviors.WALL
if (!elements[key].behavior) {
elements[key].behavior = behaviors.WALL;
if (!elements[key].behavior && !elements[key].tick) {
elements[key].tick = function(pixel) {};
}
// If the element has no color, set it to white
if (elements[key].color === undefined) {
elements[key].color = "rgb(255,255,255)";
elements[key].colorObject = {r:255,g:255,b:255};
}
if (elements[key].behavior) {
// If the element's behavior[1][1] includes "FX", set it's flippableX to true
if (elements[key].behavior[1][1].includes("FX")) {
elements[key].flippableX = true;
@ -6195,6 +6268,7 @@ for (var k = 0; k < b0.split(" AND ").length; k++) {
if (elements[key].behavior[1][1].includes("RT")) {
elements[key].rotatable = true;
}
}
// If the element has reactions, loop through each one (it is an object), if the value for elem1 or elem2 is not an element and is not null, remove that key
if (elements[key].reactions) {