This commit is contained in:
slweeb 2024-08-04 15:15:44 -04:00
commit 10e4742ab7
6 changed files with 145 additions and 114 deletions

View File

@ -544,5 +544,9 @@
"grinder": "le broyeur",
"cloth": "le tissu",
"kelp": "varech",
"freeze_ray": "Ray gelée"
"freeze_ray": "Ray gelée",
"galvanized_steel": "Acier galvanisé",
"rice": "Le riz",
"midas_touch": "Touche de Midas",
"liquid_ozone": "Ozone liquide"
}

View File

@ -545,5 +545,9 @@
"kelp": "Tảo bẹ",
"grinder": "Máy nghiền",
"mixer": "Máy trộn",
"freeze_ray": "Tia làm lạnh"
"freeze_ray": "Tia làm lạnh",
"galvanized_steel": "Thép mạ kẽm",
"rice": "Gạo",
"midas_touch": "Bàn tay của Midas",
"liquid_ozone": "Ozone lỏng"
}

View File

@ -241,6 +241,7 @@
<tr><td>icb.js</td><td>Adds various levels of nested cluster bombs</td><td>Alice</td></tr>
<tr><td>life_eater.js</td><td>Adds Warhammer 40,000s Life-Eater Virus and Virus Bombs</td><td>Alice</td></tr>
<tr><td>liquid_void.js</td><td>Adds a liquid variant of Void</td><td>Alice</td></tr>
<tr><td>meat_rockets.js</td><td>Adds rockets that create meat when exploding</td><td>Melecie</td></tr>
<tr><td>more_breaking.js</td><td>Allows for breaking more elements in explosions</td><td>Alice</td></tr>
<tr><td>rays.js</td><td>Adds more Ray types</td><td>Alice</td></tr>
<tr><td>rays++.js</td><td>Adds a couple more rays</td><td>uptzik</td></tr>

View File

@ -5,6 +5,7 @@ var lightmap = [];
var nextLightmap = [];
var lightmapWidth, lightmapHeight;
var lightmapScale = 3;
var lightSourceBoost = 2;
var pixelSizeQuarter = pixelSizeHalf / 2;
var falloff = 0.7;
@ -167,49 +168,54 @@ function hsvToRgb(h, s, v) {
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
}
function renderLightmap() {
if (!canvas) return;
if (!lightmap || !lightmap[0]) return;
function renderLightmapPrePixel(ctx) {
if (!lightmap || !lightmap[0]) return;
var context = canvas.getContext('2d');
var _width = lightmap[0].length;
var _height = lightmap.length;
var _width = lightmap[0].length;
var _height = lightmap.length;
for (var y = 0; y < _height; y++) {
for (var x = 0; x < _width; x++) {
var { color } = lightmap[y][x];
var [r, g, b] = color;
for (var y = 0; y < _height; y++) {
for (var x = 0; x < _width; x++) {
var { color } = lightmap[y][x];
var [r, g, b] = color;
if (r > 16 || g > 16 || b > 16) {
var [h, s, v] = rgbToHsv(r, g, b);
var newColor = hsvToRgb(h, s, 1);
var alpha = v;
if (r > 16 || g > 16 || b > 16) {
var [h, s, v] = rgbToHsv(r, g, b);
var newColor = hsvToRgb(h, s, 1);
var alpha = v;
context.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.4})`;
context.fillRect(
ctx.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.4})`;
ctx.fillRect(
x * pixelSize * lightmapScale,
y * pixelSize * lightmapScale,
pixelSize * lightmapScale,
pixelSize * lightmapScale
);
context.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.25})`;
context.fillRect(
ctx.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.25})`;
ctx.fillRect(
(x * pixelSize - pixelSizeHalf) * lightmapScale,
(y * pixelSize - pixelSizeHalf) * lightmapScale,
pixelSize * lightmapScale * 2,
pixelSize * lightmapScale * 2
);
}
}
}
}
}
}
}
// Register the function to run before each pixel is rendered
renderPrePixel(function(ctx) {
if (!paused) {propagateLightmap();}
renderLightmapPrePixel(ctx);
});
function glowItsOwnColor(pixel) {
if (!pixel.color) {return;}
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: rgbToArray(pixel.color) };
lightmap[y][x] = { color: scaleList(rgbToArray(pixel.color), lightSourceBoost) };
}
function glowItsOwnColorIfPowered(pixel) {
@ -217,23 +223,22 @@ function glowItsOwnColorIfPowered(pixel) {
if (!pixel.color) return;
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: rgbToArray(pixel.color) };
lightmap[y][x] = { color: scaleList(rgbToArray(pixel.color), lightSourceBoost) };
}
function glowColor(pixel, color) {
if (!color) {return;}
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: color };
lightmap[y][x] = { color: scaleList(color, lightSourceBoost) };
}
function glowRadiationColor(pixel) {
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: radColor };
lightmap[y][x] = { color: scaleList(radColor, lightSourceBoost) };
}
// Define element tick functions
var originalStrangeMatterTick = elements.strange_matter.tick;
elements.strange_matter.tick = function(pixel) {
@ -309,7 +314,7 @@ elements.magma.tick = glowItsOwnColor;
elements.plasma.tick = glowItsOwnColor;
elements.fw_ember.tick = glowItsOwnColor;
elements.cold_fire.tick = pixel => glowColor(pixel, coldFireColor);
elements.cold_fire.tick = glowItsOwnColor;
// Radioactive elements
var radioactiveElements = [
@ -329,32 +334,3 @@ window.addEventListener('load', () => {
initializeLightmap(width, height);
};
});
var originalTick = tick;
tick = function() {
originalTick();
if (!paused) propagateLightmap();
};
resetInterval(tps);
var originalDoFrame = doFrame;
doFrame = function() {
originalDoFrame();
propagateLightmap();
};
if (enabledMods.includes("mods/velocity.js")) {
runAfterAutogen(() => {
var originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
};
});
} else {
var originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
};
}

