diff --git a/mods/cannibal_cooking.js b/mods/cannibal_cooking.js new file mode 100644 index 00000000..273bbdcf --- /dev/null +++ b/mods/cannibal_cooking.js @@ -0,0 +1,620 @@ +elements.knife = { + color: ["#cbcdcd","#bdbdbd"], + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|M1 AND SM%0.005|XX", + ], + reactions: { + "head": { elem2:["brain","bone"], chance:0.5 }, + "body": { elem2:["heart","bone"], chance:0.5 }, + "decapitated_head": { elem2:["brain","bone"], chance:0.8 }, + "human_corpse": { elem2:["heart","bone"], chance:0.8 }, + "water": { elem1:"rust", chance:0.0025 }, + "salt_water": { elem1:"rust", chance:0.005 }, + "dirty_water": { elem1:"rust", chance:0.04 }, + "pool_water": { elem1:"rust", chance:0.04 }, + "sugar_water": { elem1:"rust", chance:0.0035 }, + "seltzer": { elem1:"rust", chance:0.006 }, + "salt": { elem1:"rust", chance:0.004 }, + "blood": { elem1:"rust", chance:0.003 }, + "infection": { elem1:"rust", chance:0.003 }, + "antibody": { elem1:"rust", chance:0.003 }, + "fire": { elem1:"rust", chance:0.0025 }, + "coffee": { elem1:"rust", chance:0.0003 }, + "tea": { elem1:"rust", chance:0.0003 }, + "broth": { elem1:"rust", chance:0.0003 }, + "juice": { elem1:"rust", chance:0.0003 }, + "nut_milk": { elem1:"rust", chance:0.0003 }, + }, + tempHigh: 1200, + stateHigh: ["molten_steel","molten_steel","ash","charcoal"], + category: "weapons", + density: 2500, + conduct: 0.15, + hardness: 0.2, + darkText: true +} + +elements.brain = { + color: ["#deb6c5","#F5CED5","#e87b8f"], + behavior: [ + "XX|XX|XX", + "XX|CH:rotten_human_flesh%0.00005|XX", + "M2%75|M1|M2%75", + ], + reactions: { + "dirty_water": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "fly": { "elem1":"rotten_human_flesh", "chance":0.2 }, + "dioxin": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "uranium": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "cancer": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "plague": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.3 }, + "ant": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "worm": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "rat": { "elem1":"rotten_human_flesh", "chance":0.3 }, + "mushroom_spore": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "mushroom_stalk": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "mercury": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.2 }, + "mercury_gas": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "virus": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "poison": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.5 }, + "infection": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "ink": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "acid": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.5 }, + "acid_gas": { "elem1":"rotten_human_flesh", "chance":0.4 }, + "cyanide": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.5 }, + }, + tempHigh: 100, + stateHigh: "cooked_brain", + tempLow: -18, + stateLow: "frozen_human_flesh", + category:"life", + hidden: true, + breakInto: ["human_flesh", "blood"], + burn:10, + burnTime:200, + burnInto:["cooked_brain","cooked_brain","cooked_brain","steam","salt"], + state: "solid", + density: 1081, + conduct: 1, +}; + +elements.heart = { + color: ["#e31b23","#98002e","#6f1200","#551900","#e31b23","#98002e","#6f1200","#551900","#e31b23","#98002e","#6f1200","#551900","#532e63"], + behavior: [ + "CR:blood%0.01|CR:blood%0.02|CR:blood%0.01", + "CR:blood%0.01|CH:rotten_human_flesh%0.00005|CR:blood%0.01", + "M2%75 AND CR:blood%0.02|M1 AND CR:blood%0.05|M2%75AND CR:blood%0.02", + ], + reactions: { + "dirty_water": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "fly": { "elem1":"rotten_human_flesh", "chance":0.2 }, + "dioxin": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "uranium": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "cancer": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "plague": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.3 }, + "ant": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "worm": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "rat": { "elem1":"rotten_human_flesh", "chance":0.3 }, + "mushroom_spore": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "mushroom_stalk": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "mercury": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.2 }, + "mercury_gas": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "virus": { "elem1":"rotten_human_flesh", "chance":0.1 }, + "poison": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.5 }, + "infection": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "ink": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.1 }, + "acid": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.5 }, + "acid_gas": { "elem1":"rotten_human_flesh", "chance":0.4 }, + "cyanide": { "elem1":"rotten_human_flesh", "elem2":null, "chance":0.5 }, +}, +tempHigh: 110, +stateHigh: "cooked_heart", +tempLow: -18, +stateLow: "frozen_human_flesh", +category:"life", +hidden: true, +breakInto: ["human_flesh","blood","blood"], +burn:10, +burnTime:200, +burnInto:["cooked_heart","cooked_heart","cooked_heart","blood"], +state: "solid", +density: 1075, +conduct: 1, +}; + +elements.sweet_blood = { + color: "#ff4040", + behavior: behaviors.LIQUID, + reactions: { + "yeast": { elem1:"alcohol", chance:0.005 }, + "plague": { elem1:"infection", elem2:null }, + "rotten_meat": { elem1:"infection" }, + "rotten_cheese": { elem1:"infection" }, + "virus": { elem1:"infection", elem2:null }, + "cancer": { elem1:"infection" }, + "cyanide": { elem1:"infection", elem2:null }, + "cyanide_gas": { elem1:"infection", elem2:null }, + "mushroom_spore": { elem1:"infection", elem2:null }, + "mushroom_gill": { elem1:"infection" }, + "dirty_water": { elem1:"infection", elem2:null }, + "rad_steam": { elem1:"infection" }, + "rad_glass": { elem1:"infection" }, + "rad_shard": { elem1:"infection" }, + "rad_cloud": { elem1:"infection" }, + "fallout": { elem1:"infection" }, + "rust": { elem1:"infection", chance:0.05 }, + "oxidized_copper": { elem1:"infection", chance:0.05 }, + "rat": { elem1:"infection", chance:0.075 }, + "flea": { elem1:"infection", chance:0.03 }, + "worm": { elem1:"infection", chance:0.03 }, + "mercury": { elem1:"infection", elem2:null, chance:0.05 }, + "lead": { elem1:"infection", elem2:null, chance:0.01 }, + "oxygen": { elem2:null, chance:0.05 }, + "carbon_dioxide": { elem2:null, chance:0.05 }, + "alcohol": { elem1:[null,"sugar","dna"], chance:0.02 } + }, + viscosity: 12, + tempHigh: 120, + stateHigh: ["steam","sugar","oxygen","steam","sugar","oxygen","steam","salt","oxygen"], + tempLow: -5, + stateLow: "candy", + category:"food", + state: "liquid", + density: 1080, + stain: 0.05, + isFood: true, + hidden: true +} + +elements.mellified_man = { + color: ["#f4f8db","#f8fbd0","#fbebba","#e8ce96","#b18f56","#936d43","#715234","#4b422a"], + behavior: [ + "XX|CR:honey%0.0001|XX", + "CR:honey%0.0001|XX|CR:honey%0.0001", + "XX|M1 AND CR:honey%0.0001|XX", + ], + reactions: { + "water": { elem2:"sugar_water", tempMin:70, color2:"#d7db69" }, + "salt_water": { elem2:"sugar_water", tempMin:70, color2:"#d7db69"}, + "sugar_water": { elem2:"sugar_water", tempMin:70, color2:"#d7db69" }, + "seltzer": { elem2:"sugar_water", tempMin:70, color2:"#d7db69" }, + }, + tempHigh: 200, + stateHigh: ["cooked_human","cooked_human","honey",], + category:"food", + burn:15, + burnTime:200, + burnInto:["cooked_human","cooked_human","honey",], + breakInto: ["blood","human_flesh","bone","honey","human_flesh","bone"], + state: "solid", + density: 1020, + conduct: 0.1, + isFood: true, + hidden: true +} + +elements.human_flesh = { + color: ["#9e4839","#ba6449","#d2856c","#a14940"], + behavior: [ + "XX|XX|XX", + "SP|XX|SP", + "XX|M1|XX", + ], + reactions: { + "honey": { elem1:"mellified_man", elem2:["honey","honey",null], chance:0.0001 }, + "dirty_water": { elem1:"rotten_human_flesh", chance:0.1 }, + "fly": { elem1:"rotten_human_flesh", chance:0.2 }, + "dioxin": { elem1:"rotten_human_flesh", elem2:null, chance:0.1 }, + "uranium": { elem1:"rotten_human_flesh", chance:0.1 }, + "cancer": { elem1:"rotten_human_flesh", chance:0.1 }, + "plague": { elem1:"rotten_human_flesh", elem2:null, chance:0.3 }, + "ant": { elem1:"rotten_human_flesh", chance:0.1 }, + "worm": { elem1:"rotten_human_flesh", chance:0.1 }, + "rat": { elem1:"rotten_human_flesh", chance:0.3 }, + "mushroom_spore": { elem1:"rotten_human_flesh", chance:0.1 }, + "mushroom_stalk": { elem1:"rotten_human_flesh", chance:0.1 }, + "mycelium": { elem1:"rotten_human_flesh", chance:0.1 }, + "hyphae": { elem1:"rotten_human_flesh", chance:0.1 }, + "mercury": { elem1:"rotten_human_flesh", elem2:null, chance:0.2 }, + "mercury_gas": { elem1:"rotten_human_flesh", elem2:null, chance:0.1 }, + "virus": { elem1:"rotten_human_flesh", chance:0.1 }, + "poison": { elem1:"rotten_human_flesh", elem2:null, chance:0.5 }, + "infection": { elem1:"rotten_human_flesh", elem2:null, chance:0.1 }, + "ink": { elem1:"rotten_human_flesh", elem2:null, chance:0.1 }, + "acid": { elem1:"rotten_human_flesh", elem2:null, chance:0.5 }, + "acid_gas": { elem1:"rotten_human_flesh", chance:0.4 }, + "cyanide": { elem1:"rotten_human_flesh", elem2:null, chance:0.5 }, + "cyanide_gas": { elem1:"rotten_human_flesh", elem2:null, chance:0.5 }, + "rotten_cheese": { elem1:"rotten_human_flesh", chance:0.02 }, + "fallout": { elem1:"rotten_human_flesh", chance:0.2 }, + "water": { elem2:"broth", tempMin:70 }, + "salt_water": { elem2:"broth", tempMin:70 }, + "sugar_water": { elem2:"broth", tempMin:70 }, + "seltzer": { elem2:"broth", tempMin:70 }, + "salt": { elem1:"cured_human_flesh" }, + "vinegar": { elem1:"cured_human_flesh", chance:0.1 }, + }, + tempHigh: 100, + stateHigh: "cooked_human", + tempLow: -18, + stateLow: "frozen_human_flesh", + category:"food", + burn:15, + burnTime:200, + burnInto:"cooked_human", + state: "solid", + density: 1050, + conduct: 0.2, + isFood: true, + hidden: true +} + +elements.cooked_brain = { + color: ["#C37C6E","#B77269","#AE625C"], + behavior: behaviors.STURDYPOWDER, + tick: function(pixel) { + if (pixel.temp > 100 && Math.random() < 0.0025 && isEmpty(pixel.x,pixel.y-1)) { + changePixel(pixel,"grease") + } + }, + reactions: { + "water": { elem2:"broth", tempMin:70 }, + "salt_water": { elem2:"broth", tempMin:70 }, + "sugar_water": { elem2:"broth", tempMin:70 }, + "dirty_water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "seltzer": { elem2:"broth", tempMin:70 } + }, + tempHigh: 300, + stateHigh: "ash", + category:"food", + hidden:true, + burn:10, + burnTime:200, + burnInto: "ash", + state: "solid", + density: 1005, + isFood: true +} + +elements.cooked_heart = { + color: ["#A44447","#9A4546","#8A2A30"], + behavior: behaviors.STURDYPOWDER, + tick: function(pixel) { + if (pixel.temp > 100 && Math.random() < 0.0025 && isEmpty(pixel.x,pixel.y-1)) { + changePixel(pixel,"grease") + } + }, + reactions: { + "water": { elem2:"broth", tempMin:70 }, + "salt_water": { elem2:"broth", tempMin:70 }, + "sugar_water": { elem2:"broth", tempMin:70 }, + "dirty_water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "seltzer": { elem2:"broth", tempMin:70 } + }, + tempHigh: 300, + stateHigh: "ash", + category:"food", + hidden:true, + burn:10, + burnTime:200, + burnInto: "ash", + state: "solid", + density: 1005, + isFood: true +} + +elements.cooked_human = { + color: ["#ae7d5b","#9b6d54","#7e4d31"], + behavior: behaviors.STURDYPOWDER, + tick: function(pixel) { + if (pixel.temp > 100 && Math.random() < 0.0025 && isEmpty(pixel.x,pixel.y-1)) { + changePixel(pixel,"grease") + } + }, + reactions: { + "water": { elem2:"broth", tempMin:70 }, + "salt_water": { elem2:"broth", tempMin:70 }, + "sugar_water": { elem2:"broth", tempMin:70 }, + "dirty_water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "seltzer": { elem2:"broth", tempMin:70 } + }, + tempHigh: 300, + stateHigh: "ash", + category:"food", + hidden:true, + burn:10, + burnTime:200, + burnInto: "ash", + state: "solid", + density: 1005, + isFood: true +} + +elements.frozen_human_flesh = { + color: ["#399e8f","#49baa9","#6cd2c6","#40a197"], + behavior: behaviors.STURDYPOWDER, + temp: -18, + tempHigh: 0, + stateHigh: "human_flesh", + category:"food", + hidden:true, + state: "solid", + density: 1070, + isFood: true +} + +elements.rotten_human_flesh = { + color: ["#b8b165","#b89765"], + behavior: [ + "XX|CR:plague,stench,stench,stench,fly%0.25 AND CH:meat>rotten_meat%1 AND CH:human_flesh>rotten_human_flesh%1|XX", + "SP%99 AND CH:meat>rotten_meat%1 AND CH:human_flesh>rotten_human_flesh%1|XX|SP%99 AND CH:meat>rotten_meat%1 AND CH:human_flesh>rotten_human_flesh%1", + "XX|M1 AND CH:meat>rotten_meat%1 AND CH:human_flesh>rotten_human_flesh%1|XX", + ], + reactions: { + "water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "salt_water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "sugar_water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "dirty_water": { elem2:"broth", tempMin:70, color2:"#d7db69" }, + "seltzer": { elem2:"broth", tempMin:70, color2:"#d7db69" } + }, + tempHigh: 300, + stateHigh: ["plague","ash","ammonia"], + category:"food", + hidden: true, + burn:12, + burnTime:200, + burnInto:["plague","ash","ammonia"], + state: "solid", + density: 1005, + conduct: 0.1, + isFood: true +} + +elements.cured_human_flesh = { + name: "cured_meat", + color: ["#be5c4b","#c8846f","#dda592","#bc6157"], + behavior: [ + "XX|XX|XX", + "SP|XX|SP", + "XX|M1|XX", + ], + reactions: { + "honey": { elem1:"mellified_man", elem2:["honey","honey",null], chance:0.0001 }, + "water": { elem2:"broth", tempMin:70 }, + "salt_water": { elem2:"broth", tempMin:70 }, + "sugar_water": { elem2:"broth", tempMin:70 }, + "seltzer": { elem2:"broth", tempMin:70 }, + }, + tempHigh: 100, + stateHigh: "cooked_human", + category:"food", + burn:15, + burnTime:200, + burnInto:"cooked_human", + state: "solid", + density: 1019.5, + conduct: 0.3, + isFood: true, + hidden: true +} + +elements.human_corpse = { + color: ["#069469","#047e99","#7f5fb0"], + behavior: [ + "XX|XX|XX", + "XX|CH:rotten_human_flesh%0.0001|XX", + "XX|M1|XX", + ], + tick: function(pixel) { + if (isEmpty(pixel.x, pixel.y-1)) { + if (Math.random() < 0.01 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y-1); + } + } + }, + category: "life", + hidden: true, + density: 1500, + state: "solid", + conduct: .05, + temp: 37, + tempHigh: 200, + stateHigh: "cooked_human", + tempLow: -30, + stateLow: "frozen_human_flesh", + burn: 10, + burnTime: 250, + burnInto: "cooked_human", + breakInto: ["blood","human_flesh","bone"], + forceSaveColor: true, + reactions: { + "honey": { elem1:"mellified_man", elem2:["honey","honey",null], chance:0.0005 }, + "cancer": { elem1:"cancer", chance:0.005 }, + "radiation": { elem1:["ash","human_flesh","rotten_human_flesh","cooked_human"], chance:0.4 }, + "neutron": { elem1:["ash","human_flesh","rotten_human_flesh","cooked_human"], chance:0.01 }, + "fallout": { elem1:["ash","human_flesh","rotten_human_flesh","cooked_human"], chance:0.01 }, + "plague": { elem1:["plague","plague","rotten_human_flesh"], chance:0.05 }, + "stink_bug": { elem2:"stench", oneway:true }, + "sun": { elem1:"cooked_human" }, + }, +} + +elements.decapitated_head = { + color: ["#f3e7db","#f7ead0","#eadaba","#d7bd96","#a07e56","#825c43","#604134","#3a312a"], + behavior: [ + "XX|XX|XX", + "XX|CH:rotten_human_flesh%0.0001|XX", + "M2%90|M1|M2%90", + ], + tick: function(pixel) { + if (tryMove(pixel, pixel.x, pixel.y+1)) { + if (isEmpty(pixel.x, pixel.y+1) && Math.random() < 0.01) { + createPixel("blood", pixel.x, pixel.y+1); + } + } + }, + category: "life", + hidden: true, + density: 1080, + state: "solid", + conduct: .05, + temp: 37, + tempHigh: 200, + stateHigh: "cooked_human", + tempLow: -30, + stateLow: "frozen_human_flesh", + burn: 10, + burnTime: 250, + burnInto: "cooked_human", + breakInto: ["blood","human_flesh","bone"], + forceSaveColor: true, + reactions: { + "honey": { elem1:"mellified_man", elem2:["honey","honey",null], chance:0.0005 }, + "cancer": { elem1:"cancer", chance:0.005 }, + "radiation": { elem1:["ash","human_flesh","rotten_human_flesh","cooked_human"], chance:0.4 }, + "neutron": { elem1:["ash","human_flesh","rotten_human_flesh","cooked_human"], chance:0.03 }, + "fallout": { elem1:["ash","human_flesh","rotten_human_flesh","cooked_human"], chance:0.03 }, + "plague": { elem1:"plague", chance:0.05 }, + "sun": { elem1:"cooked_human" }, + "light": { stain1:"#825043" }, + }, +} + +elements.head.tick = function(pixel) { + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + pixel.element = "decapitated_head"; + return + } + } + + // Find the body + if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == "body") { + var body = pixelMap[pixel.x][pixel.y+1]; + if (body.dead) { // If body is dead, kill head + pixel.dead = body.dead; + } + } + else { var body = null } + + if (tryMove(pixel, pixel.x, pixel.y+1)) { + // create blood if severed 10% chance + if (isEmpty(pixel.x, pixel.y+1) && !pixel.dead && Math.random() < 0.1 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y+1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } +} + +elements.body.tick = function(pixel) { + if (tryMove(pixel, pixel.x, pixel.y+1)) { // Fall + if (!isEmpty(pixel.x, pixel.y-2, true)) { // Drag head down + var headpixel = pixelMap[pixel.x][pixel.y-2]; + if (headpixel.element == "head") { + if (isEmpty(pixel.x, pixel.y-1)) { + movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); + } + else { + swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); + } + } + } + } + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + pixel.element = "human_corpse"; + } + return + } + + // Find the head + if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "head") { + var head = pixelMap[pixel.x][pixel.y-1]; + if (head.dead) { // If head is dead, kill body + pixel.dead = head.dead; + } + } + else { var head = null } + if (pixel.burning) { + pixel.panic += 0.1; + if (head && pixelTicks-pixel.burnStart > 240) { + pixel.color = head.color; + } + } + else if (pixel.panic > 0) { + pixel.panic -= 0.1; + } + + if (isEmpty(pixel.x, pixel.y-1)) { + // create blood if decapitated 10% chance + if (Math.random() < 0.1 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y-1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + else if (head == null) { return } + else if (Math.random() < 0.1*(isEmpty(pixel.x, pixel.y+1) ? 1 : pixel.panic+1)) { // Move 10% chance + var movesToTry = [ + [1*pixel.dir,0], + [1*pixel.dir,-1], + ]; + // While movesToTry is not empty, tryMove(pixel, x, y) with a random move, then remove it. if tryMove returns true, break. + while (movesToTry.length > 0) { + var move = movesToTry.splice(Math.floor(Math.random() * movesToTry.length), 1)[0]; + if (isEmpty(pixel.x+move[0], pixel.y+move[1]-1)) { + var origx = pixel.x+move[0]; + var origy = pixel.y+move[1]; + if (tryMove(pixel, pixel.x+move[0], pixel.y+move[1]) && pixel.x===origx && pixel.y===origy) { + movePixel(head, head.x+move[0], head.y+move[1]); + break; + } + } + } + // 15% chance to change direction + if (Math.random() < 0.15) { + pixel.dir *= -1; + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } + } +} + +elements.body.stateHigh = "cooked_human" +elements.head.stateHigh = "cooked_human" + +elements.body.breakInto = ["blood","human_flesh","bone","blood","human_flesh","bone","blood","heart","bone",] +elements.head.breakInto = ["blood","brain","bone"] + +elements.body.stateLow = "frozen_human_flesh" +elements.head.stateLow = "frozen_human_flesh" + +if (!elements.blood.reactions) { elements.blood.reactions = {} } + elements.blood.reactions.caramel = { "elem1": "sweet_blood", "elem2": null, chance:0.001 }; + elements.blood.reactions.sugar = { "elem1": "sweet_blood", "elem2": null, chance:0.0005}; + +if (!elements.head.reactions) { elements.head.reactions = {} } + elements.head.reactions.human_flesh = { "elem2": null, chance:0.01 }; + elements.head.reactions.cooked_human = { "elem2": null, chance:0.05 }; + elements.head.reactions.cooked_brain = { "elem2": null, chance:0.03 }; + elements.head.reactions.cooked_heart = { "elem2": null, chance:0.04 }; + diff --git a/mods/sandboxels.js b/mods/sandboxels.js index efdc014f..3d1a6daf 100644 --- a/mods/sandboxels.js +++ b/mods/sandboxels.js @@ -1,3 +1,394 @@ +/* mod by nekonico */ + +window.addEventListener("load", () => { + document.getElementById("elementButton-sandboxels_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-sand_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-rock_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-wall_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-water_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-steam_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-ice_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-wood_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-saw_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-cellulose_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-blood_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-paper_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-body_screen")?.remove() +}) + +window.addEventListener("load", () => { + document.getElementById("elementButton-head_screen")?.remove() +}) + +elements.danger_suit = { + color: ["#A8A7AB","#878689"], + behavior: behaviors.STURDYPOWDER, + reactions: { + "radiation": { elem2:"electric", temp1:200 }, + "body":{ elem1:null, elem2:"suited_body" }, + }, + tempHigh: 500, + stateHigh: ["molten_aluminum","smoke","ash"], + burn: 10, + burnTime: 300, + burnInto: ["molten_aluminum","smoke","smoke","smoke","ash"], + category: "simulation", + state: "solid", + density: 2710, + conduct: 0.73, + hardness: 0.05, + breakInto: "metal_scrap", + fireColor: "#A7B3BF", + superconductAt: -271.95 +}, + +elements.danger_helmet = { + color: ["#323233","#434344"], + behavior: behaviors.STURDYPOWDER, + reactions: { + "head":{ elem1:null, elem2:"suited_head" }, + }, + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_plastic"], + burn: 10, + burnTime: 200, + burnInto: ["glass_shard","glass_shard","glass_shard","glass_shard","dioxin","smoke","dioxin","smoke","stench"], + category: "simulation", + state: "solid", + density: 2500, + breakInto: "glass_shard", +}, + +elements.suited_body = { + color: ["#A8A7AB","#878689"], + category: "life", + hidden: true, + density: 2710, + state: "solid", + conduct: .05, + temp: 37, + tempHigh: 300, + stateHigh: ["cooked_meat","cooked_meat","cooked_meat","cooked_meat","ash"], + tempLow: -75, + stateLow: "frozen_meat", + burn: 10, + burnTime: 250, + burnInto: ["cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","molten_aluminum","smoke","smoke","smoke","ash"], + breakInto: ["blood","meat","bone"], + forceSaveColor: true, + reactions: { + "egg": { elem2:"yolk", chance:0.5, oneway:true }, + "grape": { elem2:"juice", chance:0.5, color2:"#291824", oneway:true }, + "ant": { elem2:"dead_bug", chance:0.05, oneway:true }, + "fly": { elem2:"dead_bug", oneway:true }, + "firefly": { elem2:"dead_bug", oneway:true }, + "bee": { elem2:"dead_bug", oneway:true }, + "flea": { elem2:"dead_bug", oneway:true }, + "termite": { elem2:"dead_bug", oneway:true }, + "worm": { elem2:"slime", chance:0.05, oneway:true }, + "stink_bug": { elem2:"stench", oneway:true }, + "gold_coin": { elem2:null, chance:0.05 }, + "diamond": { elem2:null, chance:0.05 }, + "sun": { elem1:"cooked_meat" }, + }, + properties: { + dead: false, + dir: 1, + panic: 0 + }, + tick: function(pixel) { + if (tryMove(pixel, pixel.x, pixel.y+1)) { // Fall + if (!isEmpty(pixel.x, pixel.y-2, true)) { // Drag head down + var headpixel = pixelMap[pixel.x][pixel.y-2]; + if (headpixel.element == "head") { + if (isEmpty(pixel.x, pixel.y-1)) { + movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); + } + else { + swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); + } + } + if (headpixel.element == "suited_head") { + if (isEmpty(pixel.x, pixel.y-1)) { + movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); + } + else { + swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); + } + } + } + } + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + changePixel(pixel,"rotten_meat"); + } + return + } + + // Find the head + if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "head") { + var head = pixelMap[pixel.x][pixel.y-1]; + if (head.dead) { // If head is dead, kill body + pixel.dead = head.dead; + } + } + else if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "suited_head") { + var head = pixelMap[pixel.x][pixel.y-1]; + if (head.dead) { // If head is dead, kill body + pixel.dead = head.dead; + } + } + else { var head = null } + if (pixel.burning) { + pixel.panic += 0.1; + if (head && pixelTicks-pixel.burnStart > 240) { + pixel.color = head.color; + } + } + else if (pixel.panic > 0) { + pixel.panic -= 0.1; + } + + if (isEmpty(pixel.x, pixel.y-1)) { + // create blood if decapitated 10% chance + if (Math.random() < 0.1 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y-1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + else if (head == null) { return } + else if (Math.random() < 0.1*(isEmpty(pixel.x, pixel.y+1) ? 1 : pixel.panic+1)) { // Move 10% chance + var movesToTry = [ + [1*pixel.dir,0], + [1*pixel.dir,-1], + ]; + // While movesToTry is not empty, tryMove(pixel, x, y) with a random move, then remove it. if tryMove returns true, break. + while (movesToTry.length > 0) { + var move = movesToTry.splice(Math.floor(Math.random() * movesToTry.length), 1)[0]; + if (isEmpty(pixel.x+move[0], pixel.y+move[1]-1)) { + var origx = pixel.x+move[0]; + var origy = pixel.y+move[1]; + if (tryMove(pixel, pixel.x+move[0], pixel.y+move[1]) && pixel.x===origx && pixel.y===origy) { + movePixel(head, head.x+move[0], head.y+move[1]); + break; + } + } + } + // 15% chance to change direction + if (Math.random() < 0.15) { + pixel.dir *= -1; + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } + } + + } +}, + +elements.suited_head = { + color: ["#46433F","#47443C","#4D483D"], + category: "life", + hidden: true, + density: 1080, + state: "solid", + conduct: .05, + temp: 37, + tempHigh: 300, + stateHigh: ["cooked_meat","cooked_meat","cooked_meat","cooked_meat","glass_shard"], + tempLow: -75, + stateLow: "frozen_meat", + burn: 10, + burnTime: 250, + burnInto: ["cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","melted_plastic","glass_shard"], + breakInto: ["blood","meat","bone","blood","meat","bone","glass_shard"], + forceSaveColor: true, + reactions: { + "oxygen": { elem2:"carbon_dioxide", chance:0.5 }, + "sun": { elem1:"cooked_meat" }, + "water": { elem2:"bubble", attr2:{"clone":"water"}, chance:0.001 }, + "salt_water": { elem2:"bubble", attr2:{"clone":"salt_water"}, chance:0.001 }, + "pool_water": { elem2:"bubble", attr2:{"clone":"pool_water"}, chance:0.001 }, + }, + properties: { + dead: false + }, + tick: function(pixel) { + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + changePixel(pixel,"rotten_meat"); + return + } + } + + // Find the body + if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == "body") { + var body = pixelMap[pixel.x][pixel.y+1]; + if (body.dead) { // If body is dead, kill head + pixel.dead = body.dead; + } + } + else if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == "suited_body") { + var body = pixelMap[pixel.x][pixel.y+1]; + if (body.dead) { // If body is dead, kill head + pixel.dead = body.dead; + } + } + else { var body = null } + + if (tryMove(pixel, pixel.x, pixel.y+1)) { + // create blood if severed 10% chance + if (isEmpty(pixel.x, pixel.y+1) && !pixel.dead && Math.random() < 0.1 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y+1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } + } +}, + +elements.digitalizer = { + color: ["#d1c6be","#b5c0ad","#b9b8bc"], + behavior: behaviors.WALL, + onSelect: function() { + logMessage("Do not digitalize unregistered elements!"); + }, + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], + conduct: 1, + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sand"], + tempLow: -80, + stateLow: "glass_shard", + category: "simulation", + tick: function(pixel) { + if (!isEmpty(pixel.x,pixel.y-1,true) && !isEmpty(pixel.x,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x][pixel.y-1]; + var screen = pixelMap[pixel.x][pixel.y+1]; + if (screen.element === "sandboxels_screen") { + if (newPixel.element === "sand" && screen.element === "sandboxels_screen") { + changePixel(screen,"sand_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "ice" && screen.element === "sandboxels_screen") { + changePixel(screen,"ice_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "steam" && screen.element === "sandboxels_screen") { + changePixel(screen,"steam_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "water" && screen.element === "sandboxels_screen") { + changePixel(screen,"water_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "wood" && screen.element === "sandboxels_screen") { + changePixel(screen,"wood_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "paper" && screen.element === "sandboxels_screen") { + changePixel(screen,"paper_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "sawdust" && screen.element === "sandboxels_screen") { + changePixel(screen,"saw_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "cellulose" && screen.element === "sandboxels_screen") { + changePixel(screen,"cellulose_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "blood" && screen.element === "sandboxels_screen") { + changePixel(screen,"blood_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "body" && screen.element === "sandboxels_screen") { + changePixel(screen,"blood_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "head" && screen.element === "sandboxels_screen") { + changePixel(screen,"blood_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "rock" && screen.element === "sandboxels_screen") { + changePixel(screen,"rock_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (newPixel.element === "wall" && screen.element === "sandboxels_screen") { + changePixel(screen,"wall_screen"); + deletePixel(newPixel.x,newPixel.y) + } + else if (!isEmpty(pixel.x,pixel.y-2,true) && newPixel.element === "suited_body" && screen.element === "sandboxels_screen") { + var headPixel = pixelMap[pixel.x][pixel.y-2]; + if (headPixel.element === "suited_head" && newPixel.element === "suited_body" && screen.element === "sandboxels_screen") { + changePixel(screen,"simulated_human"); + deletePixel(newPixel.x,newPixel.y-1) + deletePixel(newPixel.x,newPixel.y) + } + } + else { + changePixel(screen,"malware"); + deletePixel(newPixel.x,newPixel.y) + } + } + } + }, + state: "solid", + density: 1200, + desc: "simulatedizes elements." +}, + elements.sandboxels_screen_off = { name:"screen", color: "#454545", @@ -10,10 +401,10 @@ elements.sandboxels_screen_off = { tempHigh: 1500, stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], conduct: 1, - breakInto: "glass_shard", + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sand"], tempLow: -80, stateLow: "glass_shard", - category: "digital", + category: "simulation", state: "solid", density: 1200, desc: "Shock to turn on." @@ -31,14 +422,43 @@ elements.sandboxels_screen = { tempHigh: 1500, stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], conduct: 1, - breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sand"], + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sand"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", state: "solid", density: 1200, }, - + +elements.simulated_human = { + hidden:true, + color: ["#46433F","#47443C","#4D483D"], + category: "simulation", + properties: { + dead: false, + dir: 1, + panic: 0 + }, + tick: function(pixel) { + if (!isEmpty(pixel.x, pixel.y+1),true && pixelMap[pixel.x][pixel.y+1].element === "sandboxels_screen") { + var newPixel = pixelMap[pixel.x][pixel.y+1]; + newPixel.element = "body_screen"; + pixel.element = "head_screen"; + } + else if (!isEmpty(pixel.x, pixel.y-1),true && pixelMap[pixel.x][pixel.y-1].element === "sandboxels_screen") { + var newPixel = pixelMap[pixel.x][pixel.y-1]; + newPixel.element = "head_screen"; + pixel.element = "body_screen"; + } + else { + changePixel(pixel, "sandboxels_screen"); + } + }, + related: ["suited_body","suited_head"], + cooldown: defaultCooldown, + forceSaveColor: true, +}, + elements.sand_screen = { name:"screen", hidden:true, @@ -57,7 +477,7 @@ elements.sand_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sand"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (!isEmpty(pixel.x,pixel.y+1,true)) { var newPixel = pixelMap[pixel.x][pixel.y+1]; @@ -73,6 +493,12 @@ elements.sand_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"sand_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -81,6 +507,24 @@ elements.sand_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + changePixel(newPixel,"sand_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"cellulose_screen"); + } else if (newPixel.element === "rock_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -99,6 +543,12 @@ elements.sand_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"sand_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -107,6 +557,24 @@ elements.sand_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + changePixel(newPixel,"sand_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"cellulose_screen"); + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -130,6 +598,12 @@ elements.sand_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"sand_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -138,6 +612,24 @@ elements.sand_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + changePixel(newPixel,"sand_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"cellulose_screen"); + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -171,7 +663,7 @@ elements.rock_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","rock"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (!isEmpty(pixel.x,pixel.y+1,true)) { var newPixel = pixelMap[pixel.x][pixel.y+1]; @@ -187,17 +679,21 @@ elements.rock_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } - else if (newPixel.element === "ice_screen") { - newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"rock_screen"); pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); } else if (newPixel.element === "steam_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } - else if (newPixel.element === "sand_screen") { - newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + else if (newPixel.element === "cellulose_screen") { + changePixel(newPixel,"rock_screen"); pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"cellulose_screen"); } else if (Math.random() > 0.5 && !isEmpty(pixel.x+1,pixel.y+1,true)) { var newPixel = pixelMap[pixel.x+1][pixel.y+1]; @@ -213,6 +709,12 @@ elements.rock_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"rock_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -221,6 +723,24 @@ elements.rock_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + changePixel(newPixel,"rock_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"cellulose_screen"); + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -244,6 +764,12 @@ elements.rock_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"rock_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -252,6 +778,24 @@ elements.rock_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + changePixel(newPixel,"rock_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"cellulose_screen"); + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -270,7 +814,7 @@ elements.rock_screen = { elements.saw_screen = { name:"screen", hidden:true, - color: "#e6d577", + color: ["#dec150","#c7b15a"], behavior: [ "XX|XX|XX", "XX|XX|XX", @@ -282,10 +826,10 @@ elements.saw_screen = { tempHigh: 1500, stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], conduct: 1, - breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sand"], + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","sawdust"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (!isEmpty(pixel.x,pixel.y+1,true)) { var newPixel = pixelMap[pixel.x][pixel.y+1]; @@ -301,19 +845,11 @@ elements.saw_screen = { newPixel.dtemp = pixel.dtemp; changePixel(pixel,"water_screen"); } - else if (newPixel.element === "ice_screen") { - newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); - pixel.dtemp = newPixel.dtemp; - } else if (newPixel.element === "steam_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } - else if (newPixel.element === "sand_screen") { - newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); - pixel.dtemp = newPixel.dtemp; - } - else if (newPixel.element === "rock_screen") { + else if (newPixel.element === "cellulose_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } @@ -339,10 +875,22 @@ elements.saw_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -374,10 +922,22 @@ elements.saw_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -396,7 +956,7 @@ elements.saw_screen = { elements.cellulose_screen = { name:"screen", hidden:true, - color: "#2167ff", + color: "#c7d4c9", behavior: [ "XX|XX|XX", "SW:sandboxels_screen|XX|SW:sandboxels_screen", @@ -408,10 +968,10 @@ elements.cellulose_screen = { tempHigh: 1500, stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], conduct: 1, - breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","water"], + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","cellulose"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (Math.random() > 0.2 && !isEmpty(pixel.x,pixel.y+1,true)) { var newPixel = pixelMap[pixel.x][pixel.y+1]; @@ -421,6 +981,18 @@ elements.cellulose_screen = { changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -429,6 +1001,14 @@ elements.cellulose_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -449,6 +1029,18 @@ elements.cellulose_screen = { changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -457,9 +1049,17 @@ elements.cellulose_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { - newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); - pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); @@ -478,6 +1078,18 @@ elements.cellulose_screen = { changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -486,6 +1098,14 @@ elements.cellulose_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -508,6 +1128,18 @@ elements.cellulose_screen = { changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -516,6 +1148,14 @@ elements.cellulose_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -537,6 +1177,18 @@ elements.cellulose_screen = { changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "blood_screen") { + changePixel(newPixel,"cellulose_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"blood_screen"); + } else if (newPixel.element === "ice_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -545,6 +1197,14 @@ elements.cellulose_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -558,7 +1218,298 @@ elements.cellulose_screen = { pixel.dtemp = newPixel.dtemp; } } - if (pixel.dtemp > 199) { changePixel(pixel,"steam_screen") } + if (pixel.dtemp > 99) { changePixel(pixel,"paper_screen") } + }, + state: "solid", + density: 1200, +}, + +elements.blood_screen = { + name:"screen", + hidden:true, + color: ["#ff0000","#ee0000"], + behavior: [ + "XX|XX|XX", + "SW:sandboxels_screen|XX|SW:sandboxels_screen", + "SW:sandboxels_screen|XX|SW:sandboxels_screen", + ], + properties: { + dtemp: 20, + }, + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], + conduct: 1, + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","blood"], + tempLow: -45, + stateLow: "sandboxels_screen_off", + category: "simulation", + tick: function(pixel) { + if (Math.random() > 0.2 && !isEmpty(pixel.x,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x][pixel.y+1]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"blood_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"blood_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "sand_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (Math.random() > 0.5 && !isEmpty(pixel.x+1,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x+1][pixel.y+1]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"blood_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"blood_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "sand_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + } + else if (!isEmpty(pixel.x-1,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x-1][pixel.y+1]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"blood_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"blood_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "sand_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + } + } + else if (Math.random() > 0.5 && !isEmpty(pixel.x+1,pixel.y,true)) { + var newPixel = pixelMap[pixel.x+1][pixel.y]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"blood_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"blood_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "sand_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + } + else if (!isEmpty(pixel.x-1,pixel.y,true)) { + var newPixel = pixelMap[pixel.x-1][pixel.y]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"blood_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "water_screen") { + changePixel(newPixel,"blood_screen"); + pixel.dtemp = newPixel.dtemp; + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"water_screen"); + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "sand_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + } + if (pixel.dtemp > 124) { changePixel(pixel,"steam_screen") } }, state: "solid", density: 1200, @@ -582,7 +1533,7 @@ elements.water_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","water"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (Math.random() > 0.2 && !isEmpty(pixel.x,pixel.y+1,true)) { var newPixel = pixelMap[pixel.x][pixel.y+1]; @@ -600,12 +1551,30 @@ elements.water_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { changePixel(newPixel,"cellulose_screen"); newPixel.dtemp = pixel.dtemp; changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -630,12 +1599,30 @@ elements.water_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { changePixel(newPixel,"cellulose_screen"); newPixel.dtemp = pixel.dtemp; changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -661,12 +1648,30 @@ elements.water_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { changePixel(newPixel,"cellulose_screen"); newPixel.dtemp = pixel.dtemp; changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -693,12 +1698,30 @@ elements.water_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { changePixel(newPixel,"cellulose_screen"); newPixel.dtemp = pixel.dtemp; changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -724,12 +1747,30 @@ elements.water_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "saw_screen") { changePixel(newPixel,"cellulose_screen"); newPixel.dtemp = pixel.dtemp; changePixel(pixel,"sandboxels_screen"); pixel.dtemp = 0; } + else if (newPixel.element === "paper_screen") { + changePixel(newPixel,"cellulose_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } else if (newPixel.element === "sand_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -764,7 +1805,7 @@ elements.steam_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","steam"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (Math.random() > 0.75 && !isEmpty(pixel.x+1,pixel.y-1,true)) { var newPixel = pixelMap[pixel.x+1][pixel.y-1]; @@ -777,6 +1818,26 @@ elements.steam_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "water_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -801,6 +1862,26 @@ elements.steam_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "water_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -825,6 +1906,26 @@ elements.steam_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "water_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -849,6 +1950,22 @@ elements.steam_screen = { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } else if (newPixel.element === "water_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -868,6 +1985,227 @@ elements.steam_screen = { density: 1200, }, +elements.body_screen = { + color: ["#A8A7AB","#878689"], + name:"screen", + hidden:true, + behavior: [ + "XX|CH:sandboxels_screen>blood_screen%0.1|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + properties: { + dtemp: 20, + }, + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], + conduct: 1, + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","body"], + tempLow: -45, + stateLow: "sandboxels_screen_off", + category: "simulation", + tick: function(pixel) { + if (!isEmpty(pixel.x,pixel.y-1,true) && pixelMap[pixel.x][pixel.y-1].element === "head_screen") { + var headPixel = pixelMap[pixel.x][pixel.y-1] + if (!isEmpty(pixel.x,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x][pixel.y+1] + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"body_screen") + newPixel.dtemp = pixel.dtemp + changePixel(pixel,"head_screen") + pixel.dtemp = headPixel.dtemp + } + else if (newPixel.element === "water_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2) + pixel.dtemp = newPixel.dtemp + } + } + else if (Math.random() < 0.01 && !isEmpty(pixel.x+1,pixel.y,true) && !isEmpty(pixel.x+1,pixel.y-1,true)) { + var newPixel = pixelMap[pixel.x+1][pixel.y]; + var newHeadPixel = pixelMap[pixel.x+1][pixel.y-1]; + if (newPixel.element === "sandboxels_screen" && newHeadPixel.element === "sandboxels_screen") { + changePixel(pixel,"sandboxels_screen"); + changePixel(headPixel,"sandboxels_screen"); + changePixel(newPixel,"body_screen"); + changePixel(newHeadPixel,"head_screen"); + newPixel.dtemp = pixel.dtemp; + newHeadPixel.dtemp = headPixel.dtemp; + pixel.dtemp = 0; + headPixel.dtemp = 0; + } + } + else if (Math.random() < 0.01 && !isEmpty(pixel.x-1,pixel.y,true) && !isEmpty(pixel.x-1,pixel.y-1,true)) { + var newPixel = pixelMap[pixel.x-1][pixel.y]; + var newHeadPixel = pixelMap[pixel.x-1][pixel.y-1]; + if (newPixel.element === "sandboxels_screen" && newHeadPixel.element === "sandboxels_screen") { + changePixel(pixel,"sandboxels_screen"); + changePixel(headPixel,"sandboxels_screen"); + changePixel(newPixel,"body_screen"); + changePixel(newHeadPixel,"head_screen"); + newPixel.dtemp = pixel.dtemp; + newHeadPixel.dtemp = headPixel.dtemp; + pixel.dtemp = 0; + headPixel.dtemp = 0; + } + } + if (!isEmpty(pixel.x,pixel.y-2,true) && pixelMap[pixel.x][pixel.y-2].element === "head_screen") { + changePixel(pixelMap[pixel.x][pixel.y-2],"sandboxels_screen"); + } + } + else if (!isEmpty(pixel.x,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x][pixel.y+1]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel,"body_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + else if (newPixel.element === "water_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + } + }, +}, + +elements.head_screen = { + color: ["#46433F","#47443C","#4D483D"], + name:"screen", + hidden:true, + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + properties: { + dtemp: 20, + }, + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], + conduct: 1, + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","head"], + tempLow: -45, + stateLow: "sandboxels_screen_off", + category: "simulation", + tick: function(pixel) { + if (!isEmpty(pixel.x,pixel.y+1,true)) { + var newPixel = pixelMap[pixel.x][pixel.y+1]; + if (newPixel.element === "sandboxels_screen") { + if (Math.random() < 0.1) { + changePixel(newPixel,"blood_screen"); + newPixel.dtemp = pixel.dtemp; + } + else { + changePixel(newPixel,"head_screen"); + newPixel.dtemp = pixel.dtemp; + changePixel(pixel,"sandboxels_screen"); + pixel.dtemp = 0; + } + } + else if (newPixel.element === "water_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "blood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "ice_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "steam_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "wood_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "paper_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "saw_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "cellulose_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + else if (newPixel.element === "rock_screen") { + newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); + pixel.dtemp = newPixel.dtemp; + } + } + }, +}, + elements.ice_screen = { name:"screen", hidden:true, @@ -882,7 +2220,7 @@ elements.ice_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","ice"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", tick: function(pixel) { if (pixel.dtemp > 5) { changePixel(pixel,"water_screen") } }, @@ -893,7 +2231,7 @@ elements.ice_screen = { elements.wood_screen = { name:"screen", hidden:true, - color: "#808080", + color: "#a0522d", behavior: behaviors.WALL, properties: { dtemp: 20, @@ -901,10 +2239,29 @@ elements.wood_screen = { tempHigh: 1500, stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], conduct: 1, - breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","concrete"], + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","wood"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", + state: "solid", + density: 1200, +}, + +elements.paper_screen = { + name:"screen", + hidden:true, + color: "#f0f0f0", + behavior: behaviors.WALL, + properties: { + dtemp: 20, + }, + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_glass","molten_gallium"], + conduct: 1, + breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","paper"], + tempLow: -45, + stateLow: "sandboxels_screen_off", + category: "simulation", state: "solid", density: 1200, }, @@ -923,12 +2280,12 @@ elements.wall_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","concrete"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", state: "solid", density: 1200, }, -elements.digital_sand = { +elements.simulated_sand = { color: "#e6d577", behavior: [ "CH:sandboxels_screen>sand_screen|CH:sandboxels_screen>sand_screen|CH:sandboxels_screen>sand_screen", @@ -942,11 +2299,11 @@ elements.digital_sand = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on screen to place digital sand." + category: "simulation", + desc: "Use on screen to place simulated sand." }, -elements.digital_rock = { +elements.simulated_rock = { color: ["#808080","#4f4f4f","#949494"], behavior: [ "CH:sandboxels_screen>rock_screen|CH:sandboxels_screen>rock_screen|CH:sandboxels_screen>rock_screen", @@ -960,29 +2317,11 @@ elements.digital_rock = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on screen to place digital sand." + category: "simulation", + desc: "Use on screen to place simulated sand." }, -elements.digital_sawdust = { - color: "#e6d577", - behavior: [ - "CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen", - "CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen", - "CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen", - ], - tool: function(pixel) { - if (elements[pixel.element].id === elements.sandboxels_screen.id) { - changePixel(pixel,"saw_screen"); - } - }, - insulate:true, - canPlace: false, - category: "digital", - desc: "Use on screen to place digital sawdust." -}, - -elements.digital_water = { +elements.simulated_water = { color: "#2167ff", behavior: [ "CH:sandboxels_screen>water_screen|CH:sandboxels_screen>water_screen|CH:sandboxels_screen>water_screen", @@ -996,11 +2335,11 @@ elements.digital_water = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital water." + category: "simulation", + desc: "Use on a screen to place simulated water." }, -elements.digital_ice = { +elements.simulated_ice = { color: "#b2daeb", behavior: [ "CH:sandboxels_screen>ice_screen|CH:sandboxels_screen>ice_screen|CH:sandboxels_screen>ice_screen", @@ -1014,11 +2353,11 @@ elements.digital_ice = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital ice." + category: "simulation", + desc: "Use on a screen to place simulated ice." }, -elements.digital_steam = { +elements.simulated_steam = { color: "#abd6ff", behavior: [ "CH:sandboxels_screen>steam_screen|CH:sandboxels_screen>steam_screen|CH:sandboxels_screen>steam_screen", @@ -1032,12 +2371,48 @@ elements.digital_steam = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital ice." + category: "simulation", + desc: "Use on a screen to place simulated steam." }, -elements.digital_wood = { - color: "#abd6ff", +elements.simulated_blood = { + color: ["#ff0000","#ee0000"], + behavior: [ + "CH:sandboxels_screen>blood_screen|CH:sandboxels_screen>blood_screen|CH:sandboxels_screen>blood_screen", + "CH:sandboxels_screen>blood_screen|CH:sandboxels_screen>blood_screen|CH:sandboxels_screen>blood_screen", + "CH:sandboxels_screen>blood_screen|CH:sandboxels_screen>blood_screen|CH:sandboxels_screen>blood_screen", + ], + tool: function(pixel) { + if (elements[pixel.element].id === elements.sandboxels_screen.id) { + changePixel(pixel,"blood_screen"); + } + }, + insulate:true, + canPlace: false, + category: "simulation", + desc: "Use on a screen to place simulated blood." +}, + +elements.simulated_sawdust = { + color: ["#dec150","#c7b15a"], + behavior: [ + "CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen", + "CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen", + "CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen|CH:sandboxels_screen>saw_screen", + ], + tool: function(pixel) { + if (elements[pixel.element].id === elements.sandboxels_screen.id) { + changePixel(pixel,"saw_screen"); + } + }, + insulate:true, + canPlace: false, + category: "simulation", + desc: "Use on screen to place simulated sawdust." +}, + +elements.simulated_wood = { + color: "#a0522d", behavior: [ "CH:sandboxels_screen>wood_screen|CH:sandboxels_screen>wood_screen|CH:sandboxels_screen>wood_screen", "CH:sandboxels_screen>wood_screen|CH:sandboxels_screen>wood_screen|CH:sandboxels_screen>wood_screen", @@ -1050,11 +2425,29 @@ elements.digital_wood = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital ice." + category: "simulation", + desc: "Use on a screen to place simulated wood." }, -elements.digital_wall = { +elements.simulated_paper = { + color: "#f0f0f0", + behavior: [ + "CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen", + "CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen", + "CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen", + ], + tool: function(pixel) { + if (elements[pixel.element].id === elements.sandboxels_screen.id) { + changePixel(pixel,"paper_screen"); + } + }, + insulate:true, + canPlace: false, + category: "simulation", + desc: "Use on a screen to place simulated paper." +}, + +elements.simulated_wall = { color: "#808080", behavior: [ "CH:sandboxels_screen>ice_screen|CH:sandboxels_screen>ice_screen|CH:sandboxels_screen>ice_screen", @@ -1068,11 +2461,11 @@ elements.digital_wall = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital walls." + category: "simulation", + desc: "Use on a screen to place simulated wall." }, -elements.digital_heat = { +elements.simulated_heat = { color: "#ff0000", behavior: [ "XX|XX|XX", @@ -1095,6 +2488,9 @@ elements.digital_heat = { else if (elements[pixel.element].id === elements.cellulose_screen.id) { pixel.dtemp += 1 } + else if (elements[pixel.element].id === elements.blood_screen.id) { + pixel.dtemp += 1 + } else if (elements[pixel.element].id === elements.steam_screen.id) { pixel.dtemp += 1 } @@ -1104,14 +2500,23 @@ elements.digital_heat = { else if (elements[pixel.element].id === elements.wood_screen.id) { pixel.dtemp += 1 } + else if (elements[pixel.element].id === elements.paper_screen.id) { + pixel.dtemp += 1 + } + else if (elements[pixel.element].id === elements.head_screen.id) { + pixel.dtemp += 1 + } + else if (elements[pixel.element].id === elements.body_screen.id) { + pixel.dtemp += 1 + } }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to heat digital elements." + category: "simulation", + desc: "Use on a screen to heat simulated elements." }, -elements.digital_cool = { +elements.simulated_cool = { color: "#0000ff", behavior: [ "XX|XX|XX", @@ -1134,6 +2539,9 @@ elements.digital_cool = { else if (elements[pixel.element].id === elements.cellulose_screen.id) { pixel.dtemp -= 1 } + else if (elements[pixel.element].id === elements.blood_screen.id) { + pixel.dtemp -= 1 + } else if (elements[pixel.element].id === elements.steam_screen.id) { pixel.dtemp -= 1 } @@ -1143,14 +2551,23 @@ elements.digital_cool = { else if (elements[pixel.element].id === elements.wood_screen.id) { pixel.dtemp -= 1 } + else if (elements[pixel.element].id === elements.paper_screen.id) { + pixel.dtemp -= 1 + } + else if (elements[pixel.element].id === elements.head_screen.id) { + pixel.dtemp -= 1 + } + else if (elements[pixel.element].id === elements.body_screen.id) { + pixel.dtemp -= 1 + } }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to cool digital elements." + category: "simulation", + desc: "Use on a screen to cool simulated elements." }, -elements.digital_roomtemp = { +elements.simulated_roomtemp = { color: "#b1c96d", behavior: [ "XX|XX|XX", @@ -1165,31 +2582,43 @@ elements.digital_roomtemp = { pixel.dtemp = 20 } else if (elements[pixel.element].id === elements.saw_screen.id) { - pixel.dtemp = 1 + pixel.dtemp = 20 } else if (elements[pixel.element].id === elements.water_screen.id) { - pixel.dtemp = 1 + pixel.dtemp = 20 } else if (elements[pixel.element].id === elements.cellulose_screen.id) { - pixel.dtemp = 1 + pixel.dtemp = 20 + } + else if (elements[pixel.element].id === elements.blood_screen.id) { + pixel.dtemp = 20 } else if (elements[pixel.element].id === elements.steam_screen.id) { - pixel.dtemp = 1 + pixel.dtemp = 20 } else if (elements[pixel.element].id === elements.ice_screen.id) { - pixel.dtemp = 1 + pixel.dtemp = 20 } else if (elements[pixel.element].id === elements.wood_screen.id) { - pixel.dtemp = 1 + pixel.dtemp = 20 + } + else if (elements[pixel.element].id === elements.paper_screen.id) { + pixel.dtemp = 20 + } + else if (elements[pixel.element].id === elements.head_screen.id) { + pixel.dtemp = 20 + } + else if (elements[pixel.element].id === elements.body_screen.id) { + pixel.dtemp = 20 } }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to make digital elements room temperature." + category: "simulation", + desc: "Use on a screen to make simulated elements room temperature." }, -elements.digital_smash = { +elements.simulated_smash = { color: ["#666666","#888888","#666666"], behavior: [ "XX|XX|XX", @@ -1203,14 +2632,20 @@ elements.digital_smash = { else if (elements[pixel.element].id === elements.wood_screen.id) { changePixel(pixel,"saw_screen"); } + else if (elements[pixel.element].id === elements.head_screen.id) { + changePixel(pixel,"blood_screen"); + } + else if (elements[pixel.element].id === elements.body_screen.id) { + changePixel(pixel,"blood_screen"); + } }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to smash digital elements." + category: "simulation", + desc: "Use on a screen to smash simulated elements." }, -elements.digital_erase = { +elements.simulated_erase = { color: "#fdb5ff", behavior: [ "XX|XX|XX", @@ -1233,6 +2668,9 @@ elements.digital_erase = { else if (elements[pixel.element].id === elements.cellulose_screen.id) { changePixel(pixel,"sandboxels_screen"); } + else if (elements[pixel.element].id === elements.blood_screen.id) { + changePixel(pixel,"sandboxels_screen"); + } else if (elements[pixel.element].id === elements.steam_screen.id) { changePixel(pixel,"sandboxels_screen"); } @@ -1242,25 +2680,172 @@ elements.digital_erase = { else if (elements[pixel.element].id === elements.wood_screen.id) { changePixel(pixel,"sandboxels_screen"); } + else if (elements[pixel.element].id === elements.paper_screen.id) { + changePixel(pixel,"sandboxels_screen"); + } else if (elements[pixel.element].id === elements.wall_screen.id) { changePixel(pixel,"sandboxels_screen"); } + else if (elements[pixel.element].id === elements.head_screen.id) { + changePixel(pixel,"sandboxels_screen"); + } + else if (elements[pixel.element].id === elements.body_screen.id) { + changePixel(pixel,"sandboxels_screen"); + } }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to erase digital elements." + category: "simulation", + desc: "Use on a screen to erase simulated elements." }; if (!elements.malware.reactions) { elements.malware.reactions = {} } - elements.malware.reactions.sandboxels_screen = { "elem2": ["sand_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.saw_screen = { "elem2": ["wall_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.sand_screen = { "elem2": ["wood_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.rock_screen = { "elem2": ["ice_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.cellulose_screen = { "elem2": ["steam_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.water_screen = { "elem2": ["water_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.steam_screen = { "elem2": ["cellulose_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.ice_screen = { "elem2": ["rock_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.wood_screen = { "elem2": ["sand_screen","sandboxels_screen_off",null], chance:0.1 }; - elements.malware.reactions.wall_screen = { "elem2": ["saw_screen","sandboxels_screen_off",null], chance:0.1 }; + elements.malware.reactions.sandboxels_screen = { "elem2": ["sand_screen","sandboxels_screen_off","sandboxels_screen_off","malware"] }; + elements.malware.reactions.saw_screen = { "elem2": ["wall_screen","wall_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.sand_screen = { "elem2": ["paper_screen","paper_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.rock_screen = { "elem2": ["wood_screen","wood_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.cellulose_screen = { "elem2": ["blood_screen","blood_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.blood_screen = { "elem2": ["ice_screen","ice_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.water_screen = { "elem2": ["steam_screen","steam_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.steam_screen = { "elem2": ["water_screen","water_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.ice_screen = { "elem2": ["cellulose_screen","cellulose_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.wood_screen = { "elem2": ["rock_screen","rock_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.paper_screen = { "elem2": ["sand_screen","sand_screen","sandboxels_screen_off","malware"] }; + elements.malware.reactions.wall_screen = { "elem2": ["saw_screen","saw_screen","sandboxels_screen_off","malware"] }; +elements.head.tick = function(pixel) { + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + changePixel(pixel,"rotten_meat"); + return + } + } + + // Find the body + if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == "body") { + var body = pixelMap[pixel.x][pixel.y+1]; + if (body.dead) { // If body is dead, kill head + pixel.dead = body.dead; + } + } + else if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == "suited_body") { + var body = pixelMap[pixel.x][pixel.y+1]; + if (body.dead) { // If body is dead, kill head + pixel.dead = body.dead; + } + } + else { var body = null } + + if (tryMove(pixel, pixel.x, pixel.y+1)) { + // create blood if severed 10% chance + if (isEmpty(pixel.x, pixel.y+1) && !pixel.dead && Math.random() < 0.1 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y+1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } +} + +elements.body.tick = function(pixel) { + if (tryMove(pixel, pixel.x, pixel.y+1)) { // Fall + if (!isEmpty(pixel.x, pixel.y-2, true)) { // Drag head down + var headpixel = pixelMap[pixel.x][pixel.y-2]; + if (headpixel.element == "head") { + if (isEmpty(pixel.x, pixel.y-1)) { + movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); + } + else { + swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); + } + } + else if (headpixel.element == "suited_head") { + if (isEmpty(pixel.x, pixel.y-1)) { + movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); + } + else { + swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); + } + } + } + } + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + changePixel(pixel,"rotten_meat"); + } + return + } + + // Find the head + if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "head") { + var head = pixelMap[pixel.x][pixel.y-1]; + if (head.dead) { // If head is dead, kill body + pixel.dead = head.dead; + } + } + else if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "suited_head") { + var head = pixelMap[pixel.x][pixel.y-1]; + if (head.dead) { // If head is dead, kill body + pixel.dead = head.dead; + } + } + else { var head = null } + if (pixel.burning) { + pixel.panic += 0.1; + if (head && pixelTicks-pixel.burnStart > 240) { + pixel.color = head.color; + } + } + else if (pixel.panic > 0) { + pixel.panic -= 0.1; + } + + if (isEmpty(pixel.x, pixel.y-1)) { + // create blood if decapitated 10% chance + if (Math.random() < 0.1 && !pixel.charge) { + createPixel("blood", pixel.x, pixel.y-1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + else if (head == null) { return } + else if (Math.random() < 0.1*(isEmpty(pixel.x, pixel.y+1) ? 1 : pixel.panic+1)) { // Move 10% chance + var movesToTry = [ + [1*pixel.dir,0], + [1*pixel.dir,-1], + ]; + // While movesToTry is not empty, tryMove(pixel, x, y) with a random move, then remove it. if tryMove returns true, break. + while (movesToTry.length > 0) { + var move = movesToTry.splice(Math.floor(Math.random() * movesToTry.length), 1)[0]; + if (isEmpty(pixel.x+move[0], pixel.y+move[1]-1)) { + var origx = pixel.x+move[0]; + var origy = pixel.y+move[1]; + if (tryMove(pixel, pixel.x+move[0], pixel.y+move[1]) && pixel.x===origx && pixel.y===origy) { + movePixel(head, head.x+move[0], head.y+move[1]); + break; + } + } + } + // 15% chance to change direction + if (Math.random() < 0.15) { + pixel.dir *= -1; + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } + } +}