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

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
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.1 - Collision Detection

Post by kikito » Tue Dec 30, 2014 12:15 pm

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)
When I write def I mean function.

User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

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

Post by Doctory » Tue Dec 30, 2014 12:16 pm

thanks, it works now!
"This is what videogames should be like; they should have meaning and triple machine guns"
- Jan Willem Nijman, 2013
github

ishan
Prole
Posts: 4
Joined: Sat May 17, 2014 2:36 pm

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

Post by ishan » Thu Jan 01, 2015 9:34 am

I take it kikito is on a mission to free the LOVE world from dirty library names?

*hugs*

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.1 - Collision Detection

Post by kikito » Thu Jan 01, 2015 10:57 am

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).
When I write def I mean function.

User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

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

Post by Kingdaro » Wed Feb 11, 2015 1:21 am

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.

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.2 - Collision Detection

Post by kikito » Wed Feb 11, 2015 8:55 am

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
When I write def I mean function.

User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post by s-ol » Wed Feb 11, 2015 10:10 am

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.

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

Post by kikito » Wed Feb 11, 2015 10:30 am

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).
When I write def I mean function.

User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post by s-ol » Wed Feb 11, 2015 10:43 am

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

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

Post by kikito » Wed Feb 11, 2015 10:48 am

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).
When I write def I mean function.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 8 guests