From cedc5c7c436e0fcd00d17bd1a11e6fab07c90db1 Mon Sep 17 00:00:00 2001 From: Lily-129 <68935009+Lily-129@users.noreply.github.com> Date: Fri, 4 Mar 2022 11:40:07 -0500 Subject: [PATCH] pushing machines each of which pushes pixels in a certain direction --- mods/pushers.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 mods/pushers.js diff --git a/mods/pushers.js b/mods/pushers.js new file mode 100644 index 00000000..b6d9a89e --- /dev/null +++ b/mods/pushers.js @@ -0,0 +1,55 @@ +elements.up_pusher = { + color: "#7f7f7f", + tick: function(pixel) { + for(i=9; i>=0; i--) { + if (!isEmpty(pixel.x,pixel.y-1-i,true)) { + tryMove(pixelMap[pixel.x][pixel.y-1-i],pixel.x,pixel.y-2-i) + } + } + }, + category: "machines", + insulate: true, + state: "solid", +} + +elements.down_pusher = { + color: "#7f7f7f", + tick: function(pixel) { + for(i=9; i>=0; i--) { + if (!isEmpty(pixel.x,pixel.y+1+i,true)) { + tryMove(pixelMap[pixel.x][pixel.y+1+i],pixel.x,pixel.y+2+i) + } + } + }, + category: "machines", + insulate: true, + state: "solid", +} + +elements.left_pusher = { + color: "#7f7f7f", + tick: function(pixel) { + for(i=9; i>=0; i--) { + if (!isEmpty(pixel.x-1-i,pixel.y,true)) { + tryMove(pixelMap[pixel.x-1-i][pixel.y],pixel.x-2-i,pixel.y) + } + } + }, + category: "machines", + insulate: true, + state: "solid", +} + +elements.right_pusher = { + color: "#7f7f7f", + tick: function(pixel) { + for(i=9; i>=0; i--) { + if (!isEmpty(pixel.x+1+i,pixel.y,true)) { + tryMove(pixelMap[pixel.x+1+i][pixel.y],pixel.x+2+i,pixel.y) + } + } + }, + category: "machines", + insulate: true, + state: "solid", +} \ No newline at end of file