Page 2 of 2

Re: Can someone help me fix my last "slope" related problem?

Posted: Thu Jan 10, 2013 7:10 am
by micha
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.
I had a second look at you code. I don't have the solution, but some ideas how to find the mistake.
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).
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 did not know that. Good to know.

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/

Re: Can someone help me fix my last "slope" related problem?

Posted: Thu Jan 10, 2013 9:47 pm
by Uhfgood
Yeah, you're correct in the fact that I just simply set the new y position instead of taking velocity into account. I suppose I could have a variable or member set to a displacement value (floor height) and then actually add that into the velocity in the vertical movement function ( UpdateVert() ) -- I'm not sure it would work exactly like I would like but it probably wouldn't hurt to try.

As far as the one-way platform bug, I just chose not to "fix" it, as it wasn't exactly a bug. I might look into fixing it later, though.

Re: Can someone help me fix my last "slope" related problem?

Posted: Fri Jan 11, 2013 8:56 pm
by Uhfgood
I have done something which I will make do with... test it out and tell me how it feels.
SSE03v2.love
(92.01 KiB) Downloaded 111 times
Arrow keys to move, and up-arrow to jump.