04-17-2010, 02:34 AM
I wouldn't use arrays for this since there's a limited use for arrays in a Java derived language.
The best thing to use would be a list and to set the condition to something like:
for all (item in world.item_list) together in world.item_list do
if player distance to (item in world.item_list) < X then
body
You would replace 'X' with whatever distance you choose and 'body' with the body of code that you will use.
The reason why lists are normally better than arrays is because they're extremely limited in what they can do when the language is based off of Java (C based languages have a much more flexible use of arrays). There are some cases in which an array would be considered the best choice, but it's only during complex indexing that I've found that arrays are the best choice.
|