[library] bump.lua v3.1.4 - Collision Detection

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: [library] bump.lua v3.1.4 - Collision Detection

Post by kikito »

Sarcose wrote:I think trying to use bump directly to implement pushing and pulling is asking to make it into a physics engine.
I would not have said it better. Thanks.
alexzhengyi wrote:The idea of add a collision type such as 'push' is just from the platform demo.
It may make implements this kinds of collisions easier.This is the simple use case.But if there is wall just on top of the player, just simply update the player's y position may make the player cross the wall.
For another complicated use case,for example the play is pushing a solid box by 2 pixel , and the box is 1 pixel from a wall,then we can not just update this box like the platform demo.the play and the box both can just move 1 pixel.
See the previous quote. Bump is not a physics lib - it is a collision detection and (secondarily) a collision resolution lib. Physics is something you don't want me to get involved in. It took me years to have a working collision detection, and I only use boxes. If someone wants to implement a physics engine which used bump for collision detections, he's got my blessing. But I won't (can't) do that. In any case, I thank you for your interest and feedback!
When I write def I mean function.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by Davidobot »

Jasoco, I just made a quick prototype for slopes. Use the arrows keys and space to move around.
You can change the slant in line 120 of main.lua.
Press tab to see how the magic works. Enjoy~!
Attachments
RampDemo.love
(9.69 KiB) Downloaded 210 times
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by Jasoco »

Very interesting concept. Surprised I didn't think of that. Basically a moving platform that aligns itself with the player's X position and moves along the slope. I might have to do some toying around with that idea. Thanks for the idea! Maybe kikito can give some input too.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by Davidobot »

Jasoco wrote:Very interesting concept. Surprised I didn't think of that. Basically a moving platform that aligns itself with the player's X position and moves along the slope. I might have to do some toying around with that idea. Thanks for the idea! Maybe kikito can give some input too.
No problem, I was actually put-off by how simple the idea is, so at first I thought it wouldn't work because if it did, I would have expected you to already have done it. lol.
Btw, that version uses math.sin for the slop, instead of math.tan, so it's a bit off. Here's the fixed one.
Attachments
slopeFixed.love
(9.69 KiB) Downloaded 180 times
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by kikito »

@Davidobot, your solution is highly creative, congratulations!

I wouldn't go as far as saying that it is "the definitive answer to slopes in bump", but it is better than what has been shown so far. Thanks for sharing it.

My real-life workload has escalated significantly since I started a new job last summer, and I have not been able to look into this yet I am afraid. I know however that the proper solution is creating 4 new collision types (8 if you want to allow "corner" and "vertical center" variants). Each collision type would be similar to "slide", but with a modified rect_getSegmentIntersectionIndices function. The regular one calculates the intersection between a line and a rectangle, like this:

Code: Select all

+----------+           +----------+
|          |           |  XX      |
|          |           |XX        |
|          |  ==>     XO          |
|          |        XX |          |
|          |           |          |
+----------+           +----------+
What is needed is another version of this algorithm which is able to calculate the intersection between a line and a "rectangle which is missing a corner" (as well as some math to calculate exactly how much corner to "cut"):

Code: Select all

   /-------+               /------+
  /        |              OX      |
 /         |            XX        |
/          |  ==>     XX/         |
|          |        XX |          |
|          |           |          |
+----------+           +----------+
This would make things move like they are supposed to without needing to add platforms, etc. Unfortunately, this is the kind of mathy stuff I don't really enjoy doing, and I haven't had the will to spend my little free time researching this.

(Pull requests are welcome, by the way :)!)
When I write def I mean function.
User avatar
bzSteve
Prole
Posts: 34
Joined: Tue May 21, 2013 2:31 am

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by bzSteve »

@Davidobot, I like where you're going with this and that you're working to add a useful feature to an already great library. Thanks.

I had a problem, though. I added a block in love.load that intersects the slope and tried to move up the slope and fell through to the floor.

Code: Select all

addBlock(100, 500, 200, 10)
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by Davidobot »

Oh, things like that will happen. That was just a quick and dirty way to test out a idea I had. I'll work on refining it more.
Thank you for all the kind comments too. ^~^
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by 4aiman »

Hi!
I've tried your bump-demo-3.1.0.love just now and it segfaults 2/3 of launches after I press either right or up.
Is there anything I can do/provide to find the source of this behaviour?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by bobbyjones »

Segfaults? Does the demo use ffi? If not then segfaults is a very weird behavior. If you mean an error then it may need to be updated to 0.10.0.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [library] bump.lua v3.1.4 - Collision Detection

Post by kikito »

4aiman wrote:Hi!
I've tried your bump-demo-3.1.0.love just now and it segfaults 2/3 of launches after I press either right or up.
Is there anything I can do/provide to find the source of this behaviour?
bump.lua (or its demos) don't use anything that would provoke a segfault. There is no ffi, no shaders, no canvases, and no use of love.physics. It should also work in both 0.9.x and 0.10.x.

The camera in the demo uses love.graphics.translate, but that is a safe thing to do as far as I know. Does your computer segfault with other games or programs? Have you tried running it from the console, to see if it leaves any message before it "dies"? Also, is your keyboard ok? Pressing "escape" closes the demo, maybe it "presses it" due to a hardware error.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests