bump.lua - minimal collision detection lib

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

tilmah wrote:Any suggestions would be appreciated.
Hi, I don't have any particular suggestion, I have never used ATL yet. Good luck!
tilmah wrote:p.s. Why do you have 't' and 'l' in Bump instead of 'x' and 'y'? What do they stand for?
t,l,w,h => top, left, width, height. I don't call them x and y because sometimes I also need the right and bottom (r and b) and it is weird to have x,r, y,b.
When I write def I mean function.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: bump.lua - minimal collision detection lib

Post by Ranguna259 »

Found a typical collision bug on your demo, dunno if it's just in the demo and I can't really explain it so do this:
Set fly to true.
Go up intil you colide into another object (no the walls, it has to be one of the rectangles).
Once you are coliding go slowly to the left or to the right.
You'll notice the you'll get teleported to the side of the coliding object before ending the colision.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: bump.lua - minimal collision detection lib

Post by vrld »

That's very likely a bug in your collision response, not in bump.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

Sometimes bump "jumps". It is good, but it is not perfect. The demo does a very simplistic collision response, too. You might see a "jump" here or there, I'm afraid. It was the best I could do in 2-3 months; you should not see them very often.

Collision detection is quite tricky ^^
When I write def I mean function.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: bump.lua - minimal collision detection lib

Post by Ranguna259 »

Indeed, it can be tricky and really glitchy, I'm still trying to code collision for my game and till now I've complitly recoded my player.lua two times and I think I'm going for the third.. But this time I'm gonna use HC, I hope it works out
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
farzher
Prole
Posts: 42
Joined: Fri Jul 31, 2015 5:38 pm

Re: bump.lua - minimal collision detection lib

Post by farzher »

How do I "bump" another object?

I'm trying to push other players by jumping or running into them.
Is there any support for that? Or does anyone have any tips/snippets?

I tried quickly but it's pretty screwy. So I decided to ask here before I mess with it for hours.

When looping through cols, does it make sense to call world:move on the player I bump into to push them?
But then wouldn't they have to loop through their cols from that push and push anyone else they just bumped into? Sounds like a mess and potential infinite loop?
butts
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

I am on my mobile so I can't write a lot.

The simplest way to move other characters around is by changing their velocity. The explosions do this in the demo. You can modify the velocity of one object when resolving the cols of another (provided that you handle velocity nicely, not resetting it manually on each frame)

Moving other items "as you move", like pushing a block in zelda, is trickier. You must move the other object the exact amount. Too littke and you will tunnel through it. Too far and it will be separated, not touching any more.

There is an example of this in the "platforms" branch on github. The platforms move the player "just the right amount". Have a look at platform.lua (sorry I can't link it)
When I write def I mean function.
Sarcose
Prole
Posts: 48
Joined: Wed Jul 08, 2015 12:09 am

Re: bump.lua - minimal collision detection lib

Post by Sarcose »

I'm trying to think about how one would utilize multiple bump worlds to create background and foreground collision layers, and a player that can move between them. Would it be best to have a player hitbox in each layer and just control the one in the active layer, making the appropriate changes with update when switching?

My specific idea is to achieve a 'kinda-3D' ish world in an otherwise traditional sidescrolling platformer, where the player can jump to fore- and backgrounds either arbitrarily or at specific points (if arbitrary movement proves too complex). There will be npcs on these layers, too, moving around and, say, shooting arrows at the player on other layers.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: bump.lua - minimal collision detection lib

Post by s-ol »

Sarcose wrote:I'm trying to think about how one would utilize multiple bump worlds to create background and foreground collision layers, and a player that can move between them. Would it be best to have a player hitbox in each layer and just control the one in the active layer, making the appropriate changes with update when switching?

My specific idea is to achieve a 'kinda-3D' ish world in an otherwise traditional sidescrolling platformer, where the player can jump to fore- and backgrounds either arbitrarily or at specific points (if arbitrary movement proves too complex). There will be npcs on these layers, too, moving around and, say, shooting arrows at the player on other layers.
I would just put them all in the same world and have one player but change the "filter" value depending on the 2.5D position. For example like this:

Code: Select all

world:move(self, newx, newy, function (other) 
  if other.layer == self.layer then
    return "slide" -- slide along obstacles
  else
    return nil -- do not collide with other objects
  end
end)
Of course you will probably have to put a bit more logic in there for other types of things (like powerups, coins etc, you probably don't want to "slide" along those)

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
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

Both options can work. Either "1 world per slice" or "everything in one world, and filter by slice". The former will probably be slightly more efficient, but also probably more difficult to work with.

Also, please use the following thread to talk about bump, this one is about a previous version:

viewtopic.php?f=5&t=79223
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests