From dbac3886763f0338a8baa7d9431e0cf0de55508b Mon Sep 17 00:00:00 2001 From: O-01-67 <68935009+O-01-67@users.noreply.github.com> Date: Tue, 24 May 2022 13:56:31 -0400 Subject: [PATCH] Test controllable pixel Read description **Uses keyboard; not likely to work on mobile** ##Notes This *will* move if you are typing in a menu, but not in an alert. Non-shifted presses will behave *unpredictably* if there are multiple pixels. Shift-hold presses will behave more predictably. Using multiple pixels is not supported. The pixel has a state of "solid" and a density of 2. It might be able to move through liquids and gases according to this density. ##Controls## WASD to move Z to shock X to explode Hold shift to repeat action Q to stop repetition if it doesn't stop after you let go of shift --- mods/controllable_pixel_test.js | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 mods/controllable_pixel_test.js diff --git a/mods/controllable_pixel_test.js b/mods/controllable_pixel_test.js new file mode 100644 index 00000000..0ec30b38 --- /dev/null +++ b/mods/controllable_pixel_test.js @@ -0,0 +1,86 @@ +sussyKey = null, + +document.addEventListener("keyup", function(sussyListener) { + switch (sussyListener.keyCode) { + case 87: + sussyKey = "W"; + break; + case 65: + sussyKey = "A"; + break; + case 83: + sussyKey = "S"; + break; + case 68: + sussyKey = "D"; + break; + case 81: + sussyKey = "Q"; + break; + case 88: + sussyKey = "X"; + break; + case 90: + sussyKey = "Z"; + break; + }; +}); + +elements.controllable_pixel = { + color: "#FFFFFF", + colorOn: "#FFFF00", + behavior: behaviors.WALL, + state: "solid", + density: 2000, + conduct: 1, + hardness: 1, + tick: function(pixel) { + var xx = pixel.x + var yy = pixel.y + if(sussyKey !== null) { + switch (sussyKey) { + case "W": + tryMove(pixel,xx,yy-1) + if(shiftDown === 0) { + sussyKey = null; + } + break; + case "A": + tryMove(pixel,xx-1,yy) + if(shiftDown === 0) { + sussyKey = null; + } + break; + case "S": + tryMove(pixel,xx,yy+1) + if(shiftDown === 0) { + sussyKey = null; + } + break; + case "D": + tryMove(pixel,xx+1,yy) + if(shiftDown === 0) { + sussyKey = null; + } + break; + case "X": + explodeAt(xx,yy,4) + if(shiftDown === 0) { + sussyKey = null; + } + break; + case "Z": + if (!pixel.charge && !pixel.chargeCD && !isEmpty(pixel.x,pixel.y,true)) { + pixel.charge = 1; + } + if(shiftDown === 0) { + sussyKey = null; + } + break; + case "Q": + sussyKey = null; + break; + } + } + }, +}