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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

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

Post 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/
User avatar
Uhfgood
Prole
Posts: 35
Joined: Sat Jul 28, 2012 10:04 pm
Location: Oregon, US
Contact:

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

Post 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.
User avatar
Uhfgood
Prole
Posts: 35
Joined: Sat Jul 28, 2012 10:04 pm
Location: Oregon, US
Contact:

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

Post 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 219 times
Arrow keys to move, and up-arrow to jump.
Post Reply

Who is online

Users browsing this forum: No registered users and 230 guests