6
\$\begingroup\$

I've read this wall jumping question but I'm having trouble implementing it. I've gotten as far as implementing a timer that controls when wall jumping is possible. Right now, if I go up against a wall, then jump, I'll have a timer that will later run out (and then I won't be able to wall jump in mid air).

However, I'm not sure how to implement it. I see two problems here - one is to determine the direction the player should go, and how to cancel out the effects of holding down a directional arrow key and counteracting the velocity I would apply when I jump off the wall. Also, I'm having troubles of determining when I hit another wall, so I can wall jump again.

\$\endgroup\$
4
\$\begingroup\$

This is pretty dependent on how you're doing your collision detection. For example, for the "direction" question ... if you define your levels as polygons and do your collision detection that way, then it would be pretty trivial to determine the perpendicular vector to the line that you are colliding with ... that would be the direction that you would "jump" in.

For the effects of holding down the arrow key, ideally you would do nothing. Once you determine the direction of the jump, you would change the player's velocity in that direction to propel them. Once they are in the air after they've done the wall jump, why shouldn't the arrow keys affect their trajectory? I mean, of course that entirely matters on your game's control scheme since some games don't let you control the character in the air ... but even in that case, the default behavior should handle it because input would be disabled while in the air.

as to the question about how to determine when you hit another wall ... this shouldn't be a problem, and if it is it's indicative of an issue with the code's design. You should really put this logic inside of some sort of "Entity". Good object oriented design isn't a panacea, but it can go a long way to mitigating the complexities of a system like a game.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.