I'm honestly not sure what exactly is giving you issues, but one thought is to maybe define the "checks" as their own function, for example:
function chooseMovement() {
if(checkMoveRight()) {
Right();
} else if((playerLeft + 64) < enemyLeft) {
Left();
} else if((playerTop + 64) < enemyTop) {
Up();
} else if((playerTop - 64) > enemyTop) {
Down();
} else {
damagePlayer();
}
}
function checkMoveRight(){
if(playerLeft - 64 > enemyLeft){ return true }
if(WallLeft - 64 != enemyLeft){ return true }
return false
}
This introduces it's own set of problems when it comes to complexity and state and what not but extracting things out into their own definitions rather than trying to have everything exist in the primary/singular if/else call thread might be useful.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…