I'm trying to make a Megaman-style wall jump in my 2D platform game with JavaScript.
The character can do A,B,C motions when it sticks the wall:
My problem is that when I trying to jump off the wall(motion C), it goes to motion A or B first, C was not happened. I think the keyboard input was conflict but I have no idea how to handle it.
Here is my current code:
if(key['right'] && key['jump']) {//it doesn't work
//jump off the wall
} else if(key['right']) {
//leave the wall
} else if(key['left']) {
//stick the wall
} else {//release all keys
//falling down
}
Please, Any help would be appreciated.