Help with implementing smooth mario movement
Instead of having `leftSpeed' and `rightSpeed', combine them into a single `horizontalSpeed' (probably set to be `leftSpeed - rightSpeed'), and use that in your logic.
What alvaro said. Besides what happens when the user presses both a and d (left and right). With ur code, it'll move right. If u remove the else om the 2nd if, and use speed, the resulting speed will be 0.
I generally handle the input as a vector.
Instead of direct cause to effect (movement occurs as you click), I use an additionnal layer:
When I click, I apply force in a direction.
I have a background process that tries to simulate inertia (progressively) by nullifying all vectors over time.
So, if I tap a direction, the move begins, and slows down into position.
You can see it in action here:
Notice how my 'direction' doesn't affect my vector and that it dies out of its own accord?
It is possible to apply something similar for your program.
Unfortunately, I am not familiar with the syntax you are using...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement