Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Reply
 
Thread Tools Display Modes
lab 4 array
Old
RandallWT
Junior Member
 
Status: Offline
Posts: 10
Join Date: Feb 2014
Exclamation lab 4 array - 03-31-2014, 12:48 PM

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.
Attached Files
File Type: a2w lab4.a2w (300.8 KB, 28 views)

Last edited by RandallWT; 03-31-2014 at 07:12 PM.
   
Reply With Quote
Lists
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 500
Join Date: Sep 2007
Location: Austin, Texas
Default Lists - 03-31-2014, 02:09 PM

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.
   
Reply With Quote
Old
RandallWT
Junior Member
 
Status: Offline
Posts: 10
Join Date: Feb 2014
Default 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?
   
Reply With Quote
Maybe
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 500
Join Date: Sep 2007
Location: Austin, Texas
Default Maybe - 03-31-2014, 09:37 PM

Try using the distanceTo method to as shown in the jpg.
Also, what are the rules for a score? Just close, or touching?
Attached Images
File Type: jpg dist.jpg (27.6 KB, 33 views)

Last edited by MrMoke; 04-01-2014 at 03:12 PM.
   
Reply With Quote
Old
RandallWT
Junior Member
 
Status: Offline
Posts: 10
Join Date: Feb 2014
Default 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.
   
Reply With Quote
Good Job
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 500
Join Date: Sep 2007
Location: Austin, Texas
Default Good Job - 04-03-2014, 12:17 PM

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.

Last edited by MrMoke; 04-04-2014 at 09:13 AM.
   
Reply With Quote
Reply

Tags
array, game, lab, ring

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.