これは、最初にトリガーされたときに魔法のように機能します。しかしその後は、トリガーされるたびに playerYPos が 8 ずつ増加します。考えられることはすべて試しましたが、理由がわかりません。
var playerYPos = 188;
var playerJumpSpeed = 8;
var playerJumpVelocity = playerJumpSpeed;
function jump(){
playerYPos -= playerJumpVelocity;
//Hits top
if(playerYPos < 40){
playerJumpVelocity = -playerJumpSpeed;
}
if(playerYPos >= 188){
keyW = false;
}
}
どんな助けでも大歓迎です!