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

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

I'll try this again as everything else is pretty much fixed. I have slope collisions mostly working and can blast through at any speed without tunneling through. And you can jump in an arc based on the slope normal if you're not moving very fast.

So now the final problem is jumping while trying to move up-hill. That is I want to be able to jump up (vertically) from the slope while moving uphill. See the horizontal collision functions will detect a slope and actually bump you up to the y position of the slope (which is a height map). Which means it will stick to the floor and never get a jump.

This is only part of the problem. The second part of the problem is that the jump is based on the slope normal which I have hard coded into the tiles and then I read them and put it in a member called jumpDir. The steeper the slope, the shallower the normal.

Okay so if I comment out the lines where it sets the y position based on a horizontal collision then it simply jumps through the slope. The third part of the problem is gravity constantly drags the sprite down -- so what you have is a sprite that can't jump very high on slopes when moving up-hill.

I'm not really sure what to do, but if all else fails I'm going to increase the jump force depending on the slope so it will at least clear the slope tiles in a move.

Here's a video showing the problem, make note of the first 4 seconds, in which I'm trying to jump but can't:

And here's the love file -
SSE03.love
Hopefully someone can give me an idea... of course I suppose most of you wouldn't care to wade through someone else's code, and admittedly, my code is a bit stranger than most, but I don't think my code is entirely unreadable. Most of the code is in player.lua -- so look there first.

Thanks
Last edited by Uhfgood on Thu Jan 10, 2013 7:02 am, edited 1 time in total.

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?

I had a quick look at your code. Can you explain one thing to me? Maybe that helps me helping you:
When the player is moving around you keep updating the jumpDirection, which is a vector that tells us, what direction the player jumps to. Then I press jump, a velocity vector in this direction is added to the player's velocity. As far as I see, this is done in the update() function and not only in the single moment, when the key is pressed. Is that correct or am I wrong here?

And one small comment: Making the jump orthogonal to the sloped ground seems physically plausible, but I doubt it will be fun for the player. I highly suggest, you implement a straight jump in y-direction.

And last: Nice and fluid framework so far. It is a lot of fun, just running around on the platforms and slopes. Keep up good work!

Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

When I run the .love it starts fading to grey, after about 2 seconds it's all grey and I can't see anything.

P.S: r, g, b, and a returned by lg.getColor() decrease a little each frame. I added the following code to create a log file showing frame number, microtime and rgba, I'm attaching the strange result.

Code: Select all

local r, g, b, a = love.graphics.getColor();--your code
local tNix = love.timer.getMicroTime()
fNix:open('a')
fNix:write('\n', tNix, ': ', r,' ', g, ' ', b, ' ', a, ' frame: ', iNix)
fNix:close()
love.graphics.rectangle("fill", 0, 0, 320, 180);
love.graphics.setColor(r, g, b, a);
Attachments
log.log
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
li = love.image
lg = love.graphics

Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

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

Nixola wrote:When I run the .love it starts fading to grey, after about 2 seconds it's all grey and I can't see anything.
mmh, maybe the same problem than viewtopic.php?f=4&t=12261
no problem for me on this PC (ubuntu 12.10, GeForce Go 7400)
Current work : Isömap

Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Thanks, I wrote my OS and graphic card there
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
li = love.image
lg = love.graphics

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?

A quick note on the color thing, someone was telling me it happened to them when they ran the 64-bit version of love, but when they ran the 32 bit version it worked fine.

I had set the gray background color so I could see a few things better (at least a couple of months ago).

Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

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

Uhfgood wrote:A quick note on the color thing, someone was telling me it happened to them when they ran the 64-bit version of love, but when they ran the 32 bit version it worked fine.
tested with 64 bits architecture and no problem deceled

it's just a quick idea but is the problem maybe related to LuaJIT version of love ?
Current work : Isömap

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?

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.

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.
micha wrote:I had a quick look at your code. Can you explain one thing to me? Maybe that helps me helping you:
When the player is moving around you keep updating the jumpDirection, which is a vector that tells us, what direction the player jumps to. Then I press jump, a velocity vector in this direction is added to the player's velocity. As far as I see, this is done in the update() function and not only in the single moment, when the key is pressed. Is that correct or am I wrong here?

And one small comment: Making the jump orthogonal to the sloped ground seems physically plausible, but I doubt it will be fun for the player. I highly suggest, you implement a straight jump in y-direction.

And last: Nice and fluid framework so far. It is a lot of fun, just running around on the platforms and slopes. Keep up good work!
Saegor - no idea, I just use the thing, I don't know about the internals. It has been working just fine for me so I don't know what's causing the problem.

Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

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

for your jump problem, you may find some inspiration with Open Sonic or even Open Surge, two sonic-like clones that i love a lot (but you have to know C to understand the code)
Current work : Isömap

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?

While I understand C, I looked at some of the source for open sonic, and it's hard to decipher for me.

### Who is online

Users browsing this forum: No registered users and 55 guests