I just want to know how to change the “w” in this line from w to spacebar. all help is appreciated.
if(keyPress.W && ground) {
this.yspd += -this.jspd;
}
I just want to know how to change the “w” in this line from w to spacebar. all help is appreciated.
if(keyPress.W && ground) {
this.yspd += -this.jspd;
}
go to keys.js file and change this:
document.onkeypress = function(event) {
var key = (event.key).toUpperCase();
...
to
document.onkeypress = function(event) {
var key;
if (event.keyCode == 32)
key = "SPACE";
else
key = (event.key).toUpperCase();
...
save keys.js
NOTE: you will also need to change: document.onkeyup = …. to this new one (i leave it as an exercise for u to do ?)
then u can change:
if(keyPress.W && ground) {
this.yspd += -this.jspd;
}
to
if(keyPress.SPACE && ground) {
this.yspd += -this.jspd;
}
have fun ?
NOTE: you will also need to change: document.onkeyup = …. to this new one (i leave it as an exercise for u to do ?)
idk what to do, ive been trying for 2 hours…
@ddlox