Page 1 of 1

Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 11:12 am
by TheScout18
Being relatively new to both Lua and Love, collisions and whatnot have always kinda confused me. I've made a map with Tiled, and am loading it with STI, I have no clue how to make a working "player" so I've been using this: viewtopic.php?f=4&t=80684
However, the "player" doesn't collide with my map, so I started looking into bump.lua, only problem is, I have no idea how to make my "player" abide by bump.lua's 'rules'. If someone could show me how this might be possible, that would be wonderful. :)

If possible, I'd also appreciate if someone could give an example of implementing gravity, and jumping, currently, my player is free-floating around the screen. :ultrahappy:

Re: Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 3:24 pm
by s-ol
Did you read bump.lua's documentation?

you need to use world:move before actually moving your player to check for and handle collisions.

Re: Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 9:33 pm
by TheScout18
Ah! I'd only read the "README" thanks, this has a lot more detail, however, the way it explains handling collisions is rather complicated... And I'm still having my player float right through what I thought I had defined as a solid block. Perhaps an example of sorts would be handy?
(attached the changed version of my game)

Re: Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 10:05 pm
by s-ol
TheScout18 wrote:Ah! I'd only read the "README" thanks, this has a lot more detail, however, the way it explains handling collisions is rather complicated... And I'm still having my player float right through what I thought I had defined as a solid block. Perhaps an example of sorts would be handy?
(attached the changed version of my game)
That is also the Readme file, you just need to scroll. There is also a small examples at the beginning and there are two larger examples as separate branches of the got repo. Did you read the whole README now?

Re: Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 10:09 pm
by TheScout18
Oh wow, I feel kinda dumb now, lol. Yes, I've now read it all, but am still not quite grasping the collision handling...

Re: Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 10:41 pm
by s-ol
TheScout18 wrote:Oh wow, I feel kinda dumb now, lol. Yes, I've now read it all, but am still not quite grasping the collision handling...
All you need to do is calculate where the player "wants" to go, and then give that to world:move. It will return new x and y coordinates for the position that the player will end up in, after colliding with all the stuff that is around. If you want to trigger additional actions based on the collisions, you can look at the other values returned by the function.

Which part is unclear to you?

Re: Help with Collisions, bump.lua, and STI

Posted: Thu Aug 27, 2015 11:07 pm
by TheScout18
The calculating of where I want the player to go, and feeding it to world:move part, currently I have a moveable 'player' by coloring a box, and changing it's x and y coordinates, I don't know how to feed this through world:move to make it abide by bump.lua's rules, as I said earlier. That and I'm not entirely sure if I've correctly boxed off the area that I'm wanting the player to collide with and not effortlessly float through.

Re: Help with Collisions, bump.lua, and STI

Posted: Fri Aug 28, 2015 12:42 am
by s-ol
TheScout18 wrote:The calculating of where I want the player to go, and feeding it to world:move part, currently I have a moveable 'player' by coloring a box, and changing it's x and y coordinates, I don't know how to feed this through world:move to make it abide by bump.lua's rules, as I said earlier. That and I'm not entirely sure if I've correctly boxed off the area that I'm wanting the player to collide with and not effortlessly float through.
Whatever you are doing now is calculating the x and y for the next frame already. All you need to do is put something like "player.x, player.y = world:move(player, player.x, player.y)" after your current movement code.

Re: Help with Collisions, bump.lua, and STI

Posted: Fri Aug 28, 2015 1:27 am
by TheScout18
Got that working now! :awesome: However, I'm still having problems adding the "slide" collision resolution, I added it as a filter on both the "ground" and the player, but the player will still float through the ground layer...