From b6a6af86e03b9ece8272de5125eb572960d2d615 Mon Sep 17 00:00:00 2001 From: redbirdly <155550833+redbirdly@users.noreply.github.com> Date: Mon, 17 Jun 2024 08:41:12 +0800 Subject: [PATCH] add radiation glow and fireflies --- mods/lightmap.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/mods/lightmap.js b/mods/lightmap.js index c5dc0d3b..2e26a12c 100644 --- a/mods/lightmap.js +++ b/mods/lightmap.js @@ -19,8 +19,14 @@ 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 radColor = [75, 100, 30]; let neonColor = [255*2, 60*2, 10*2]; +function scaleList(numbers, scale) { + return numbers.map(number => number * scale); +} + function initializeLightmap(width, height) { lightmapWidth = Math.ceil(width / lightmapScale); lightmapHeight = Math.ceil(height / lightmapScale); @@ -265,6 +271,71 @@ elements.plasma.tick = function(pixel) { lightmap[y][x] = { color: plasmaColor }; }; +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 }; + } +}; + +// Radioactive elements +elements.uranium.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.radiation.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.rad_glass.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.fallout.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.molten_uranium.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.rad_shard.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.rad_cloud.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + +elements.rad_steam.tick = function(pixel) { + let x = Math.floor(pixel.x / lightmapScale); + let y = Math.floor(pixel.y / lightmapScale); + lightmap[y][x] = { color: radColor }; +}; + window.addEventListener('load', function() { initializeLightmap(width, height); });