Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Array
Old
tm.design
Guest
 
Status:
Posts: n/a
Default Array - 04-17-2010, 12:31 AM

I'm attempting to create a high score counter. Everything I've done so far has worked.

When you get near an item from the array you get your points and the item goes away.

My problem is that if you get one of the items out of order you will not get your points.

I need to know what line of code I'd need to make this work.
What i need is a "any item of array"
   
Reply With Quote
Old
Niteshifter
Guest
 
Status:
Posts: n/a
Default 04-17-2010, 03: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.
   
Reply With Quote
Old
tm.design
Guest
 
Status:
Posts: n/a
Default 04-17-2010, 07:13 PM

Thanks for the advice. I got it last night out of nowhere. Basically the same way you explained it to me. Thanks again for the response.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.