diff --git a/mods/sandboxels.js b/mods/sandboxels.js index 9d1dca26..06b07c23 100644 --- a/mods/sandboxels.js +++ b/mods/sandboxels.js @@ -40,10 +40,257 @@ 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() }) +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, @@ -56,7 +303,7 @@ elements.digitalizer = { 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", 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]; @@ -94,6 +341,18 @@ elements.digitalizer = { 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) @@ -102,6 +361,14 @@ elements.digitalizer = { 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) @@ -111,7 +378,7 @@ elements.digitalizer = { }, state: "solid", density: 1200, - desc: "Digitalizes elements." + desc: "simulatedizes elements." }, elements.sandboxels_screen_off = { @@ -129,7 +396,7 @@ elements.sandboxels_screen_off = { 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." @@ -150,11 +417,45 @@ elements.sandboxels_screen = { 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) { + var oldPixel = pixelMap[pixel.x][pixel.y]; + var newPixel = pixelMap[pixel.x][pixel.y+1]; + if (newPixel.element === "sandboxels_screen") { + changePixel(newPixel, "body_screen"); + pixel.element = "head_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, "head_screen"); + pixel.element = "body_screen"; + } + } + else { + changePixel(oldPixel, "sandboxels_screen"); + } + }, + related: ["suited_body","suited_head"], + cooldown: defaultCooldown, + forceSaveColor: true, +}, + elements.sand_screen = { name:"screen", hidden:true, @@ -173,7 +474,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]; @@ -189,6 +490,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; @@ -233,6 +540,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; @@ -282,6 +595,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; @@ -341,7 +660,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]; @@ -357,6 +676,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 === "steam_screen") { newPixel.dtemp = ((pixel.dtemp + newPixel.dtemp) / 2); pixel.dtemp = newPixel.dtemp; @@ -381,6 +706,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; @@ -430,6 +761,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; @@ -489,7 +826,7 @@ elements.saw_screen = { 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]; @@ -631,7 +968,7 @@ elements.cellulose_screen = { 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]; @@ -647,6 +984,12 @@ elements.cellulose_screen = { 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; @@ -689,6 +1032,12 @@ elements.cellulose_screen = { 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; @@ -706,8 +1055,8 @@ elements.cellulose_screen = { 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); @@ -732,6 +1081,12 @@ elements.cellulose_screen = { 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; @@ -776,6 +1131,12 @@ elements.cellulose_screen = { 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; @@ -819,6 +1180,12 @@ elements.cellulose_screen = { 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; @@ -853,6 +1220,297 @@ elements.cellulose_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, +}, elements.water_screen = { name:"screen", @@ -872,7 +1530,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]; @@ -894,12 +1552,26 @@ elements.water_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; @@ -928,6 +1600,14 @@ elements.water_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; @@ -969,6 +1649,14 @@ elements.water_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; @@ -1011,6 +1699,14 @@ elements.water_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; @@ -1052,6 +1748,14 @@ elements.water_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; @@ -1098,7 +1802,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]; @@ -1127,6 +1831,10 @@ elements.steam_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; @@ -1167,6 +1875,10 @@ elements.steam_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; @@ -1207,6 +1919,10 @@ elements.steam_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; @@ -1266,6 +1982,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, @@ -1280,7 +2217,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") } }, @@ -1302,7 +2239,7 @@ elements.wood_screen = { 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, }, @@ -1321,7 +2258,7 @@ elements.paper_screen = { breakInto: ["glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","glass_shard","paper"], tempLow: -45, stateLow: "sandboxels_screen_off", - category: "digital", + category: "simulation", state: "solid", density: 1200, }, @@ -1340,12 +2277,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", @@ -1359,11 +2296,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", @@ -1377,11 +2314,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_water = { +elements.simulated_water = { color: "#2167ff", behavior: [ "CH:sandboxels_screen>water_screen|CH:sandboxels_screen>water_screen|CH:sandboxels_screen>water_screen", @@ -1395,11 +2332,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", @@ -1413,11 +2350,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", @@ -1431,11 +2368,47 @@ elements.digital_steam = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital steam." + category: "simulation", + desc: "Use on a screen to place simulated steam." }, -elements.digital_wood = { +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", @@ -1449,11 +2422,11 @@ elements.digital_wood = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital wood." + category: "simulation", + desc: "Use on a screen to place simulated wood." }, -elements.digital_paper = { +elements.simulated_paper = { color: "#f0f0f0", behavior: [ "CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen|CH:sandboxels_screen>paper_screen", @@ -1467,11 +2440,11 @@ elements.digital_paper = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital paper." + category: "simulation", + desc: "Use on a screen to place simulated paper." }, -elements.digital_wall = { +elements.simulated_wall = { color: "#808080", behavior: [ "CH:sandboxels_screen>ice_screen|CH:sandboxels_screen>ice_screen|CH:sandboxels_screen>ice_screen", @@ -1485,11 +2458,11 @@ elements.digital_wall = { }, insulate:true, canPlace: false, - category: "digital", - desc: "Use on a screen to place digital wall." + category: "simulation", + desc: "Use on a screen to place simulated wall." }, -elements.digital_heat = { +elements.simulated_heat = { color: "#ff0000", behavior: [ "XX|XX|XX", @@ -1512,6 +2485,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 } @@ -1524,14 +2500,20 @@ elements.digital_heat = { 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", @@ -1554,6 +2536,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 } @@ -1566,14 +2551,20 @@ elements.digital_cool = { 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", @@ -1596,6 +2587,9 @@ elements.digital_roomtemp = { else if (elements[pixel.element].id === elements.cellulose_screen.id) { 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 = 20 } @@ -1608,14 +2602,20 @@ elements.digital_roomtemp = { 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", @@ -1629,14 +2629,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", @@ -1659,6 +2665,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"); } @@ -1674,11 +2683,17 @@ elements.digital_erase = { 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 = {} } @@ -1686,10 +2701,148 @@ if (!elements.malware.reactions) { elements.malware.reactions = {} } 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": ["ice_screen","ice_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; } + } +}