key input polish
This commit is contained in:
@@ -7,7 +7,7 @@ const b = {
|
|||||||
inventoryGun: 0,
|
inventoryGun: 0,
|
||||||
inventory: [], //list of what guns player has // 0 starts with basic gun
|
inventory: [], //list of what guns player has // 0 starts with basic gun
|
||||||
fire() {
|
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) {
|
if (b.guns[b.activeGun].ammo > 0) {
|
||||||
b.guns[b.activeGun].fire();
|
b.guns[b.activeGun].fire();
|
||||||
if (mod.isCrouchAmmo && mech.crouch) {
|
if (mod.isCrouchAmmo && mech.crouch) {
|
||||||
|
|||||||
86
js/index.js
86
js/index.js
@@ -569,6 +569,18 @@ const input = {
|
|||||||
field: false, // right mouse
|
field: false, // right mouse
|
||||||
fire: false, // left mouse
|
fire: false, // left mouse
|
||||||
isPauseKeyReady: true,
|
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
|
//mouse move input
|
||||||
document.body.addEventListener("mousemove", (e) => {
|
document.body.addEventListener("mousemove", (e) => {
|
||||||
@@ -633,34 +645,58 @@ document.body.addEventListener("wheel", (e) => {
|
|||||||
passive: true
|
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) {
|
window.addEventListener("keydown", function (event) {
|
||||||
// if (event.defaultPrevented) {
|
switch (event.code) {
|
||||||
// return; // Do nothing if the event was already processed
|
case input.key.right:
|
||||||
// }
|
|
||||||
switch (event.key) {
|
|
||||||
case "d":
|
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
input.right = true
|
input.right = true
|
||||||
break;
|
break;
|
||||||
case "a":
|
case input.key.left:
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
input.left = true
|
input.left = true
|
||||||
break;
|
break;
|
||||||
case "w":
|
case input.key.up:
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
input.up = true
|
input.up = true
|
||||||
break;
|
break;
|
||||||
case "s":
|
case input.key.down:
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
input.down = true
|
input.down = true
|
||||||
break;
|
break;
|
||||||
case "e":
|
case input.key.field:
|
||||||
|
input.field = true
|
||||||
|
break
|
||||||
|
case input.key.nextGun:
|
||||||
game.nextGun();
|
game.nextGun();
|
||||||
break
|
break
|
||||||
case "q":
|
case input.key.previousGun:
|
||||||
game.previousGun();
|
game.previousGun();
|
||||||
break
|
break
|
||||||
case "p":
|
case input.key.pause:
|
||||||
if (!game.isChoosing && input.isPauseKeyReady) {
|
if (!game.isChoosing && input.isPauseKeyReady) {
|
||||||
input.isPauseKeyReady = false
|
input.isPauseKeyReady = false
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@@ -680,7 +716,7 @@ window.addEventListener("keydown", function (event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "t":
|
case input.key.testing:
|
||||||
if (game.testing) {
|
if (game.testing) {
|
||||||
game.testing = false;
|
game.testing = false;
|
||||||
game.loop = game.normalLoop
|
game.loop = game.normalLoop
|
||||||
@@ -781,32 +817,6 @@ window.addEventListener("keydown", function (event) {
|
|||||||
break
|
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);
|
}, true);
|
||||||
|
|
||||||
//**********************************************************************
|
//**********************************************************************
|
||||||
|
|||||||
@@ -795,7 +795,7 @@ const mod = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Pauli exclusion",
|
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,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
@@ -803,7 +803,7 @@ const mod = {
|
|||||||
},
|
},
|
||||||
requires: "",
|
requires: "",
|
||||||
effect() {
|
effect() {
|
||||||
mod.collisionImmuneCycles += 55;
|
mod.collisionImmuneCycles += 30;
|
||||||
mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
@@ -2660,7 +2660,7 @@ const mod = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pair production",
|
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,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
@@ -2669,7 +2669,7 @@ const mod = {
|
|||||||
requires: "nano-scale manufacturing",
|
requires: "nano-scale manufacturing",
|
||||||
effect: () => {
|
effect: () => {
|
||||||
mod.isMassEnergy = true // used in mech.grabPowerUp
|
mod.isMassEnergy = true // used in mech.grabPowerUp
|
||||||
mech.energy = mech.maxEnergy * 3
|
mech.energy = mech.maxEnergy * 2.5
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
mod.isMassEnergy = false;
|
mod.isMassEnergy = false;
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ const powerUps = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPickUp(where) {
|
onPickUp(where) {
|
||||||
if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 3;
|
if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 2.5;
|
||||||
if (mod.isMineDrop) b.mine({
|
if (mod.isMineDrop) b.mine({
|
||||||
x: where.x,
|
x: where.x,
|
||||||
y: where.y
|
y: where.y
|
||||||
|
|||||||
12
todo.txt
12
todo.txt
@@ -8,10 +8,12 @@ new key press detection system
|
|||||||
|
|
||||||
************** TODO - n-gon **************
|
************** TODO - n-gon **************
|
||||||
|
|
||||||
redo key press around e.key
|
add custom key settings
|
||||||
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
|
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
|
time dilation mod rework brain storm
|
||||||
take no damage
|
take no damage
|
||||||
@@ -19,8 +21,6 @@ time dilation mod rework brain storm
|
|||||||
2x move jump fire while field is active
|
2x move jump fire while field is active
|
||||||
33% move jump fire always
|
33% move jump fire always
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vacuum bomb applies status effect to mobs that makes blocks attracted to them
|
vacuum bomb applies status effect to mobs that makes blocks attracted to them
|
||||||
|
|
||||||
mod: take less harm if you are moving fast
|
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
|
fix door.isOpen actually meaning isClosed
|
||||||
|
|
||||||
mod - laser fires 3 beams
|
|
||||||
|
|
||||||
give missiles a suck and delay explosion, like vacuum bomb
|
give missiles a suck and delay explosion, like vacuum bomb
|
||||||
|
|
||||||
level Boss: fractal Sierpiński triangle
|
level Boss: fractal Sierpiński triangle
|
||||||
|
|||||||
Reference in New Issue
Block a user