lua-users home
lua-l archive

Best strategy to check all elements of a table

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi!
I'm testing porting some C++ code to Lua.
One part of the code checks all elements on an array
against each other.
Is there some optimized way of do this in Lua?
I don't have to check collisions twice, only one time
for each pair of objects.
In pseudocode:
for obj1 = list.first to list.end do
 for obj2 = list.first to list.end do
 
 if obj1.collideWith(obj2) then 
 obj1.DoSomething(obj2)
 end
 end
end
Thanks for any tip!
__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger 
http://br.beta.messenger.yahoo.com/ 

AltStyle によって変換されたページ (->オリジナル) /