View File

@ -5,6 +5,7 @@ var lightmap = [];
var nextLightmap = [];
var lightmapWidth, lightmapHeight;
var lightmapScale = 2;
var lightSourceBoost = 2;
var pixelSizeQuarter = pixelSizeHalf / 2;
var falloff = 0.8;
@ -167,49 +168,54 @@ function hsvToRgb(h, s, v) {
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
}
function renderLightmap() {
if (!canvas) return;
if (!lightmap || !lightmap[0]) return;
function renderLightmapPrePixel(ctx) {
if (!lightmap || !lightmap[0]) return;
var context = canvas.getContext('2d');
var _width = lightmap[0].length;
var _height = lightmap.length;
var _width = lightmap[0].length;
var _height = lightmap.length;
for (var y = 0; y < _height; y++) {
for (var x = 0; x < _width; x++) {
var { color } = lightmap[y][x];
var [r, g, b] = color;
for (var y = 0; y < _height; y++) {
for (var x = 0; x < _width; x++) {
var { color } = lightmap[y][x];
var [r, g, b] = color;
if (r > 16 || g > 16 || b > 16) {
var [h, s, v] = rgbToHsv(r, g, b);
var newColor = hsvToRgb(h, s, 1);
var alpha = v;
if (r > 16 || g > 16 || b > 16) {
var [h, s, v] = rgbToHsv(r, g, b);
var newColor = hsvToRgb(h, s, 1);
var alpha = v;
context.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.4})`;
context.fillRect(
ctx.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.4})`;
ctx.fillRect(
x * pixelSize * lightmapScale,
y * pixelSize * lightmapScale,
pixelSize * lightmapScale,
pixelSize * lightmapScale
);
context.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.25})`;
context.fillRect(
ctx.fillStyle = `rgba(${newColor[0]}, ${newColor[1]}, ${newColor[2]}, ${alpha * 0.25})`;
ctx.fillRect(
(x * pixelSize - pixelSizeHalf) * lightmapScale,
(y * pixelSize - pixelSizeHalf) * lightmapScale,
pixelSize * lightmapScale * 2,
pixelSize * lightmapScale * 2
);
}
}
}
}
}
}
}
// Register the function to run before each pixel is rendered
renderPrePixel(function(ctx) {
if (!paused) {propagateLightmap();}
renderLightmapPrePixel(ctx);
});
function glowItsOwnColor(pixel) {
if (!pixel.color) {return;}
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: rgbToArray(pixel.color) };
lightmap[y][x] = { color: scaleList(rgbToArray(pixel.color), lightSourceBoost) };
}
function glowItsOwnColorIfPowered(pixel) {
@ -217,23 +223,22 @@ function glowItsOwnColorIfPowered(pixel) {
if (!pixel.color) return;
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: rgbToArray(pixel.color) };
lightmap[y][x] = { color: scaleList(rgbToArray(pixel.color), lightSourceBoost) };
}
function glowColor(pixel, color) {
if (!color) {return;}
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: color };
lightmap[y][x] = { color: scaleList(color, lightSourceBoost) };
}
function glowRadiationColor(pixel) {
var x = Math.floor(pixel.x / lightmapScale);
var y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: radColor };
lightmap[y][x] = { color: scaleList(radColor, lightSourceBoost) };
}
// Define element tick functions
var originalStrangeMatterTick = elements.strange_matter.tick;
elements.strange_matter.tick = function(pixel) {
@ -309,7 +314,7 @@ elements.magma.tick = glowItsOwnColor;
elements.plasma.tick = glowItsOwnColor;
elements.fw_ember.tick = glowItsOwnColor;
elements.cold_fire.tick = pixel => glowColor(pixel, coldFireColor);
elements.cold_fire.tick = glowItsOwnColor;
// Radioactive elements
var radioactiveElements = [
@ -329,32 +334,3 @@ window.addEventListener('load', () => {
initializeLightmap(width, height);
};
});
var originalTick = tick;
tick = function() {
originalTick();
if (!paused) propagateLightmap();
};
resetInterval(tps);
var originalDoFrame = doFrame;
doFrame = function() {
originalDoFrame();
propagateLightmap();
};
if (enabledMods.includes("mods/velocity.js")) {
runAfterAutogen(() => {
var originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
};
});
} else {
var originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
};
}

70
mods/meat_rockets.js Normal file
View File

@ -0,0 +1,70 @@
// Meat Rockets 1.0
// Author: Melecie
meat_rocket_funcs = {
rocketCreator(rElem, rColor, rName) {
if (typeof(rName) == "undefined") { rName = rElem + "_rocket" }
elements[rName] = {
color: rColor,
state: "solid",
behavior: behaviors.ITEM_ROCKET,
properties: { launching: false },
rocketItem: rElem,
density: 1024,
hardness: 0.90,
burn: 100,
burnTime: 8192,
category: "special",
}
}
}
behaviors.ITEM_ROCKET = function(pixel) {
if (pixel.launching) {
pixel.burning = false;
// launching rocket
let nextX = pixel.x + (pixel.flipX ? -1:1);
let nextY = pixel.y-1;
let rocketItem = elements[pixel.element].rocketItem;
// flip, occasionally explode
if (Math.random() < 0.1) {
pixel.flipX = !pixel.flipX;
if (Math.random() < 0.05) {
explodeAt(pixel.x, pixel.y-1, 3, [rocketItem, "smoke"]);
}
} else if (Math.random() < 0.1) {
createPixel(pixel.x, pixel.y-1, "smoke")
}
// movement code
if (outOfBounds(nextX, nextY)) {
explodeAt(pixel.x, pixel.y, 10, [rocketItem, "smoke", "smoke"]);
deletePixel(pixel.x, pixel.y);
} else if (canMove(pixel, nextX, nextY)) {
tryMove(pixel, nextX, nextY);
} else if ( elements[pixelMap[nextX][nextY].element].state == "gas" || pixelMap[nextX][nextY].element == rocketItem ) {
let otherPixel = pixelMap[nextX][nextY];
swapPixels(pixel, otherPixel);
} else if ( pixelMap[nextX][nextY].element == pixel.element ) {
} else {
explodeAt(pixel.x, pixel.y, 10, [rocketItem, "smoke", "smoke"]);
deletePixel(pixel.x, pixel.y);
}
} else {
// hasn't started yet
behaviors.POWDER(pixel);
if (pixel.burning == true) {
pixel.launching = true;
}
}
doDefaults(pixel);
}
meat_rocket_funcs.rocketCreator("meat", ["#d36e7d", "#a85c4b"])
elements.meat.reactions.fallout = { elem1: "meat_rocket", chance: 0.2 }