Page 5 of 23

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

Posted: Tue Dec 30, 2014 12:15 pm
by kikito
Hi there,

It's a very easy fix actually.

Inside src/player.lua, you are ignoring the results world:move gives you. world:move can "move correctly" the "rectangle inside the world" but it does not change the player variable itself (you must use the return values to do it yourself).

In other words, to fix the issue, you must replace this line:

Code: Select all

world:move(player, player.pos.x, player.pos.y)
By this:

Code: Select all

player.pos.x, player.pos.y = world:move(player, player.pos.x, player.pos.y)

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

Posted: Tue Dec 30, 2014 12:16 pm
by Doctory
thanks, it works now!

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

Posted: Thu Jan 01, 2015 9:34 am
by ishan
I take it kikito is on a mission to free the LOVE world from dirty library names?

*hugs*

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

Posted: Thu Jan 01, 2015 10:57 am
by kikito
ishan wrote:I take it kikito is on a mission to free the LOVE world from dirty library names?

*hugs*
Thanks for the hugs, but I am not on such a mission. I personally don't use lewd names for my libraries, but I think anyone has the right to name theirs however they want. I think some human-right-related themes are off-limits (i.e. sexism or hate speech), and I have voted to close some threads in that sense in the past. But that's a last-resource thing that I hope we won't have to use often, or lightly.

(Also, lewd-named libs tend to span long discussions in the forum. If you want to further talk about this, please do so in a separate thread. I'd like to keep things on-topic here).

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

Posted: Wed Feb 11, 2015 1:21 am
by Kingdaro
Is there a way to simply get all of the items in a world? I've found that I either need to contain my objects in a container outside of the world to keep track of and update them separately (removing them as well, which is a pain), use arbitrarily big numbers to get all of them which still have the potential to be exceeded, or make odd, seemingly unnecessary measures to make sure the object doesn't leave the bounds of the world/map. It seems really odd to me to not be able to do something so trivial.

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

Posted: Wed Feb 11, 2015 8:55 am
by kikito
You raise a completely valid concern. I will see what I can do. Thanks

EDIT: Done. I've added two new methods to world:
  • local items, len = world:getItems() is just what you need
  • local count = world:countItems() just returns the number of items
I am releasing v3.1.2 with these changes

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

Posted: Wed Feb 11, 2015 10:10 am
by s-ol
kikito wrote:You raise a completely valid concern. I will see what I can do. Thanks

EDIT: Done. I've added two new methods to world:
  • local items, len = world:getItems() is just what you need
  • local count = world:countItems() just returns the number of items
I am releasing v3.1.2 with these changes
Maybe also have an iterator? Easier to write and more performant.

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

Posted: Wed Feb 11, 2015 10:30 am
by kikito
I considered it, but bump's interface is already list-based - the collisions are returned as a list, and the results of a query are also returned as a list. Besides, often you will want to sort the items in a certain order, and you can't do that with an iterator anyway (unless you use the iterator to create a table, which is even slower than just building the table).

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

Posted: Wed Feb 11, 2015 10:43 am
by s-ol
kikito wrote:I considered it, but bump's interface is already list-based - the collisions are returned as a list, and the results of a query are also returned as a list. Besides, often you will want to sort the items in a certain order, and you can't do that with an iterator anyway (unless you use the iterator to create a table, which is even slower than just building the table).
Oh, I though that you stored the items in the space-partition tables (idk what you use/call them).

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

Posted: Wed Feb 11, 2015 10:48 am
by kikito
I store them there (those are called "cells"), but the "rectangles associated to each item" are stored in a single table in the world, and each one has its corresponding 'item' as a key. This is useful for several things (for example, to check if an item is in the world, you just check in that list, instead of iterating over all the cells).