diff --git a/gravity.js b/gravity.js new file mode 100644 index 00000000..da48e66c --- /dev/null +++ b/gravity.js @@ -0,0 +1,40 @@ +elements.gravity_point = { + color: "#FFD700", // Goudkleurig + behavior: behaviors.STURDYPOWDER, + category: "special", + state: "solid", + density: 5000, + max_gravity_distance: 100, // Bereik van zwaartekracht + gravity_strength: 1, // Kracht van zwaartekracht + + tick: function(pixel) { + for (var x = -pixel.max_gravity_distance; x <= pixel.max_gravity_distance; x++) { + for (var y = -pixel.max_gravity_distance; y <= pixel.max_gravity_distance; y++) { + var nx = pixel.x + x; + var ny = pixel.y + y; + + if (!isEmpty(nx, ny, true)) { + var npixel = pixelMap[nx][ny]; + + if (npixel && npixel.element !== "gravity_point") { + var dx = nx - pixel.x; + var dy = ny - pixel.y; + var distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < 1) distance = 1; // Voorkom delen door 0 + if (distance <= pixel.max_gravity_distance) { + var force = (pixel.gravity_strength * 100) / (distance * distance); + var angle = Math.atan2(dy, dx); + var vx = -Math.cos(angle) * force; + var vy = -Math.sin(angle) * force; + + // Voeg snelheid toe aan objecten + npixel.vx = (npixel.vx || 0) + vx; + npixel.vy = (npixel.vy || 0) + vy; + } + } + } + } + } + } +}; diff --git a/mod-list.html b/mod-list.html index 96137945..c41e32cc 100644 --- a/mod-list.html +++ b/mod-list.html @@ -160,6 +160,7 @@ extra_element_info.jsAdds descriptions to various vanilla elements. Used to provide the functionality that desc now does before it was added to vanillaMelecie extrasaveslots.jsAdds extra saves slots !SAVE IMPORTANT SAVES AS FILES!Jayd find.jsAdds a find mode that highlights a chosen element as pulsating red and yellow (read commit description)Alice +hideandshowtools.jsAdds two tools, one that hides elements, and one that shows hidden elementsMicaelNotUsed human_friendly_design.jsMakes the drag and mix tools not kill humans.Nekonico insane_random_events.jsMassively buffs random eventsAlice jaydsfunctions.jsAdds extra toolsJayd diff --git a/mods/hideandshowtools.js b/mods/hideandshowtools.js new file mode 100644 index 00000000..63a3370a --- /dev/null +++ b/mods/hideandshowtools.js @@ -0,0 +1,18 @@ +elements.hide = { + color: "#000000", + tool: function(pixel){ + pixel.alpha = 0 + }, + category: "tools", + canPlace: false, + desc: "Use on pixels to hide them.", +}; +elements.show = { + color: "#ffffff", + tool: function(pixel){ + pixel.alpha = 1 + }, + category: "tools", + canPlace: false, + desc: "Use on pixels to show them." +};