From 672db7654b013da8d9f68ea871005e5f12f9b725 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Sat, 24 Aug 2024 20:12:24 -0400 Subject: [PATCH 1/3] ye --- mods/subspace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/subspace.js b/mods/subspace.js index 3230b879..3604159c 100644 --- a/mods/subspace.js +++ b/mods/subspace.js @@ -2,7 +2,7 @@ function playSubspace(file) { var audio = new Audio("https://JustAGenericUsername.github.io/" + file + ".mp3"); audio.play(); } -elements.subspace_trimpine = { +elements.subspace_tripmine = { color: "#2e2430", behavior: behaviors.STURDYPOWDER, maxSize: 1, From a060db0cfe018df059738b0c1fc0194cb91566ed Mon Sep 17 00:00:00 2001 From: jakob3797 <167775393+jakob3797@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:53:01 -0500 Subject: [PATCH 2/3] Create Inators.js Working/tested --- mods/Inators.js | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 mods/Inators.js diff --git a/mods/Inators.js b/mods/Inators.js new file mode 100644 index 00000000..46b8ff76 --- /dev/null +++ b/mods/Inators.js @@ -0,0 +1,108 @@ +elements.explodeinator = { + color: "#ff0000", + behaviorOn: behaviors.WALL, + behavior: [ + "CR:steel|CR:steel|CR:brick|CR:wall|CR:wall", + "XX|DL|CR:beamcr|CR:wire|CR:wall", + "CR:steel|CR:brick|CR:wire|CR:wire|CR:wire|CR:sensor" + ], + category: "lab", + state: "solid", + }; + elements.explodeinator_beam = { + color: "#ff0000", + behavior: [ + "XX|XX|XX", + "M1|DL%0.25|XX", + "XX|XX|XX", + ], + tick: behaviors.wall, + reactions: { + "": { "elem2":"explosion", "chance": 100 }, + "wall": { "elem2":"explosion", "chance": 100 }, + }, + temp: 35, + tempLow: -273, + stateLow: ["liquid_light",null], + stateLowColorMultiplier: 0.8, + breakInto: ["explosion"], + properties: { + flipY: false, + speed: 5, + fall: 0, + attached: false, + attachOffsets: [null, null], + penetrateCounter: 7, + }, + breakInto: "light", + breakIntoColor: "#ffcfcf", + category: "energy", + state: "gas", + density: 0.00001, + ignoreAir: true + }; + elements.beamcr = { + behavior: behaviors.WALL, + behaviorOn: [ + "XX|XX|XX", + "CR:explodeinator_beam|XX|XX", + "XX|XX|XX", + ], + color: "#fadecd", + category: "machines", + conduct: 1 + } +elements.acidinator2 = { + color: "#ff0000", + behaviorOn: behaviors.WALL, + behavior: [ + "CR:steel|CR:steel|CR:brick|CR:wall|CR:wall", + "XX|DL|CR:beamcr2|CR:wire|CR:wall", + "CR:steel|CR:brick|CR:wire|CR:wire|CR:wire|CR:sensor" + ], + category: "lab", + state: "solid", + }; + elements.acidinator_beam2 = { + color: "#ff0000", + behavior: [ + "XX|XX|XX", + "M1|DL%0.25|XX", + "XX|XX|XX", + ], + tick: behaviors.wall, + reactions: { + "head": { "elem2":"acid", "chance": 100 }, + "wall": { "elem2":"acid", "chance": 100 }, + }, + temp: 35, + tempLow: -273, + stateLow: ["liquid_light",null], + stateLowColorMultiplier: 0.8, + breakInto: ["explosion"], + properties: { + flipY: false, + speed: 5, + fall: 0, + attached: false, + attachOffsets: [null, null], + penetrateCounter: 7, + }, + breakInto: "light", + breakIntoColor: "#ffcfcf", + category: "energy", + state: "gas", + density: 0.00001, + ignoreAir: true + }; + elements.beamcr2 = { + behavior: behaviors.WALL, + behaviorOn: [ + "XX|XX|XX", + "CR:acidinator_beam2|XX|XX", + "XX|XX|XX", + ], + color: "#fadecd", + category: "machines", + conduct: 1 + } From d139c2ccfbf2590aabce346fe9783572968e857b Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Fri, 13 Sep 2024 20:59:13 -0400 Subject: [PATCH 3/3] scenexe mod --- mod-list.html | 1 + mods/scenexe.js | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 mods/scenexe.js diff --git a/mod-list.html b/mod-list.html index 8ce35e97..d820f5ac 100644 --- a/mod-list.html +++ b/mod-list.html @@ -376,6 +376,7 @@ randomness_but_tick.jsRandom experimental elements using the tick function featureAlice randomness_but_tool.jsRandom experimental elements using the tool function featureAlice randomness.jsRandom experimental elementsAlice +scenexe.jsWork-in-progress mod, renders and simulates a bunch of polygonsnousernamefound structure_test_2.jsAnother test for implementing structures into Sandboxels (requires the previous test)Alice structure_test.jsA test for implementing structures into SandboxelsAlice test.jsA test mod that adds mayo :)R74n diff --git a/mods/scenexe.js b/mods/scenexe.js new file mode 100644 index 00000000..9fa9ac32 --- /dev/null +++ b/mods/scenexe.js @@ -0,0 +1,144 @@ +polygonColors = function(sides){ + let baseColors = [ + { r: 255, g: 228, b: 107 }, + { r: 252, g: 118, b: 118 }, + { r: 118, g: 140, b: 252 }, + { r: 252, g: 166, b: 68 }, + { r: 56, g: 183, b: 100 }, + { r: 74, g: 102, b: 189 }, + { r: 93, g: 39, b: 93 }, + { r: 26, g: 28, b: 44 }, + { r: 6, g: 0, b: 17 }, + { r: 64, g: 54, b: 69 }, + { r: 237, g: 237, b: 255 }, + { r: 0, g: 0, b: 0 }, + ] + if (sides <= 14 && sides >= 3){ + return baseColors[Math.round(sides)-3] + } else { + return {r: 0, g: 0, b: 0} + } +} +function polygonCount(random){ + const thresholds = [0, 0.3, 0.68, 0.77, 0.82, 0.86, 0.88, 0.89, 0.895, 0.8975, 0.898, 0.8982, 1]; + const values = [3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 3]; + + for (let i = 0; i < thresholds.length; i++) { + if (random < thresholds[i]) { + return values[i]; + } + } +} +polygonList = [] +zoomLevel = .2 +polygonSize = function(sides){ + return 18 * Math.pow(1.47, sides - 3) +} +for (var i = 0; i <= 400; i++){ + sides = polygonCount(Math.random()) + polygonList.push({ + sides: sides, + radius: polygonSize(sides), + x: (Math.random() * 5000)-2500, + y: (Math.random() * 5000)-2500, + vx: 0, + vy: 0, + random: Math.random(), + rotation: Math.random() * 2 * Math.PI, + }) +} +function drawPolygon(ctx, polygon){ + let x = polygon.x + let y = polygon.y + let sides = polygon.sides + let radius = polygon.radius + let rotation = polygon.rotation + let vx = polygon.vx + let vy = polygon.vy + ctx.lineJoin = 'round'; + ctx.fillStyle = "rgb(" + polygonColors(sides).r + ", " + polygonColors(sides).g + ", " + polygonColors(sides).b + ")" + ctx.strokeStyle = "rgb(" + Math.max(polygonColors(sides).r - 30, 0) + ", " + Math.max(polygonColors(sides).g - 30, 0) + ", " + Math.max(polygonColors(sides).b - 30, 0) + ")" + ctx.lineWidth = 5*zoomLevel + ctx.beginPath() + ctx.moveTo(Math.sin(rotation)*radius+x, Math.cos(rotation)*radius+y) + for (var i = 0; i <= sides+1; i++){ + ctx.lineTo(Math.sin(rotation+2*Math.PI*i/sides)*radius+x, Math.cos(rotation+2*Math.PI*i/sides)*radius+y) + } + ctx.fill() + ctx.stroke() + // debug + /* + // draw a line to represent angle + ctx.beginPath() + ctx.moveTo(x, y) + ctx.lineTo(Math.sin(rotation)*2*radius+x, Math.cos(rotation)*2*radius+y) + ctx.strokeStyle = "rgb(0, 0, 255)" + ctx.stroke() + // draw a line to represent velocity + ctx.beginPath() + ctx.moveTo(x, y) + ctx.lineTo(x+20*vx, y+20*vy) + ctx.strokeStyle = "rgb(255, 0, 0)" + ctx.stroke() + */ +} +function zoom(ctx, poly, multiplier){ + polyreturn = {...poly} + polyreturn.x = polyreturn.x * multiplier + ctx.canvas.width/2 + polyreturn.y = polyreturn.y * multiplier + ctx.canvas.height/2 + polyreturn.radius = polyreturn.radius * multiplier + return polyreturn +} +renderPostPixel(function(ctx){ + ctx.fillStyle = "rgb(205, 205, 205)" + ctx.fillRect(0, 0, canvas.width, canvas.height) + ctx.strokeStyle = "rgb(200, 200, 200)" + ctx.lineWidth = 5*zoomLevel + for (var i = 0; i < canvas.width; i += canvas.width/30*zoomLevel){ + ctx.beginPath() + ctx.moveTo(i, canvas.height) + ctx.lineTo(i, 0) + ctx.stroke() + } + for (var j = 0; j < canvas.height; j += canvas.width/30*zoomLevel){ + ctx.beginPath() + ctx.moveTo(0, j) + ctx.lineTo(canvas.width, j) + ctx.stroke() + } + //drawPolygon(ctx, Math.round((pixelTicks/20)%13)+3, polygonSize(Math.round((pixelTicks/20)%13)+3), canvas.width/2, canvas.height/2, 0) + for (var poly = 0; poly < polygonList.length; poly++){ + drawPolygon(ctx, zoom(ctx, polygonList[poly], zoomLevel)) + } + // polygon collision checking + for (var poly = 0; poly < polygonList.length; poly++){ + for (var poly2 = 0; poly2 < polygonList.length; poly2++){ + if (poly != poly2){ + polygon1 = polygonList[poly] + polygon2 = polygonList[poly2] + distance = Math.sqrt((polygon1.x - polygon2.x)**2 + (polygon1.y - polygon2.y)**2) + if (distance < polygonSize(polygon1.sides) + polygonSize(polygon2.sides)){ + //calculate angle of collision + angle = Math.atan2(polygon2.y - polygon1.y, polygon2.x - polygon1.x) + // update velocity + polygon1.vx -= (Math.cos(angle) * (polygonSize(polygon1.sides) + polygonSize(polygon2.sides) - distance)/2)/(3+polygonSize(polygon1.sides)/9) + polygon1.vy -= (Math.sin(angle) * (polygonSize(polygon1.sides) + polygonSize(polygon2.sides) - distance)/2)/(3+polygonSize(polygon1.sides)/9) + } + } + } + } + // move polygons + for (var poly = 0; poly < polygonList.length; poly++){ + let polygon = polygonList[poly] + if (polygon.vx || polygon.vy){ + polygon.x += polygon.vx + polygon.y += polygon.vy + polygon.vx *= 0.8 + polygon.vy *= 0.8 + } + polygon.rotation += 1.00672*Math.pow(0.344151, polygon.sides) + 0.000002 + // add some velocity towards wherever its facing + polygon.vx += Math.sin(polygon.rotation)*(1.00672*Math.pow(0.344151, polygon.sides) + 0.000002)*8 + polygon.vy += Math.cos(polygon.rotation)*(1.00672*Math.pow(0.344151, polygon.sides) + 0.000002)*8 + } +}) \ No newline at end of file