key input polish
This commit is contained in:
@@ -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) {
|
||||
|
||||
86
js/index.js
86
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);
|
||||
|
||||
//**********************************************************************
|
||||
|
||||
@@ -795,7 +795,7 @@ const mod = {
|
||||
},
|
||||
{
|
||||
name: "Pauli exclusion",
|
||||
description: `<strong>immune</strong> to <strong class='color-harm'>harm</strong> for <strong>1</strong> second<br>after receiving <strong class='color-harm'>harm</strong> from a collision`,
|
||||
description: `<strong>immune</strong> to <strong class='color-harm'>harm</strong> for <strong>0.5</strong> seconds longer<br>after receiving <strong class='color-harm'>harm</strong> 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: "<strong>power ups</strong> overload your <strong class='color-f'>energy</strong><br>by <strong>300%</strong> of your maximum <strong class='color-f'>energy</strong>",
|
||||
description: "<strong>power ups</strong> overload your <strong class='color-f'>energy</strong><br>by <strong>250%</strong> of your maximum <strong class='color-f'>energy</strong>",
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
12
todo.txt
12
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
|
||||
|
||||
Reference in New Issue
Block a user