backup after input rework
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 (game.mouseDown && mech.fireCDcycle < mech.cycle && (!(keys[32] || game.mouseDownRight) || mech.fieldFire) && b.inventory.length) {
|
if (input.fire && mech.fireCDcycle < mech.cycle && (!(input.space || input.fireRight) || 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) {
|
||||||
@@ -2412,9 +2412,9 @@ const b = {
|
|||||||
this.force.y += this.mass * 0.0022;
|
this.force.y += this.mass * 0.0022;
|
||||||
|
|
||||||
//set armed and sucking status
|
//set armed and sucking status
|
||||||
if (!this.isArmed && !game.mouseDown) {
|
if (!this.isArmed && !input.fire) {
|
||||||
this.isArmed = true
|
this.isArmed = true
|
||||||
} else if (this.isArmed && game.mouseDown && !this.isSucking) {
|
} else if (this.isArmed && input.fire && !this.isSucking) {
|
||||||
this.isSucking = true;
|
this.isSucking = true;
|
||||||
this.endCycle = game.cycle + 50;
|
this.endCycle = game.cycle + 50;
|
||||||
}
|
}
|
||||||
@@ -3013,7 +3013,7 @@ const b = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!game.mouseDown && this.charge > 0.6)) { //fire on mouse release or on low energy
|
if ((!input.fire && this.charge > 0.6)) { //fire on mouse release or on low energy
|
||||||
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
|
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
|
||||||
//normal bullet behavior occurs after firing, overwrites this function
|
//normal bullet behavior occurs after firing, overwrites this function
|
||||||
this.do = function () {
|
this.do = function () {
|
||||||
|
|||||||
220
js/game.js
220
js/game.js
@@ -136,7 +136,6 @@ const game = {
|
|||||||
accelScale: null, //set in levels.setDifficulty
|
accelScale: null, //set in levels.setDifficulty
|
||||||
CDScale: null, //set in levels.setDifficulty
|
CDScale: null, //set in levels.setDifficulty
|
||||||
lookFreqScale: null, //set in levels.setDifficulty
|
lookFreqScale: null, //set in levels.setDifficulty
|
||||||
mouseDown: false,
|
|
||||||
// dropFPS(cap = 40, time = 15) {
|
// dropFPS(cap = 40, time = 15) {
|
||||||
// game.fpsCap = cap
|
// game.fpsCap = cap
|
||||||
// game.fpsInterval = 1000 / game.fpsCap;
|
// game.fpsInterval = 1000 / game.fpsCap;
|
||||||
@@ -367,167 +366,6 @@ const game = {
|
|||||||
game.boldActiveGunHUD();
|
game.boldActiveGunHUD();
|
||||||
// mech.drop();
|
// mech.drop();
|
||||||
},
|
},
|
||||||
isPauseKeyReady: true,
|
|
||||||
keyPress() { //runs on key down event
|
|
||||||
//full screen toggle
|
|
||||||
// if (keys[13]) {
|
|
||||||
// //enter key
|
|
||||||
// var doc = window.document;
|
|
||||||
// var docEl = doc.documentElement;
|
|
||||||
|
|
||||||
// var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
|
|
||||||
// var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
|
|
||||||
|
|
||||||
// if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
|
|
||||||
// requestFullScreen.call(docEl);
|
|
||||||
// } else {
|
|
||||||
// cancelFullScreen.call(doc);
|
|
||||||
// }
|
|
||||||
// setupCanvas();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//color testing
|
|
||||||
// if (keys[49]) {
|
|
||||||
// mech.color.hue--
|
|
||||||
// mech.setFillColors();
|
|
||||||
// } else if (keys[50]) {
|
|
||||||
// mech.color.hue++
|
|
||||||
// mech.setFillColors();
|
|
||||||
// } else if (keys[51]) {
|
|
||||||
// mech.color.sat--
|
|
||||||
// mech.setFillColors();
|
|
||||||
// } else if (keys[52]) {
|
|
||||||
// mech.color.sat++
|
|
||||||
// mech.setFillColors();
|
|
||||||
// } else if (keys[53]) {
|
|
||||||
// mech.color.light--
|
|
||||||
// mech.setFillColors();
|
|
||||||
// } else if (keys[54]) {
|
|
||||||
// mech.color.light++
|
|
||||||
// mech.setFillColors();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (keys[69]) { // e swap to next active gun
|
|
||||||
game.nextGun();
|
|
||||||
} else if (keys[81]) { //q swap to previous active gun
|
|
||||||
game.previousGun();
|
|
||||||
}
|
|
||||||
if (keys[80] && !game.isChoosing && game.isPauseKeyReady) { //p for pause
|
|
||||||
|
|
||||||
game.isPauseKeyReady = false
|
|
||||||
setTimeout(function () {
|
|
||||||
game.isPauseKeyReady = true
|
|
||||||
}, 300);
|
|
||||||
|
|
||||||
if (game.paused) {
|
|
||||||
build.unPauseGrid()
|
|
||||||
game.paused = false;
|
|
||||||
level.levelAnnounce();
|
|
||||||
document.body.style.cursor = "none";
|
|
||||||
requestAnimationFrame(cycle);
|
|
||||||
} else {
|
|
||||||
game.paused = true;
|
|
||||||
game.replaceTextLog = true;
|
|
||||||
// game.makeTextLog("<h1>PAUSED</h1>", 1);
|
|
||||||
//display grid
|
|
||||||
// document.title = "PAUSED: press P to resume";
|
|
||||||
build.pauseGrid()
|
|
||||||
document.body.style.cursor = "auto";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//toggle testing mode
|
|
||||||
if (keys[84]) {
|
|
||||||
// 84 = t
|
|
||||||
if (game.testing) {
|
|
||||||
game.testing = false;
|
|
||||||
game.loop = game.normalLoop
|
|
||||||
if (game.isConstructionMode) {
|
|
||||||
document.getElementById("construct").style.display = 'none'
|
|
||||||
}
|
|
||||||
} else { //if (keys[191])
|
|
||||||
game.testing = true;
|
|
||||||
game.isCheating = true;
|
|
||||||
if (game.isConstructionMode) {
|
|
||||||
document.getElementById("construct").style.display = 'inline'
|
|
||||||
}
|
|
||||||
game.loop = game.testingLoop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//in testing mode
|
|
||||||
if (game.testing) {
|
|
||||||
|
|
||||||
if (keys[79]) {
|
|
||||||
// - key
|
|
||||||
game.isAutoZoom = false;
|
|
||||||
game.zoomScale /= 0.9;
|
|
||||||
game.setZoom();
|
|
||||||
} else if (keys[73]) {
|
|
||||||
// = key
|
|
||||||
game.isAutoZoom = false;
|
|
||||||
game.zoomScale *= 0.9;
|
|
||||||
game.setZoom();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keys[192]) { // `
|
|
||||||
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "reroll");
|
|
||||||
} else if (keys[49]) { // give power ups with 1
|
|
||||||
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
|
|
||||||
} else if (keys[50]) { // 2
|
|
||||||
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "ammo");
|
|
||||||
} else if (keys[51]) { // 3
|
|
||||||
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
|
|
||||||
} else if (keys[52]) { // 4
|
|
||||||
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "field");
|
|
||||||
} else if (keys[53]) { // 5
|
|
||||||
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
|
|
||||||
} else if (keys[54]) { // 6 spawn mob
|
|
||||||
const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
|
|
||||||
spawn[pick](game.mouseInGame.x, game.mouseInGame.y);
|
|
||||||
} else if (keys[55]) { // 7 spawn body
|
|
||||||
index = body.length
|
|
||||||
spawn.bodyRect(game.mouseInGame.x, game.mouseInGame.y, 50, 50);
|
|
||||||
body[index].collisionFilter.category = cat.body;
|
|
||||||
body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
|
|
||||||
body[index].classType = "body";
|
|
||||||
World.add(engine.world, body[index]); //add to world
|
|
||||||
} else if (keys[70]) { //cycle fields with F
|
|
||||||
const mode = (mech.fieldMode === mech.fieldUpgrades.length - 1) ? 0 : mech.fieldMode + 1
|
|
||||||
mech.setField(mode)
|
|
||||||
} else if (keys[71]) { // give all guns with G
|
|
||||||
b.giveGuns("all", 1000)
|
|
||||||
} else if (keys[72]) { // heal with H
|
|
||||||
mech.addHealth(Infinity)
|
|
||||||
mech.energy = mech.maxEnergy;
|
|
||||||
} else if (keys[89]) { //add mods with y
|
|
||||||
mod.giveMod()
|
|
||||||
} else if (keys[82]) { // teleport to mouse with R
|
|
||||||
Matter.Body.setPosition(player, game.mouseInGame);
|
|
||||||
Matter.Body.setVelocity(player, {
|
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
});
|
|
||||||
// move bots to follow player
|
|
||||||
for (let i = 0; i < bullet.length; i++) {
|
|
||||||
if (bullet[i].botType) {
|
|
||||||
Matter.Body.setPosition(bullet[i], Vector.add(player.position, {
|
|
||||||
x: 250 * (Math.random() - 0.5),
|
|
||||||
y: 250 * (Math.random() - 0.5)
|
|
||||||
}));
|
|
||||||
Matter.Body.setVelocity(bullet[i], {
|
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// game.noCameraScroll()
|
|
||||||
} else if (keys[85]) { // next level with U
|
|
||||||
level.nextLevel();
|
|
||||||
} else if (keys[88] && keys[90]) {
|
|
||||||
mech.death();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
zoom: null,
|
zoom: null,
|
||||||
zoomScale: 1000,
|
zoomScale: 1000,
|
||||||
isAutoZoom: true,
|
isAutoZoom: true,
|
||||||
@@ -811,35 +649,35 @@ const game = {
|
|||||||
game.fpsCap = game.fpsCapDefault
|
game.fpsCap = game.fpsCapDefault
|
||||||
game.fpsInterval = 1000 / game.fpsCap;
|
game.fpsInterval = 1000 / game.fpsCap;
|
||||||
},
|
},
|
||||||
getCoords: {
|
// getCoords: {
|
||||||
//used when building maps, outputs a draw rect command to console, only works in testing mode
|
// //used when building maps, outputs a draw rect command to console, only works in testing mode
|
||||||
pos1: {
|
// pos1: {
|
||||||
x: 0,
|
// x: 0,
|
||||||
y: 0
|
// y: 0
|
||||||
},
|
// },
|
||||||
pos2: {
|
// pos2: {
|
||||||
x: 0,
|
// x: 0,
|
||||||
y: 0
|
// y: 0
|
||||||
},
|
// },
|
||||||
out() {
|
// out() {
|
||||||
if (keys[49]) {
|
// if (keys[49]) {
|
||||||
game.getCoords.pos1.x = Math.round(game.mouseInGame.x / 25) * 25;
|
// game.getCoords.pos1.x = Math.round(game.mouseInGame.x / 25) * 25;
|
||||||
game.getCoords.pos1.y = Math.round(game.mouseInGame.y / 25) * 25;
|
// game.getCoords.pos1.y = Math.round(game.mouseInGame.y / 25) * 25;
|
||||||
}
|
// }
|
||||||
if (keys[50]) {
|
// if (keys[50]) {
|
||||||
//press 1 in the top left; press 2 in the bottom right;copy command from console
|
// //press 1 in the top left; press 2 in the bottom right;copy command from console
|
||||||
game.getCoords.pos2.x = Math.round(game.mouseInGame.x / 25) * 25;
|
// game.getCoords.pos2.x = Math.round(game.mouseInGame.x / 25) * 25;
|
||||||
game.getCoords.pos2.y = Math.round(game.mouseInGame.y / 25) * 25;
|
// game.getCoords.pos2.y = Math.round(game.mouseInGame.y / 25) * 25;
|
||||||
window.getSelection().removeAllRanges();
|
// window.getSelection().removeAllRanges();
|
||||||
var range = document.createRange();
|
// var range = document.createRange();
|
||||||
range.selectNode(document.getElementById("test"));
|
// range.selectNode(document.getElementById("test"));
|
||||||
window.getSelection().addRange(range);
|
// window.getSelection().addRange(range);
|
||||||
document.execCommand("copy");
|
// document.execCommand("copy");
|
||||||
window.getSelection().removeAllRanges();
|
// window.getSelection().removeAllRanges();
|
||||||
console.log(`spawn.mapRect(${game.getCoords.pos1.x}, ${game.getCoords.pos1.y}, ${game.getCoords.pos2.x - game.getCoords.pos1.x}, ${game.getCoords.pos2.y - game.getCoords.pos1.y}); //`);
|
// console.log(`spawn.mapRect(${game.getCoords.pos1.x}, ${game.getCoords.pos1.y}, ${game.getCoords.pos2.x - game.getCoords.pos1.x}, ${game.getCoords.pos2.y - game.getCoords.pos1.y}); //`);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
checks() {
|
checks() {
|
||||||
if (!(mech.cycle % 60)) { //once a second
|
if (!(mech.cycle % 60)) { //once a second
|
||||||
|
|
||||||
|
|||||||
404
js/index.js
404
js/index.js
@@ -110,6 +110,39 @@ window.addEventListener('load', (event) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//set up canvas
|
||||||
|
var canvas = document.getElementById("canvas");
|
||||||
|
//using "const" causes problems in safari when an ID shares the same name.
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
document.body.style.backgroundColor = "#fff";
|
||||||
|
|
||||||
|
//disable pop up menu on right click
|
||||||
|
document.oncontextmenu = function () {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
canvas.width2 = canvas.width / 2; //precalculated because I use this often (in mouse look)
|
||||||
|
canvas.height2 = canvas.height / 2;
|
||||||
|
canvas.diagonal = Math.sqrt(canvas.width2 * canvas.width2 + canvas.height2 * canvas.height2);
|
||||||
|
// ctx.font = "18px Arial";
|
||||||
|
// ctx.textAlign = "center";
|
||||||
|
ctx.font = "25px Arial";
|
||||||
|
ctx.lineJoin = "round";
|
||||||
|
ctx.lineCap = "round";
|
||||||
|
// ctx.lineCap='square';
|
||||||
|
game.setZoom();
|
||||||
|
}
|
||||||
|
setupCanvas();
|
||||||
|
window.onresize = () => {
|
||||||
|
setupCanvas();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//build build grid display
|
//build build grid display
|
||||||
const build = {
|
const build = {
|
||||||
onLoadPowerUps() {
|
onLoadPowerUps() {
|
||||||
@@ -493,117 +526,9 @@ if (localSettings) {
|
|||||||
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
//set up canvas
|
//**********************************************************************
|
||||||
var canvas = document.getElementById("canvas");
|
// settings
|
||||||
//using "const" causes problems in safari when an ID shares the same name.
|
//**********************************************************************
|
||||||
const ctx = canvas.getContext("2d");
|
|
||||||
document.body.style.backgroundColor = "#fff";
|
|
||||||
|
|
||||||
//disable pop up menu on right click
|
|
||||||
document.oncontextmenu = function () {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupCanvas() {
|
|
||||||
canvas.width = window.innerWidth;
|
|
||||||
canvas.height = window.innerHeight;
|
|
||||||
canvas.width2 = canvas.width / 2; //precalculated because I use this often (in mouse look)
|
|
||||||
canvas.height2 = canvas.height / 2;
|
|
||||||
canvas.diagonal = Math.sqrt(canvas.width2 * canvas.width2 + canvas.height2 * canvas.height2);
|
|
||||||
// ctx.font = "18px Arial";
|
|
||||||
// ctx.textAlign = "center";
|
|
||||||
ctx.font = "25px Arial";
|
|
||||||
ctx.lineJoin = "round";
|
|
||||||
ctx.lineCap = "round";
|
|
||||||
// ctx.lineCap='square';
|
|
||||||
game.setZoom();
|
|
||||||
}
|
|
||||||
setupCanvas();
|
|
||||||
window.onresize = () => {
|
|
||||||
setupCanvas();
|
|
||||||
};
|
|
||||||
|
|
||||||
//mouse move input
|
|
||||||
document.body.addEventListener("mousemove", (e) => {
|
|
||||||
game.mouse.x = e.clientX;
|
|
||||||
game.mouse.y = e.clientY;
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.addEventListener("mouseup", (e) => {
|
|
||||||
// game.buildingUp(e); //uncomment when building levels
|
|
||||||
// game.mouseDown = false;
|
|
||||||
// console.log(e)
|
|
||||||
if (e.which === 3) {
|
|
||||||
game.mouseDownRight = false;
|
|
||||||
} else {
|
|
||||||
game.mouseDown = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.addEventListener("mousedown", (e) => {
|
|
||||||
if (e.which === 3) {
|
|
||||||
game.mouseDownRight = true;
|
|
||||||
} else {
|
|
||||||
game.mouseDown = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.addEventListener("mouseenter", (e) => { //prevents mouse getting stuck when leaving the window
|
|
||||||
// game.mouseDown = false;
|
|
||||||
// game.mouseDownRight = false;
|
|
||||||
|
|
||||||
if (e.button === 1) {
|
|
||||||
game.mouseDown = true;
|
|
||||||
} else {
|
|
||||||
game.mouseDown = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.button === 3) {
|
|
||||||
game.mouseDownRight = true;
|
|
||||||
} else {
|
|
||||||
game.mouseDownRight = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
document.body.addEventListener("mouseleave", (e) => { //prevents mouse getting stuck when leaving the window
|
|
||||||
// game.mouseDown = false;
|
|
||||||
// game.mouseDownRight = false;
|
|
||||||
// console.log(e)
|
|
||||||
if (e.button === 1) {
|
|
||||||
game.mouseDown = true;
|
|
||||||
} else {
|
|
||||||
game.mouseDown = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.button === 3) {
|
|
||||||
game.mouseDownRight = true;
|
|
||||||
} else {
|
|
||||||
game.mouseDownRight = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//keyboard input
|
|
||||||
const keys = [];
|
|
||||||
document.body.addEventListener("keydown", (e) => {
|
|
||||||
console.log(e.keyCode)
|
|
||||||
keys[e.keyCode] = true;
|
|
||||||
if (mech.alive) game.keyPress();
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.addEventListener("keyup", (e) => {
|
|
||||||
keys[e.keyCode] = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.addEventListener("wheel", (e) => {
|
|
||||||
if (!game.paused) {
|
|
||||||
if (e.deltaY > 0) {
|
|
||||||
game.nextGun();
|
|
||||||
} else {
|
|
||||||
game.previousGun();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
passive: true
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById("fps-select").addEventListener("input", () => {
|
document.getElementById("fps-select").addEventListener("input", () => {
|
||||||
let value = document.getElementById("fps-select").value
|
let value = document.getElementById("fps-select").value
|
||||||
@@ -630,7 +555,262 @@ document.getElementById("difficulty-select").addEventListener("input", () => {
|
|||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
});
|
});
|
||||||
|
|
||||||
//main loop ************************************************************
|
// ************************************************************************************************
|
||||||
|
// ************************************************************************************************
|
||||||
|
// inputs
|
||||||
|
// ************************************************************************************************
|
||||||
|
// ************************************************************************************************
|
||||||
|
|
||||||
|
const input = {
|
||||||
|
up: false, // jump
|
||||||
|
down: false, // crouch
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
|
field: false, // right mouse
|
||||||
|
fire: false, // left mouse
|
||||||
|
isPauseKeyReady: true,
|
||||||
|
}
|
||||||
|
//mouse move input
|
||||||
|
document.body.addEventListener("mousemove", (e) => {
|
||||||
|
game.mouse.x = e.clientX;
|
||||||
|
game.mouse.y = e.clientY;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.body.addEventListener("mouseup", (e) => {
|
||||||
|
// input.fire = false;
|
||||||
|
// console.log(e)
|
||||||
|
if (e.which === 3) {
|
||||||
|
input.field = false;
|
||||||
|
} else {
|
||||||
|
input.fire = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.body.addEventListener("mousedown", (e) => {
|
||||||
|
if (e.which === 3) {
|
||||||
|
input.field = true;
|
||||||
|
} else {
|
||||||
|
input.fire = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.body.addEventListener("mouseenter", (e) => { //prevents mouse getting stuck when leaving the window
|
||||||
|
if (e.button === 1) {
|
||||||
|
input.fire = true;
|
||||||
|
} else {
|
||||||
|
input.fire = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.button === 3) {
|
||||||
|
input.field = true;
|
||||||
|
} else {
|
||||||
|
input.field = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.body.addEventListener("mouseleave", (e) => { //prevents mouse getting stuck when leaving the window
|
||||||
|
if (e.button === 1) {
|
||||||
|
input.fire = true;
|
||||||
|
} else {
|
||||||
|
input.fire = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.button === 3) {
|
||||||
|
input.field = true;
|
||||||
|
} else {
|
||||||
|
input.field = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.body.addEventListener("wheel", (e) => {
|
||||||
|
if (!game.paused) {
|
||||||
|
if (e.deltaY > 0) {
|
||||||
|
game.nextGun();
|
||||||
|
} else {
|
||||||
|
game.previousGun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
passive: true
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("keydown", function (event) {
|
||||||
|
// if (event.defaultPrevented) {
|
||||||
|
// return; // Do nothing if the event was already processed
|
||||||
|
// }
|
||||||
|
switch (event.key) {
|
||||||
|
case "d":
|
||||||
|
case "ArrowRight":
|
||||||
|
input.right = true
|
||||||
|
break;
|
||||||
|
case "a":
|
||||||
|
case "ArrowLeft":
|
||||||
|
input.left = true
|
||||||
|
break;
|
||||||
|
case "w":
|
||||||
|
case "ArrowUp":
|
||||||
|
input.up = true
|
||||||
|
break;
|
||||||
|
case "s":
|
||||||
|
case "ArrowDown":
|
||||||
|
input.down = true
|
||||||
|
break;
|
||||||
|
case "e":
|
||||||
|
game.nextGun();
|
||||||
|
break
|
||||||
|
case "q":
|
||||||
|
game.previousGun();
|
||||||
|
break
|
||||||
|
case "p":
|
||||||
|
if (!game.isChoosing && input.isPauseKeyReady) {
|
||||||
|
input.isPauseKeyReady = false
|
||||||
|
setTimeout(function () {
|
||||||
|
input.isPauseKeyReady = true
|
||||||
|
}, 300);
|
||||||
|
if (game.paused) {
|
||||||
|
build.unPauseGrid()
|
||||||
|
game.paused = false;
|
||||||
|
level.levelAnnounce();
|
||||||
|
document.body.style.cursor = "none";
|
||||||
|
requestAnimationFrame(cycle);
|
||||||
|
} else {
|
||||||
|
game.paused = true;
|
||||||
|
game.replaceTextLog = true;
|
||||||
|
build.pauseGrid()
|
||||||
|
document.body.style.cursor = "auto";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "t":
|
||||||
|
if (game.testing) {
|
||||||
|
game.testing = false;
|
||||||
|
game.loop = game.normalLoop
|
||||||
|
if (game.isConstructionMode) {
|
||||||
|
document.getElementById("construct").style.display = 'none'
|
||||||
|
}
|
||||||
|
} else { //if (keys[191])
|
||||||
|
game.testing = true;
|
||||||
|
game.isCheating = true;
|
||||||
|
if (game.isConstructionMode) {
|
||||||
|
document.getElementById("construct").style.display = 'inline'
|
||||||
|
}
|
||||||
|
game.loop = game.testingLoop
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (game.testing) {
|
||||||
|
switch (event.key) {
|
||||||
|
case "o":
|
||||||
|
game.isAutoZoom = false;
|
||||||
|
game.zoomScale /= 0.9;
|
||||||
|
game.setZoom();
|
||||||
|
break;
|
||||||
|
case "i":
|
||||||
|
game.isAutoZoom = false;
|
||||||
|
game.zoomScale *= 0.9;
|
||||||
|
game.setZoom();
|
||||||
|
break
|
||||||
|
case "`":
|
||||||
|
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "reroll");
|
||||||
|
break
|
||||||
|
case "1":
|
||||||
|
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
|
||||||
|
break
|
||||||
|
case "2":
|
||||||
|
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "ammo");
|
||||||
|
break
|
||||||
|
case "3":
|
||||||
|
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
|
||||||
|
break
|
||||||
|
case "4":
|
||||||
|
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "field");
|
||||||
|
break
|
||||||
|
case "5":
|
||||||
|
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
|
||||||
|
break
|
||||||
|
case "6":
|
||||||
|
const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
|
||||||
|
spawn[pick](game.mouseInGame.x, game.mouseInGame.y);
|
||||||
|
break
|
||||||
|
case "7":
|
||||||
|
const index = body.length
|
||||||
|
spawn.bodyRect(game.mouseInGame.x, game.mouseInGame.y, 50, 50);
|
||||||
|
body[index].collisionFilter.category = cat.body;
|
||||||
|
body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
|
||||||
|
body[index].classType = "body";
|
||||||
|
World.add(engine.world, body[index]); //add to world
|
||||||
|
break
|
||||||
|
case "f":
|
||||||
|
const mode = (mech.fieldMode === mech.fieldUpgrades.length - 1) ? 0 : mech.fieldMode + 1
|
||||||
|
mech.setField(mode)
|
||||||
|
break
|
||||||
|
case "g":
|
||||||
|
b.giveGuns("all", 1000)
|
||||||
|
break
|
||||||
|
case "h":
|
||||||
|
mech.addHealth(Infinity)
|
||||||
|
mech.energy = mech.maxEnergy;
|
||||||
|
break
|
||||||
|
case "y":
|
||||||
|
mod.giveMod()
|
||||||
|
break
|
||||||
|
case "r":
|
||||||
|
Matter.Body.setPosition(player, game.mouseInGame);
|
||||||
|
Matter.Body.setVelocity(player, {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
|
});
|
||||||
|
// move bots to follow player
|
||||||
|
for (let i = 0; i < bullet.length; i++) {
|
||||||
|
if (bullet[i].botType) {
|
||||||
|
Matter.Body.setPosition(bullet[i], Vector.add(player.position, {
|
||||||
|
x: 250 * (Math.random() - 0.5),
|
||||||
|
y: 250 * (Math.random() - 0.5)
|
||||||
|
}));
|
||||||
|
Matter.Body.setVelocity(bullet[i], {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "u":
|
||||||
|
level.nextLevel();
|
||||||
|
break
|
||||||
|
case "X": //capital X to make it hard to die
|
||||||
|
mech.death();
|
||||||
|
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);
|
||||||
|
|
||||||
|
//**********************************************************************
|
||||||
|
// main loop
|
||||||
//**********************************************************************
|
//**********************************************************************
|
||||||
game.loop = game.normalLoop;
|
game.loop = game.normalLoop;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const level = {
|
|||||||
// for (let i = 0; i < 10; i++) {
|
// for (let i = 0; i < 10; i++) {
|
||||||
// mod.giveMod("laser-bot");
|
// mod.giveMod("laser-bot");
|
||||||
// }
|
// }
|
||||||
// mod.giveMod("eddy current brake")
|
// mod.giveMod("bot fabrication")
|
||||||
|
|
||||||
|
|
||||||
level.intro(); //starting level
|
level.intro(); //starting level
|
||||||
|
|||||||
48
js/player.js
48
js/player.js
@@ -223,10 +223,10 @@ const mech = {
|
|||||||
buttonCD_jump: 0, //cool down for player buttons
|
buttonCD_jump: 0, //cool down for player buttons
|
||||||
groundControl() {
|
groundControl() {
|
||||||
if (mech.crouch) {
|
if (mech.crouch) {
|
||||||
if (!(keys[83] || keys[40]) && mech.checkHeadClear() && mech.hardLandCD < mech.cycle) mech.undoCrouch();
|
if (!(input.down) && mech.checkHeadClear() && mech.hardLandCD < mech.cycle) mech.undoCrouch();
|
||||||
} else if (keys[83] || keys[40] || mech.hardLandCD > mech.cycle) {
|
} else if (input.down || mech.hardLandCD > mech.cycle) {
|
||||||
mech.doCrouch(); //on ground && not crouched and pressing s or down
|
mech.doCrouch(); //on ground && not crouched and pressing s or down
|
||||||
} else if ((keys[87] || keys[38]) && mech.buttonCD_jump + 20 < mech.cycle && mech.yOffWhen.stand > 23) {
|
} else if ((input.up) && mech.buttonCD_jump + 20 < mech.cycle && mech.yOffWhen.stand > 23) {
|
||||||
mech.buttonCD_jump = mech.cycle; //can't jump again until 20 cycles pass
|
mech.buttonCD_jump = mech.cycle; //can't jump again until 20 cycles pass
|
||||||
|
|
||||||
//apply a fraction of the jump force to the body the player is jumping off of
|
//apply a fraction of the jump force to the body the player is jumping off of
|
||||||
@@ -242,7 +242,7 @@ const mech = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys[65] || keys[37]) { //left / a
|
if (input.left) {
|
||||||
// if (game.mouseDownRight && mech.fieldCDcycle < mech.cycle && !mech.crouch) {
|
// if (game.mouseDownRight && mech.fieldCDcycle < mech.cycle && !mech.crouch) {
|
||||||
// blink(-1)
|
// blink(-1)
|
||||||
// } else {
|
// } else {
|
||||||
@@ -252,7 +252,7 @@ const mech = {
|
|||||||
player.force.x -= mech.Fx
|
player.force.x -= mech.Fx
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
} else if (keys[68] || keys[39]) { //right / d
|
} else if (input.right) {
|
||||||
// if (game.mouseDownRight && mech.fieldCDcycle < mech.cycle && !mech.crouch) {
|
// if (game.mouseDownRight && mech.fieldCDcycle < mech.cycle && !mech.crouch) {
|
||||||
// blink(1)
|
// blink(1)
|
||||||
// } else {
|
// } else {
|
||||||
@@ -280,7 +280,7 @@ const mech = {
|
|||||||
},
|
},
|
||||||
airControl() {
|
airControl() {
|
||||||
//check for short jumps //moving up //recently pressed jump //but not pressing jump key now
|
//check for short jumps //moving up //recently pressed jump //but not pressing jump key now
|
||||||
if (mech.buttonCD_jump + 60 > mech.cycle && !(keys[87] || keys[38]) && mech.Vy < 0) {
|
if (mech.buttonCD_jump + 60 > mech.cycle && !(input.up) && mech.Vy < 0) {
|
||||||
Matter.Body.setVelocity(player, {
|
Matter.Body.setVelocity(player, {
|
||||||
//reduce player y-velocity every cycle
|
//reduce player y-velocity every cycle
|
||||||
x: player.velocity.x,
|
x: player.velocity.x,
|
||||||
@@ -288,9 +288,9 @@ const mech = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys[65] || keys[37]) {
|
if (input.left) {
|
||||||
if (player.velocity.x > -mech.airSpeedLimit / player.mass / player.mass) player.force.x -= mech.FxAir; // move player left / a
|
if (player.velocity.x > -mech.airSpeedLimit / player.mass / player.mass) player.force.x -= mech.FxAir; // move player left / a
|
||||||
} else if (keys[68] || keys[39]) {
|
} else if (input.right) {
|
||||||
if (player.velocity.x < mech.airSpeedLimit / player.mass / player.mass) player.force.x += mech.FxAir; //move player right / d
|
if (player.velocity.x < mech.airSpeedLimit / player.mass / player.mass) player.force.x += mech.FxAir; //move player right / d
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -860,7 +860,7 @@ const mech = {
|
|||||||
},
|
},
|
||||||
throwBlock() {
|
throwBlock() {
|
||||||
if (mech.holdingTarget) {
|
if (mech.holdingTarget) {
|
||||||
if (keys[32] || game.mouseDownRight) {
|
if (input.field) {
|
||||||
if (mech.energy > 0.001) {
|
if (mech.energy > 0.001) {
|
||||||
if (mech.fireCDcycle < mech.cycle) mech.fireCDcycle = mech.cycle
|
if (mech.fireCDcycle < mech.cycle) mech.fireCDcycle = mech.cycle
|
||||||
mech.energy -= 0.001 / mod.throwChargeRate;
|
mech.energy -= 0.001 / mod.throwChargeRate;
|
||||||
@@ -1234,7 +1234,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
} else if ((input.field && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
if (mech.energy > 0.05) {
|
if (mech.energy > 0.05) {
|
||||||
@@ -1261,7 +1261,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed
|
} else if ((input.field) && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
} else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle) { //holding, but field button is released
|
} else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle) { //holding, but field button is released
|
||||||
@@ -1311,7 +1311,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
} else if ((input.field && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
if (mech.energy > 0.05) {
|
if (mech.energy > 0.05) {
|
||||||
@@ -1405,7 +1405,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
} else if ((input.field && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
if (mech.energy > 0.05) {
|
if (mech.energy > 0.05) {
|
||||||
@@ -1441,7 +1441,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //push away
|
} else if (input.field && mech.fieldCDcycle < mech.cycle) { //push away
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
const DRAIN = 0.00035
|
const DRAIN = 0.00035
|
||||||
@@ -1474,12 +1474,12 @@ const mech = {
|
|||||||
// zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit
|
// zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit
|
||||||
// zeroG(mob); //mobs are too irregular to make this work?
|
// zeroG(mob); //mobs are too irregular to make this work?
|
||||||
|
|
||||||
if (keys[83] || keys[40]) { //down
|
if (input.down) { //down
|
||||||
player.force.y -= 0.5 * player.mass * game.g;
|
player.force.y -= 0.5 * player.mass * game.g;
|
||||||
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 400 * 0.03;
|
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 400 * 0.03;
|
||||||
zeroG(powerUp, this.fieldDrawRadius, 0.7);
|
zeroG(powerUp, this.fieldDrawRadius, 0.7);
|
||||||
zeroG(body, this.fieldDrawRadius, 0.7);
|
zeroG(body, this.fieldDrawRadius, 0.7);
|
||||||
} else if (keys[87] || keys[38]) { //up
|
} else if (input.up) { //up
|
||||||
mech.energy -= 5 * DRAIN;
|
mech.energy -= 5 * DRAIN;
|
||||||
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 850 * 0.03;
|
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 850 * 0.03;
|
||||||
player.force.y -= 1.45 * player.mass * game.g;
|
player.force.y -= 1.45 * player.mass * game.g;
|
||||||
@@ -1497,7 +1497,7 @@ const mech = {
|
|||||||
mech.energy = 0;
|
mech.energy = 0;
|
||||||
}
|
}
|
||||||
//add extra friction for horizontal motion
|
//add extra friction for horizontal motion
|
||||||
if (keys[65] || keys[68] || keys[37] || keys[39]) {
|
if (input.down || input.up || input.left || input.right) {
|
||||||
Matter.Body.setVelocity(player, {
|
Matter.Body.setVelocity(player, {
|
||||||
x: player.velocity.x * 0.99,
|
x: player.velocity.x * 0.99,
|
||||||
y: player.velocity.y * 0.98
|
y: player.velocity.y * 0.98
|
||||||
@@ -1552,7 +1552,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed
|
} else if (input.field && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
const DRAIN = 0.002
|
const DRAIN = 0.002
|
||||||
@@ -1710,7 +1710,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) {
|
} else if (input.field && mech.fieldCDcycle < mech.cycle) {
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp(180);
|
mech.lookForPickUp(180);
|
||||||
|
|
||||||
@@ -1807,7 +1807,7 @@ const mech = {
|
|||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
mech.throwBlock();
|
mech.throwBlock();
|
||||||
} else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < mech.cycle)) { //not hold and field button is pressed
|
} else if (input.field && mech.fieldCDcycle < mech.cycle) { //not hold and field button is pressed
|
||||||
mech.grabPowerUp();
|
mech.grabPowerUp();
|
||||||
mech.lookForPickUp();
|
mech.lookForPickUp();
|
||||||
} else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle) { //holding target exists, and field button is not pressed
|
} else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle) { //holding target exists, and field button is not pressed
|
||||||
@@ -1869,7 +1869,7 @@ const mech = {
|
|||||||
const wiggle = 0.15 * Math.sin(mech.fieldPhase * 0.5)
|
const wiggle = 0.15 * Math.sin(mech.fieldPhase * 0.5)
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.ellipse(mech.pos.x, mech.pos.y, mech.fieldDrawRadius * (1 - wiggle), mech.fieldDrawRadius * (1 + wiggle), mech.fieldPhase, 0, 2 * Math.PI);
|
ctx.ellipse(mech.pos.x, mech.pos.y, mech.fieldDrawRadius * (1 - wiggle), mech.fieldDrawRadius * (1 + wiggle), mech.fieldPhase, 0, 2 * Math.PI);
|
||||||
if (mech.fireCDcycle > mech.cycle && (keys[32] || game.mouseDownRight)) {
|
if (mech.fireCDcycle > mech.cycle && (input.field)) {
|
||||||
ctx.lineWidth = 5;
|
ctx.lineWidth = 5;
|
||||||
ctx.strokeStyle = `rgba(0, 204, 255,1)`
|
ctx.strokeStyle = `rgba(0, 204, 255,1)`
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
@@ -1947,7 +1947,7 @@ const mech = {
|
|||||||
// const off2 = 1 - 0.06 * Math.sin(mech.fieldPhase);
|
// const off2 = 1 - 0.06 * Math.sin(mech.fieldPhase);
|
||||||
// ctx.beginPath();
|
// ctx.beginPath();
|
||||||
// ctx.ellipse(mech.pos.x, mech.pos.y, radius * off1, radius * off2, rotate, 0, 2 * Math.PI);
|
// ctx.ellipse(mech.pos.x, mech.pos.y, radius * off1, radius * off2, rotate, 0, 2 * Math.PI);
|
||||||
// if (mech.fireCDcycle > mech.cycle && (keys[32] || game.mouseDownRight)) {
|
// if (mech.fireCDcycle > mech.cycle && (input.field)) {
|
||||||
// ctx.lineWidth = 5;
|
// ctx.lineWidth = 5;
|
||||||
// ctx.strokeStyle = `rgba(0, 204, 255,1)`
|
// ctx.strokeStyle = `rgba(0, 204, 255,1)`
|
||||||
// ctx.stroke()
|
// ctx.stroke()
|
||||||
@@ -1969,7 +1969,7 @@ const mech = {
|
|||||||
// mech.drawHold(mech.holdingTarget);
|
// mech.drawHold(mech.holdingTarget);
|
||||||
// mech.holding();
|
// mech.holding();
|
||||||
// mech.throwBlock();
|
// mech.throwBlock();
|
||||||
// } else if (keys[32] || game.mouseDownRight) {
|
// } else if (input.field) {
|
||||||
// mech.grabPowerUp();
|
// mech.grabPowerUp();
|
||||||
// mech.lookForPickUp();
|
// mech.lookForPickUp();
|
||||||
|
|
||||||
@@ -2083,7 +2083,7 @@ const mech = {
|
|||||||
mech.fieldRadius = 0;
|
mech.fieldRadius = 0;
|
||||||
mech.drop();
|
mech.drop();
|
||||||
mech.hold = function () {
|
mech.hold = function () {
|
||||||
if (keys[32] || game.mouseDownRight) {
|
if (input.field) {
|
||||||
if (mech.fieldCDcycle < mech.cycle) {
|
if (mech.fieldCDcycle < mech.cycle) {
|
||||||
const scale = 25
|
const scale = 25
|
||||||
const bounds = {
|
const bounds = {
|
||||||
|
|||||||
5
todo.txt
5
todo.txt
@@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
ice IX thermoelectric energy 66% -> 100%, heal 3%->4%
|
ice IX thermoelectric energy 66% -> 100%, heal 3%->4%
|
||||||
|
|
||||||
|
new key press detection system
|
||||||
|
I rewrote some fundamental systems so there may be some bugs
|
||||||
|
testing mode death is now shift X (was x+z)
|
||||||
|
|
||||||
************** TODO - n-gon **************
|
************** TODO - n-gon **************
|
||||||
|
|
||||||
redo key press around e.key
|
redo key press around e.key
|
||||||
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
|
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
|
||||||
|
|
||||||
|
mouse event e.which is deprecated
|
||||||
|
|
||||||
time dilation mod rework brain storm
|
time dilation mod rework brain storm
|
||||||
take no damage
|
take no damage
|
||||||
can fire
|
can fire
|
||||||
|
|||||||
Reference in New Issue
Block a user