Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   The Lounge (http://www.alice.org/community/forumdisplay.php?f=4)
-   -   lab 4 array (http://www.alice.org/community/showthread.php?t=10569)

RandallWT 03-31-2014 12:48 PM

lab 4 array
 
1 Attachment(s)
I cant figure this one out. I understand lists and arrays should be used to minimize time spent repeating code, but i don't understand how to apply it. I have read through chapter 5 in the book several times since last night, and i am still stalled on this.
I have rebuilt it three times now, and my patience has reached its end, because each time i end up getting to the point where i start inputting things on my own, and i know that's not going to fly with my instructor, which will end up getting it sent back several weeks later.
Questions.
How to i use an array to make objects fall simultaneously?
How do i get the score to rise for all the objects?

I can pretty it up later, i just need to know how to make it work.
Edit: I attached the right file so you can see what i am working on.

MrMoke 03-31-2014 02:09 PM

Lists
 
That sounds like a job for lists, although I don't know what the Lab is:

Look at the bottom of the programming window at the "for all Together" and "for All In Order" buttons. Drag one in and tell it which list you want to work with.

RandallWT 03-31-2014 07:01 PM

That handles falling and resetting, though i still need to keep score. Im using an if/else line to do that.

If True( ring is within threshold of cone)
Increment core by 1
Else
Increment Missed by 1

I have tried to apply the list to this command, but cant get it to work. I though about using 'for all together' or 'for all in order' but they wont go into the true/false space. This is the last thing in the way, but i need to get around it. Is there a way to force the program to check each item on the list, while it is in the if/else line?

MrMoke 03-31-2014 09:37 PM

Maybe
 
1 Attachment(s)
Try using the distanceTo method to as shown in the jpg.
Also, what are the rules for a score? Just close, or touching?

RandallWT 04-01-2014 07:30 PM

Thank you so much. While i didn't follow your exact fix, it did give me an idea to rearrange things. Basically your idea, with the following change.

If
Cone is within X of object from Ring list

With the score cone in front, it can register any item in the list.

MrMoke 04-03-2014 12:17 PM

Good Job
 
Just goes to prove that there are always multiple logical pathways to solve a problem.:)

My first question to myself when I saw your post was, "What constitutes a valid hit, and how to give at least a 50-50 chance?"
The +2 actually made it pretty easy to win consistently. Using just the Width of the cone would mean touching, because the cone is the smaller of the circles and touching would be the sum of the two radii. Also makes it pretty hard to win without changing other stuff.


All times are GMT -5. The time now is 06:21 PM.

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