I had a second look at you code. I don't have the solution, but some ideas how to find the mistake.Uhfgood wrote:The jumping does work this way, but the jump velocity should be 0 when you're not jumping which means hopefully nothing extra gets added when you're not jumping.
In the collision checking step you first calculate the dy, which tell you, if the player moves up or down. As far as I understood your code, the dy does not contain information, if the up/down movement is caused by slopes. In other words, when I run up a slope, the code believes, i move downwards, because dy tells me so. In the collision part, the y-coordinate is simply set to the top of the slope. y-Velocty itself is not changed. This is my best guess of the error.
However, if you change y-Velocity here, the player will hop over ramps (when a slope is ending and a straigh path beginns, the player will lift of the ground for a moment. This is not desired (unless you do a racing game), because you cannot jump in that moment).
I did not know that. Good to know.Uhfgood wrote: As far as your comment goes, Sonic the Hedgehog (the original Genesis/MegaDrive ones) works like this. He'll jump perpendicular to the slope. Though going uphill works a bit differently, which is what I'm trying to fix in my code. Essentially when Sonic jumps uphill his x (horizontal) movement slows down a bit but he still manages to jump upward (I'm not really sure how this works out), but it allows him to clear the hill to a certain extent.
I found one bug:
In the area of the map to the bottom left there are some jump-through platform, where the player can jump through from the bottom. The platform in the corner is higher than the player can jump, but still the player can reach it. At the highest point of the jump he suddenly gets set onto the platform. I believe the problem is that you only check for the players velocity and if it is going down, you adjust the y-position to make the player stand on the platform. You have to include a check of the position, not the velocity. See "one way platforms" here: http://higherorderfun.com/blog/2012/05/ ... atformers/