From 01a29430fafc9964c9678f743bd2b7795a76409f Mon Sep 17 00:00:00 2001 From: landgreen Date: Fri, 9 Oct 2020 19:34:38 -0700 Subject: [PATCH] key input polish --- js/bullet.js | 2 +- js/index.js | 86 ++++++++++++++++++++++++++++----------------------- js/mods.js | 8 ++--- js/powerup.js | 2 +- todo.txt | 12 +++---- 5 files changed, 59 insertions(+), 51 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 9a41cf9..48681ea 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -7,7 +7,7 @@ const b = { inventoryGun: 0, inventory: [], //list of what guns player has // 0 starts with basic gun fire() { - if (input.fire && mech.fireCDcycle < mech.cycle && (!(input.space || input.fireRight) || mech.fieldFire) && b.inventory.length) { + if (input.fire && mech.fireCDcycle < mech.cycle && (!input.field || mech.fieldFire) && b.inventory.length) { if (b.guns[b.activeGun].ammo > 0) { b.guns[b.activeGun].fire(); if (mod.isCrouchAmmo && mech.crouch) { diff --git a/js/index.js b/js/index.js index 021cddb..e71d638 100644 --- a/js/index.js +++ b/js/index.js @@ -569,6 +569,18 @@ const input = { field: false, // right mouse fire: false, // left mouse isPauseKeyReady: true, + key: { + up: "KeyW", // jump + down: "KeyS", // crouch + left: "KeyA", + right: "KeyD", + field: "Space", + // fire: "ShiftLeft", + pause: "KeyP", + nextGun: "KeyE", + previousGun: "KeyQ", + testing: "KeyT" + } } //mouse move input document.body.addEventListener("mousemove", (e) => { @@ -633,34 +645,58 @@ document.body.addEventListener("wheel", (e) => { passive: true }); +window.addEventListener("keyup", function (event) { + switch (event.code) { + case input.key.right: + case "ArrowRight": + input.right = false + break; + case input.key.left: + case "ArrowLeft": + input.left = false + break; + case input.key.up: + case "ArrowUp": + input.up = false + break; + case input.key.down: + case "ArrowDown": + input.down = false + break; + case input.key.field: + input.field = false + break + } +}, true); + window.addEventListener("keydown", function (event) { - // if (event.defaultPrevented) { - // return; // Do nothing if the event was already processed - // } - switch (event.key) { - case "d": + switch (event.code) { + case input.key.right: case "ArrowRight": input.right = true break; - case "a": + case input.key.left: case "ArrowLeft": input.left = true break; - case "w": + case input.key.up: case "ArrowUp": input.up = true break; - case "s": + case input.key.down: case "ArrowDown": input.down = true break; - case "e": + case input.key.field: + input.field = true + break + case input.key.nextGun: game.nextGun(); break - case "q": + case input.key.previousGun: game.previousGun(); break - case "p": + case input.key.pause: if (!game.isChoosing && input.isPauseKeyReady) { input.isPauseKeyReady = false setTimeout(function () { @@ -680,7 +716,7 @@ window.addEventListener("keydown", function (event) { } } break - case "t": + case input.key.testing: if (game.testing) { game.testing = false; game.loop = game.normalLoop @@ -781,32 +817,6 @@ window.addEventListener("keydown", function (event) { break } } - // event.preventDefault(); // Cancel the default action to avoid it being handled twice -}, true); - -window.addEventListener("keyup", function (event) { - // if (event.defaultPrevented) { - // return; // Do nothing if the event was already processed - // } - switch (event.key) { - case "d": - case "ArrowRight": - input.right = false - break; - case "a": - case "ArrowLeft": - input.left = false - break; - case "w": - case "ArrowUp": - input.up = false - break; - case "s": - case "ArrowDown": - input.down = false - break; - } - // event.preventDefault(); // Cancel the default action to avoid it being handled twice }, true); //********************************************************************** diff --git a/js/mods.js b/js/mods.js index 73419b8..f1a3028 100644 --- a/js/mods.js +++ b/js/mods.js @@ -795,7 +795,7 @@ const mod = { }, { name: "Pauli exclusion", - description: `immune to harm for 1 second
after receiving harm from a collision`, + description: `immune to harm for 0.5 seconds longer
after receiving harm from a collision`, maxCount: 9, count: 0, allowed() { @@ -803,7 +803,7 @@ const mod = { }, requires: "", effect() { - mod.collisionImmuneCycles += 55; + mod.collisionImmuneCycles += 30; mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles }, remove() { @@ -2660,7 +2660,7 @@ const mod = { }, { name: "pair production", - description: "power ups overload your energy
by 300% of your maximum energy", + description: "power ups overload your energy
by 250% of your maximum energy", maxCount: 1, count: 0, allowed() { @@ -2669,7 +2669,7 @@ const mod = { requires: "nano-scale manufacturing", effect: () => { mod.isMassEnergy = true // used in mech.grabPowerUp - mech.energy = mech.maxEnergy * 3 + mech.energy = mech.maxEnergy * 2.5 }, remove() { mod.isMassEnergy = false; diff --git a/js/powerup.js b/js/powerup.js index de92a68..e809722 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -412,7 +412,7 @@ const powerUps = { } }, onPickUp(where) { - if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 3; + if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 2.5; if (mod.isMineDrop) b.mine({ x: where.x, y: where.y diff --git a/todo.txt b/todo.txt index 6586ec5..02e4436 100644 --- a/todo.txt +++ b/todo.txt @@ -8,10 +8,12 @@ new key press detection system ************** TODO - n-gon ************** -redo key press around e.key - https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent +add custom key settings + put in local storage - mouse event e.which is deprecated +give the power up boss the ability to eject your mobs if it hits you + +mouse event e.which is deprecated time dilation mod rework brain storm take no damage @@ -19,8 +21,6 @@ time dilation mod rework brain storm 2x move jump fire while field is active 33% move jump fire always - - vacuum bomb applies status effect to mobs that makes blocks attracted to them mod: take less harm if you are moving fast @@ -94,8 +94,6 @@ use mac automator to speed up your n-gon -> git sync fix door.isOpen actually meaning isClosed -mod - laser fires 3 beams - give missiles a suck and delay explosion, like vacuum bomb level Boss: fractal SierpiƄski triangle