Help with Collisions, bump.lua, and STI

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.
Post Reply
User avatar
TheScout18
Prole
Posts: 10
Joined: Tue Aug 25, 2015 2:12 am

Help with Collisions, bump.lua, and STI

Post 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:
Attachments
Game.love
w,a,s,d to move
(173.56 KiB) Downloaded 135 times
Ubuntu is pretty cool! :awesome:
http://www.ubuntu.com
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
TheScout18
Prole
Posts: 10
Joined: Tue Aug 25, 2015 2:12 am

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

Post 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)
Attachments
Game.love
(173.65 KiB) Downloaded 113 times
Ubuntu is pretty cool! :awesome:
http://www.ubuntu.com
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
TheScout18
Prole
Posts: 10
Joined: Tue Aug 25, 2015 2:12 am

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

Post 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...
Ubuntu is pretty cool! :awesome:
http://www.ubuntu.com
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
TheScout18
Prole
Posts: 10
Joined: Tue Aug 25, 2015 2:12 am

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

Post 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.
Ubuntu is pretty cool! :awesome:
http://www.ubuntu.com
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
TheScout18
Prole
Posts: 10
Joined: Tue Aug 25, 2015 2:12 am

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

Post 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...
Ubuntu is pretty cool! :awesome:
http://www.ubuntu.com
Post Reply

Who is online

Users browsing this forum: tpimh and 7 guests