You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.3 KiB

2 years ago
"use strict"
function keyPressed(){
if (!game) return false;
if (!game.ready) return false;
switch(keyCode){
case LEFT_ARROW:
game.player.walk(-1);
break;
case RIGHT_ARROW:
game.player.walk(1);
break;
case UP_ARROW:
game.player.jump();
break;
case DOWN_ARROW:
game.player.fall(1);
break;
case 68: //D
debug = !debug;
break;
case 78: //N
loadNewGame();
break;
case 76: //L
game.lost();
break;
case 27: //ESC
case 9: //TAB
toggleMenu($("#menuOpener"));
break;
case 32: //Spacebar
game.toggleRun();
break;
}
return false;
}
function keyReleased(){
if (!game) return false;
if (!game.ready) return true;
switch(keyCode){
case LEFT_ARROW:
if (!keyIsDown(RIGHT_ARROW)) game.player.break();
break;
case RIGHT_ARROW:
if (!keyIsDown(LEFT_ARROW)) game.player.break();
break;
case DOWN_ARROW:
game.player.fall(-1);
break;
}
}
function mouseMoved(){
globalCursor ? globalCursor.standStillTime = 0 : null;
}
function mouseDragged(){
}
function mousePressed(){
}
function mouseReleased(){
}
window.onresize = function(){
let i = 0;
function resize(){
resizeCanvas($("#canvasHolder").outerWidth(), $("#canvasHolder").outerHeight(), true);
i++;
if (i < 5) window.setTimeout(resize, 0);
}
resize();
}