add more stuff
This commit is contained in:
parent
009ca8a323
commit
ed3ec4e051
|
|
@ -19,9 +19,24 @@ let fireColor = [255, 69, 0];
|
|||
let plasmaColor = [160, 69, 255];
|
||||
let coldFireColor = [0, 191, 255];
|
||||
let magmaColor = [255, 140, 0];
|
||||
let fireFlyColors = [[180, 255, 70], scaleList([180, 255, 70], 0.75), scaleList([180, 255, 70], 0.5), scaleList([180, 255, 70], 0.25)];
|
||||
let fireflyColor = [240, 255, 70];
|
||||
let radColor = [75, 100, 30];
|
||||
let neonColor = [255*2, 60*2, 10*2];
|
||||
let strangeMatterColor = [220*0.3, 255*0.3, 210*0.3];
|
||||
let sparkColors = [[255, 210, 120], [255, 140, 10]];
|
||||
|
||||
function rgbToArray(rgbString) {
|
||||
// Remove "rgb(" and ")" from the string and split by comma
|
||||
let values = rgbString.slice(4, -1).split(',');
|
||||
|
||||
// Convert each value from string to number
|
||||
let r = parseInt(values[0].trim());
|
||||
let g = parseInt(values[1].trim());
|
||||
let b = parseInt(values[2].trim());
|
||||
|
||||
// Return the array of RGB values
|
||||
return [r, g, b];
|
||||
}
|
||||
|
||||
function scaleList(numbers, scale) {
|
||||
return numbers.map(number => number * scale);
|
||||
|
|
@ -170,7 +185,7 @@ function renderLightmap() {
|
|||
elements.sun.tick = function(pixel) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: sunColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
let originalLightTick = elements.light.tick;
|
||||
|
|
@ -178,7 +193,7 @@ elements.light.tick = function(pixel) {
|
|||
originalLightTick(pixel);
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: lightColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
let originalLiquidLightTick = elements.liquid_light.tick;
|
||||
|
|
@ -186,7 +201,7 @@ elements.liquid_light.tick = function(pixel) {
|
|||
originalLiquidLightTick(pixel);
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: lightColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
elements.magma.tick = function(pixel) {
|
||||
|
|
@ -199,7 +214,7 @@ elements.neon.tick = function(pixel) {
|
|||
if (!pixel.charge || pixel.charge <= 0) {return;}
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: neonColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
elements.light_bulb.behaviorOn = null
|
||||
|
|
@ -208,7 +223,7 @@ elements.light_bulb.tick = function(pixel) {
|
|||
if (pixel.lightIntensity > 0) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: lampColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
}
|
||||
pixel.lightIntensity -= 1;
|
||||
};
|
||||
|
|
@ -218,7 +233,7 @@ elements.led_r.tick = function(pixel) {
|
|||
if (pixel.lightIntensity > 0) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: ledRColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
}
|
||||
pixel.lightIntensity -= 1;
|
||||
};
|
||||
|
|
@ -228,7 +243,7 @@ elements.led_g.tick = function(pixel) {
|
|||
if (pixel.lightIntensity > 0) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: ledGColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
}
|
||||
pixel.lightIntensity -= 1;
|
||||
};
|
||||
|
|
@ -238,7 +253,7 @@ elements.led_b.tick = function(pixel) {
|
|||
if (pixel.lightIntensity > 0) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: ledBColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
}
|
||||
pixel.lightIntensity -= 1;
|
||||
};
|
||||
|
|
@ -248,7 +263,7 @@ elements.laser.tick = function(pixel) {
|
|||
originalLaserTick(pixel);
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: laserColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
let originalFireTick2 = elements.fire.tick;
|
||||
|
|
@ -265,28 +280,47 @@ elements.cold_fire.tick = function(pixel) {
|
|||
lightmap[y][x] = { color: coldFireColor };
|
||||
};
|
||||
|
||||
let originalRainbowTick = elements.rainbow.tick;
|
||||
elements.rainbow.tick = function(pixel) {
|
||||
originalRainbowTick(pixel);
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
elements.plasma.tick = function(pixel) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
lightmap[y][x] = { color: plasmaColor };
|
||||
lightmap[y][x] = { color: rgbToArray(pixel.color) };
|
||||
};
|
||||
|
||||
let originalFireflyTick = elements.firefly.tick;
|
||||
|
||||
elements.firefly.tick = function(pixel) {
|
||||
originalFireflyTick(pixel);
|
||||
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
let y = Math.floor(pixel.y / lightmapScale);
|
||||
|
||||
let col = undefined;
|
||||
if (pixelTicks % pixel.fff <= 5) { col = fireFlyColors[3]; }
|
||||
if (pixelTicks % pixel.fff <= 4) { col = fireFlyColors[2]; }
|
||||
if (pixelTicks % pixel.fff <= 3) { col = fireFlyColors[1]; }
|
||||
if (pixelTicks % pixel.fff <= 2) { col = fireFlyColors[0]; }
|
||||
if (col) {
|
||||
lightmap[y][x] = { color: col };
|
||||
let num;
|
||||
let tickMod = pixelTicks % pixel.fff;
|
||||
|
||||
if (tickMod <= 2) {
|
||||
num = 1;
|
||||
} else if (tickMod <= 3) {
|
||||
num = 0.75;
|
||||
} else if (tickMod <= 4) {
|
||||
num = 0.5;
|
||||
} else if (tickMod <= 5) {
|
||||
num = 0.25;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
lightmap[y][x] = { color: scaleList(fireflyColor, num) };
|
||||
};
|
||||
|
||||
|
||||
// Radioactive elements
|
||||
elements.uranium.tick = function(pixel) {
|
||||
let x = Math.floor(pixel.x / lightmapScale);
|
||||
|
|
@ -336,6 +370,8 @@ elements.rad_steam.tick = function(pixel) {
|
|||
lightmap[y][x] = { color: radColor };
|
||||
};
|
||||
|
||||
// #keepTheGap
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
initializeLightmap(width, height);
|
||||
});
|
||||
|
|
@ -356,10 +392,6 @@ doFrame = function() {
|
|||
propagateLightmap();
|
||||
};
|
||||
|
||||
if (enabledMods.includes("mods/lightmap.js")) {
|
||||
alert("Warning: both fast_lightmap.js and lightmap.js are active and it will not properly work");
|
||||
}
|
||||
|
||||
if (enabledMods.includes("mods/velocity.js")) {
|
||||
runAfterAutogen(()=>{
|
||||
let originalDrawPixels = drawPixels;
|
||||
|
|
|
|||
Loading…
Reference in New Issue