sandboxels/mods/lighting_test.js

79 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

Version 1.10.1 - October 5, 2024 - Creepy Crawlies [Version 1.10.1 - October 5, 2024 - Creepy Crawlies] [Crawly] + Spider, will climb and create Webs + Web (Hidden), will trap bugs + Ants can climb walls [Creepy] + Soul (Hidden), from Humans + Ectoplasm (Hidden) + Tombstone, spawns Souls ~ Note: Soul features will move to the souls.js mod after October + Candy is candy corn-colored + Humans will wear orange shirts on Halloween [Changes] + Fire can heat existing pixels when placed over them + Wet Sand and Mud release Steam when heated + Smashing Clouds can release their Water + Water will create Bubbles before boiling + Dirty Water can be purified before boiling + Panicking humans will cause others to panic + Rice can be fermented + Rats can eat Vines + Bleach kills Algae + Salt slowly dissolves in Bleach + Bleach destroys Ink and Dye + Bleach stains Porcelain Shards brown + Caramel dissolves in Vinegar + Image tool set to Paint will recolor pixels + Midas Touch converts hot liquids to Molten Gold ~ Thermite can no longer form Slag ~ Milk boils more realistically ~ Increased minimum temperature for Meat to make Grease ~ Blaster explodes into less Plasma ~ Moved Hive to after Bee when unhidden + Rust alias 'Iron Oxide' [Bug Fixes] ~ Fixed: Mix with Replace Mode deletes pixels ~ Fixed: Cannot Erase lines on mobile ~ Fixed: Heat glow appears in inappropriate views ~ Fixed: Void can be dragged ~ Fixed: Oxidized Copper can't sink in liquids ~ Fixed: Pressure Plate doesn't conduct Heat or sink ~ Fixed: Fire created by molten pixels isn't hot enough ~ Fixed: Mods added with backslash can't be removed ~ Fixed: Single Sponge pixels have NaN moisture ~ Fixed: Non-string hoverStat values crash simulation ~ Fixed: Crash when pixel changes state into a customColor element [Technical] + URL parameter ?holiday=false disables holiday events + Pressure Plate 'min' attribute for minimum density + 'onStateHigh' and 'onStateLow' element properties + 'buttonGlow' element property + Saves with abnormally large canvases display a warning + createPixel and changePixel functions accept null values ~ Corn updated to use 'onStateHigh' property ~ Pixel 'glow' attribute can be false to override default ~ Pixel 'glow' attribute is removed when pixel changes ~ Random element is no longer hard-coded
2024-10-05 11:53:31 -04:00
lightCoordsLevel1 = [
[-1,-3],[0,-3],[1,-3],
[-2,-2],[2,-2],
[-3,-1],[3,-1],
[-3,-0],[3,-0],
[-3,1],[3,1],
[-2,2],[2,2],
[-1,3],[0,3],[1,3],
]
lightCoordsLevel2 = [
[-1,-2],[0,-2],[1,-2],
[-2,-1],[2,-1],
[-2,0],[2,0],
[-2,1],[2,1],
[-1,2],[0,2],[1,2],
]
lightCoordsLevel3 = [
[-1,-1],[1,-1],
[-1,1],[1,1],
]
lightCoordsLevel3Extra = [
[1,0],[-1,0],[0,1],[0,-1]
]
glowAmount = 2;
viewInfo[4] = {
name: "lighting",
effects: true,
colorEffects: true,
pixel: viewInfo[1].pixel,
pre: function(ctx){
const pixelSize3 = pixelSize*3;
const pixelSize7 = pixelSize*7
const pixelSize5 = pixelSize*5
ctx.globalAlpha = 0.1;
for (let i = 0; i < currentPixels.length; i++) {
const pixel = currentPixels[i];
if (elements[pixel.element].id === elements.fire.id) {
ctx.fillStyle = pixel.color;
/* no occulusion: */
ctx.fillRect(canvasCoord(pixel.x-1), canvasCoord(pixel.y-3), pixelSize3, pixelSize7);
if (!isEmpty(pixel.x,pixel.y+1) && !isEmpty(pixel.x,pixel.y-1)) {
continue;
}
ctx.fillRect(canvasCoord(pixel.x-3), canvasCoord(pixel.y-1), pixelSize7, pixelSize3);
if (!isEmpty(pixel.x+1,pixel.y) && !isEmpty(pixel.x-1,pixel.y)) {
continue;
}
ctx.fillRect(canvasCoord(pixel.x-2), canvasCoord(pixel.y-2), pixelSize5, pixelSize5);
// ctx.globalAlpha = 0.1;
// lightCoordsLevel1.forEach(coords => {
// let x = pixel.x+coords[0]; let y = pixel.y+coords[1];
// if (!outOfBounds(x,y) && pixelMap[pixel.x+coords[0]][pixel.y+coords[1]] === undefined) {
// ctx.fillRect(x*pixelSize, y*pixelSize, pixelSize, pixelSize);
// }
// });
// ctx.globalAlpha = 0.2;
// lightCoordsLevel2.forEach(coords => {
// let x = pixel.x+coords[0]; let y = pixel.y+coords[1];
// if (!outOfBounds(x,y) && pixelMap[pixel.x+coords[0]][pixel.y+coords[1]] === undefined) {
// ctx.fillRect(x*pixelSize, y*pixelSize, pixelSize, pixelSize);
// }
// });
// ctx.globalAlpha = 0.3;
// lightCoordsLevel3.forEach(coords => {
// let x = pixel.x+coords[0]; let y = pixel.y+coords[1];
// if (!outOfBounds(x,y) && pixelMap[pixel.x+coords[0]][pixel.y+coords[1]] === undefined) {
// ctx.fillRect(x*pixelSize, y*pixelSize, pixelSize, pixelSize);
// }
// });
}
}
ctx.globalAlpha = 1;
}
}