Merge branch 'main' of https://github.com/R74nCom/sandboxels
This commit is contained in:
commit
a532128761
|
|
@ -4,9 +4,7 @@ v 0.11 "axolotl" eats fish
|
||||||
v 0.2 crocodiles scales and axolotls actually eat fish now
|
v 0.2 crocodiles scales and axolotls actually eat fish now
|
||||||
v 0.3 chameleons + bugfixes
|
v 0.3 chameleons + bugfixes
|
||||||
v 0.4 turtles, tortoise + improved logic
|
v 0.4 turtles, tortoise + improved logic
|
||||||
|
v 0.41 Bugfixes (How was this even working before this fix)
|
||||||
|
|
||||||
thats it for now
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const defaultColors = ["#02c937", "#18d64a", "#09e644"];
|
const defaultColors = ["#02c937", "#18d64a", "#09e644"];
|
||||||
|
|
@ -73,10 +71,6 @@ function poisonOther(pixel1, pixel2) {
|
||||||
pixel2.poisoned ??= 30;
|
pixel2.poisoned ??= 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInBounds(x, y) {
|
|
||||||
return x >= 0 && x < width && y >= 0 && y < height;
|
|
||||||
}
|
|
||||||
|
|
||||||
elements.human.reactions.snake =
|
elements.human.reactions.snake =
|
||||||
{ attr1: { panic: 5 } }
|
{ attr1: { panic: 5 } }
|
||||||
|
|
||||||
|
|
@ -87,7 +81,7 @@ if (!elements.glue.ignore.includes("scale")) {
|
||||||
elements.glue.ignore.push("scale");
|
elements.glue.ignore.push("scale");
|
||||||
}
|
}
|
||||||
|
|
||||||
danger = ["crocodile", "snake"];
|
let danger = ["crocodile", "snake"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -219,7 +213,6 @@ elements.toad_tadpole = {
|
||||||
"bleach": { elem1: null, chance: 0.05 },
|
"bleach": { elem1: null, chance: 0.05 },
|
||||||
"poison": { elem1: null },
|
"poison": { elem1: null },
|
||||||
"radiation": { elem1: ["toad", "toad", "frog", "worm", null], chance: 0.4 },
|
"radiation": { elem1: ["toad", "toad", "frog", "worm", null], chance: 0.4 },
|
||||||
"poison": { elem1: null },
|
|
||||||
"poison_gas": { elem1: null },
|
"poison_gas": { elem1: null },
|
||||||
},
|
},
|
||||||
tempHigh: 100,
|
tempHigh: 100,
|
||||||
|
|
@ -362,10 +355,10 @@ elements.snake = {
|
||||||
"slug": { elem2: null, func: behaviors.FEEDPIXEL },
|
"slug": { elem2: null, func: behaviors.FEEDPIXEL },
|
||||||
"snail": { elem2: "limestone", func: behaviors.FEEDPIXEL },
|
"snail": { elem2: "limestone", func: behaviors.FEEDPIXEL },
|
||||||
"egg": {
|
"egg": {
|
||||||
elem2: "egg",
|
|
||||||
func: function (pixel1, pixel2) {
|
func: function (pixel1, pixel2) {
|
||||||
if (pixel2.animal === "snake") return; // Don't eat own egg
|
if (pixel2.animal === "snake") return; // Don't eat own egg
|
||||||
behaviors.FEEDPIXEL(pixel1, pixel2);
|
behaviors.FEEDPIXEL(pixel1);
|
||||||
|
deletePixel(pixel2.x, pixel2.y)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"radiation": { elem1: ["ash", "meat", "cooked_meat", "rotten_meat", "lizard", "crocodile", null], chance: 0.4 },
|
"radiation": { elem1: ["ash", "meat", "cooked_meat", "rotten_meat", "lizard", "crocodile", null], chance: 0.4 },
|
||||||
|
|
@ -433,10 +426,10 @@ elements.crocodile = {
|
||||||
"head": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
"head": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||||
"human": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
"human": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||||
"chameleon": {
|
"chameleon": {
|
||||||
reactionFunction: function (pixel, otherPixel) {
|
func: function (pixel, otherPixel) {
|
||||||
let isNormalColor = defaultColors.includes(pixel.color);
|
let isNormalColor = defaultColors.includes(pixel.color);
|
||||||
if (otherPixel.threatened !== true || isNormalColor === true) {
|
if (otherPixel.threatened !== true || isNormalColor === true) {
|
||||||
behaviors.FEEDPIXEL(pixel, otherPixel);
|
behaviors.FEEDPIXEL(pixel);
|
||||||
deletePixel(otherPixel.x, otherPixel.y)
|
deletePixel(otherPixel.x, otherPixel.y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -704,11 +697,6 @@ elements.turtle = {
|
||||||
state: "solid",
|
state: "solid",
|
||||||
category: "life",
|
category: "life",
|
||||||
foodNeed: 10,
|
foodNeed: 10,
|
||||||
tempHigh: 100,
|
|
||||||
stateHigh: "cooked_meat",
|
|
||||||
tempLow: -10,
|
|
||||||
stateLow: "frozen_meat",
|
|
||||||
breakInto: ["scute", "blood", "meat", "limestone"],
|
|
||||||
reactions: {
|
reactions: {
|
||||||
"fish": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.1 },
|
"fish": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.1 },
|
||||||
"kelp": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.5 },
|
"kelp": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.5 },
|
||||||
|
|
@ -726,44 +714,16 @@ elements.turtle = {
|
||||||
"poison": { elem1: "limestone" },
|
"poison": { elem1: "limestone" },
|
||||||
"poison_gas": { elem1: "limestone" },
|
"poison_gas": { elem1: "limestone" },
|
||||||
},
|
},
|
||||||
}
|
tick: function (pixel) {
|
||||||
|
pixel.cd ??= 600;
|
||||||
elements.tortoise = {
|
pixel.cd--;
|
||||||
color: ["#47b000", "#406000"],
|
for (let i = 0; i < squareCoords.length; i++) {
|
||||||
behavior: [
|
let x = pixel.x + squareCoords[i][0];
|
||||||
"XX|XX|XX",
|
let y = pixel.y + squareCoords[i][1];
|
||||||
"XX|FX%1|M2%5",
|
if (isEmpty(x, y) && pixel.cd <= 0 && Math.random() <= 0.005) {
|
||||||
"M2|M1|M2",
|
createPixel("scute", x, y);
|
||||||
],
|
pixel.cd = 600;
|
||||||
density: 1080,
|
}
|
||||||
state: "solid",
|
}
|
||||||
category: "life",
|
|
||||||
foodNeed: 10,
|
|
||||||
tempHigh: 100,
|
|
||||||
stateHigh: "cooked_meat",
|
|
||||||
tempLow: -10,
|
|
||||||
stateLow: "frozen_meat",
|
|
||||||
breakInto: ["blood", "meat", "limestone"],
|
|
||||||
reactions: {
|
|
||||||
"grass": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"plant": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"evergreen": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"pistil": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"petal": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"lettuce": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"tomato": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"pumpkin": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
|
||||||
"radiation": { elem1: ["ash", "meat", "cooked_meat", "rotten_meat", "limestone"], chance: 0.4 },
|
|
||||||
"oxygen": { elem2: "carbon_dioxide", chance: 0.5 },
|
|
||||||
"mercury": { elem1: "rotten_meat", chance: 0.1 },
|
|
||||||
"bleach": { elem1: "rotten_meat", chance: 0.1 },
|
|
||||||
"infection": { elem1: "rotten_meat", chance: 0.025 },
|
|
||||||
"uranium": { elem1: "rotten_meat", chance: 0.1 },
|
|
||||||
"cyanide": { elem1: "rotten_meat", chance: 0.1 },
|
|
||||||
"chlorine": { elem1: "meat", chance: 0.1 },
|
|
||||||
"alcohol": { elem1: "meat", chance: 0.025 },
|
|
||||||
"vinegar": { elem1: "rotten_meat", chance: 0.001 },
|
|
||||||
"poison": { elem1: "limestone" },
|
|
||||||
"poison_gas": { elem1: "limestone" },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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