Merge branch 'main' of https://github.com/R74nCom/sandboxels
This commit is contained in:
commit
a532128761
1292
mods/coldblooded.js
1292
mods/coldblooded.js
File diff suppressed because it is too large
Load Diff
|
|
@ -797,7 +797,7 @@ elements.rgb_led = {
|
||||||
promptInput("Enter red value (0-255):", function (r_inp) {
|
promptInput("Enter red value (0-255):", function (r_inp) {
|
||||||
r_inp = parseInt(r_inp);
|
r_inp = parseInt(r_inp);
|
||||||
if (r_inp > 255 || r_inp < 0 || isNaN(r_inp)) {
|
if (r_inp > 255 || r_inp < 0 || isNaN(r_inp)) {
|
||||||
logMessage("Red value is invalid, using default/last red value: " + r);
|
logMessage("Red value is invalid, using default/last red value: " + globals.red);
|
||||||
} else {
|
} else {
|
||||||
globals.red = r_inp;
|
globals.red = r_inp;
|
||||||
}
|
}
|
||||||
|
|
@ -805,7 +805,7 @@ elements.rgb_led = {
|
||||||
promptInput("Enter green value (0-255):", function (g_inp) {
|
promptInput("Enter green value (0-255):", function (g_inp) {
|
||||||
g_inp = parseInt(g_inp);
|
g_inp = parseInt(g_inp);
|
||||||
if (g_inp > 255 || g_inp < 0 || isNaN(g_inp)) {
|
if (g_inp > 255 || g_inp < 0 || isNaN(g_inp)) {
|
||||||
logMessage("Green value is invalid, using default/last green value: " + g);
|
logMessage("Green value is invalid, using default/last green value: " + globals.green);
|
||||||
} else {
|
} else {
|
||||||
globals.green = g_inp;
|
globals.green = g_inp;
|
||||||
}
|
}
|
||||||
|
|
@ -813,7 +813,7 @@ elements.rgb_led = {
|
||||||
promptInput("Enter blue value (0-255):", function (b_inp) {
|
promptInput("Enter blue value (0-255):", function (b_inp) {
|
||||||
b_inp = parseInt(b_inp);
|
b_inp = parseInt(b_inp);
|
||||||
if (b_inp > 255 || b_inp < 0 || isNaN(b_inp)) {
|
if (b_inp > 255 || b_inp < 0 || isNaN(b_inp)) {
|
||||||
logMessage("Blue value is invalid, using default/last blue value: " + b);
|
logMessage("Blue value is invalid, using default/last blue value: " + globals.blue);
|
||||||
} else {
|
} else {
|
||||||
globals.blue = b_inp;
|
globals.blue = b_inp;
|
||||||
}
|
}
|
||||||
|
|
@ -823,7 +823,7 @@ elements.rgb_led = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onPlace: (pixel) => {
|
onPlace: (pixel) => {
|
||||||
var ledColor = RGBToHex([red, green, blue]);
|
var ledColor = RGBToHex([globals.red, globals.green, globals.blue]);
|
||||||
pixel.color = ledColor;
|
pixel.color = ledColor;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1321,7 +1321,7 @@ elements.custom_bomb = {
|
||||||
|
|
||||||
// If pixel is at the bottom or resting on a solid
|
// If pixel is at the bottom or resting on a solid
|
||||||
if (outOfBounds(pixel.x, pixel.y + 1) || (belowPixel && belowPixel.element !== "custom_bomb" && !isEmpty(pixel.x, pixel.y + 1) && belowPixel.element !== "fire" && belowPixel.element !== "smoke")) {
|
if (outOfBounds(pixel.x, pixel.y + 1) || (belowPixel && belowPixel.element !== "custom_bomb" && !isEmpty(pixel.x, pixel.y + 1) && belowPixel.element !== "fire" && belowPixel.element !== "smoke")) {
|
||||||
explodeAt(pixel.x, pixel.y, 10, explodeElem);
|
explodeAt(pixel.x, pixel.y, 10, globals.explodeElem);
|
||||||
deletePixel(pixel.x, pixel.y);
|
deletePixel(pixel.x, pixel.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1667,7 +1667,7 @@ elements.robot_body = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Robot creator element
|
// Robot creator element
|
||||||
var mode = "Aimless"
|
globals.mode = "Aimless"
|
||||||
elements.robot = {
|
elements.robot = {
|
||||||
color: "#b1b1b1",
|
color: "#b1b1b1",
|
||||||
category: "machines",
|
category: "machines",
|
||||||
|
|
@ -1679,10 +1679,10 @@ elements.robot = {
|
||||||
(choice) => {
|
(choice) => {
|
||||||
if (choice === "Controlled" && isMobile) {
|
if (choice === "Controlled" && isMobile) {
|
||||||
logMessage("Controlled mode doesn't work on mobile");
|
logMessage("Controlled mode doesn't work on mobile");
|
||||||
mode = "Aimless";
|
globals.mode = "Aimless";
|
||||||
} else {
|
} else {
|
||||||
mode = choice || "Aimless";
|
globals.mode = choice || "Aimless";
|
||||||
if (mode === "Controlled") {
|
if (globals.mode === "Controlled") {
|
||||||
logMessage("Controls: A/D to move and W to jump or (Not reccomended) ←/→ to move, and ↑ to jump");
|
logMessage("Controls: A/D to move and W to jump or (Not reccomended) ←/→ to move, and ↑ to jump");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1695,17 +1695,17 @@ elements.robot = {
|
||||||
if (isEmpty(pixel.x, pixel.y - 1)) {
|
if (isEmpty(pixel.x, pixel.y - 1)) {
|
||||||
createPixel("robot_head", pixel.x, pixel.y - 1);
|
createPixel("robot_head", pixel.x, pixel.y - 1);
|
||||||
const head = getPixel(pixel.x, pixel.y - 1);
|
const head = getPixel(pixel.x, pixel.y - 1);
|
||||||
head.mode = mode;
|
head.mode = globals.mode;
|
||||||
changePixel(pixel, "robot_body");
|
changePixel(pixel, "robot_body");
|
||||||
pixel.mode = mode;
|
pixel.mode = globals.mode;
|
||||||
}
|
}
|
||||||
// Try to create body below if above is blocked
|
// Try to create body below if above is blocked
|
||||||
else if (isEmpty(pixel.x, pixel.y + 1)) {
|
else if (isEmpty(pixel.x, pixel.y + 1)) {
|
||||||
createPixel("robot_body", pixel.x, pixel.y + 1);
|
createPixel("robot_body", pixel.x, pixel.y + 1);
|
||||||
const body = getPixel(pixel.x, pixel.y + 1);
|
const body = getPixel(pixel.x, pixel.y + 1);
|
||||||
body.mode = mode;
|
body.mode = globals.mode;
|
||||||
changePixel(pixel, "robot_head");
|
changePixel(pixel, "robot_head");
|
||||||
pixel.mode = mode;
|
pixel.mode = globals.mode;
|
||||||
}
|
}
|
||||||
// Delete if no space
|
// Delete if no space
|
||||||
else {
|
else {
|
||||||
|
|
@ -2017,7 +2017,7 @@ elements.indestructable_filter = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.glass_hole_expand = false
|
globals.blackHoleExpand = false
|
||||||
elements.black_hole = {
|
elements.black_hole = {
|
||||||
color: "#111111",
|
color: "#111111",
|
||||||
hardness: 1,
|
hardness: 1,
|
||||||
|
|
@ -2105,7 +2105,7 @@ elements.black_hole = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (globals.glass_hole_expand) {
|
if (globals.blackHoleExpand) {
|
||||||
for (var i = 0; i < adjacentCoords.length; i++) {
|
for (var i = 0; i < adjacentCoords.length; i++) {
|
||||||
var x = pixel.x + adjacentCoords[i][0];
|
var x = pixel.x + adjacentCoords[i][0];
|
||||||
var y = pixel.y + adjacentCoords[i][1];
|
var y = pixel.y + adjacentCoords[i][1];
|
||||||
|
|
@ -2127,10 +2127,10 @@ elements.black_hole = {
|
||||||
choice = "No"
|
choice = "No"
|
||||||
}
|
}
|
||||||
if (choice == "Yes") {
|
if (choice == "Yes") {
|
||||||
globals.glass_hole_expand = true
|
globals.blackHoleExpand = true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
globals.glass_hole_expand = false
|
globals.blackHoleExpand = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -3326,4 +3326,3 @@ elements.replace_all_of_element = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
// IIFE to prevent this mod from breaking
|
||||||
|
(() => {
|
||||||
|
let staticMode = 0
|
||||||
|
|
||||||
|
function randomGrayscale() {
|
||||||
|
const value = Math.floor(Math.random() * 256);
|
||||||
|
return `rgb(${value}, ${value}, ${value})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomColor() {
|
||||||
|
const letters = "0123456789ABCDEF";
|
||||||
|
let color = "#";
|
||||||
|
for (let i = 0; i < 6; i++) {
|
||||||
|
color += letters[Math.floor(Math.random() * 16)];
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loopScreen(callback) {
|
||||||
|
for (let x = 0; x <= width; x++) {
|
||||||
|
for (let y = 0; y <= height; y++) {
|
||||||
|
callback(x, y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
keybinds["KeyS"] = () => {
|
||||||
|
staticMode === 0 ? staticMode = 1 : staticMode === 1 ? staticMode = 2 : staticMode = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
renderPostPixel(function (ctx) {
|
||||||
|
if (!staticMode) return
|
||||||
|
loopScreen((x, y) => {
|
||||||
|
if (staticMode === 1) {
|
||||||
|
drawSquare(ctx, randomGrayscale(), x, y, 1, 0.2)
|
||||||
|
}
|
||||||
|
if (staticMode === 2) {
|
||||||
|
drawSquare(ctx, randomColor(), x, y, 1, 0.3)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})()
|
||||||
Loading…
Reference in New Issue