Alice Community Need Assistance
 User Name Remember Me? Password

 Thread Tools Display Modes
 Need Assistance
 AcidicPlague Guest   Status: Posts: n/a Need Assistance - 04-11-2008, 07:07 PM I'm currently working on project 1 in Chapter 6. I cannot even get past the first hurdle, and that's getting the objects to switch with one another. Basically I've got to take four objects and line them in a row, 1 - 2 - 3 - 4. When the user click an object it switches with the object furthest from it. So when you click 4 it swaps with 1, 3 with 1, and 2 with 4. I haven't even the slightest clue of where to begin. I can write a method that makes 1 switch with 4, but only those two objects regardless of where they are in the line up. I cannot for the life of me figure out how to assign objects numbers when they're in a specific position so that I can just make a method that calls Obj1 to move to Obj4 depending on what object are in those spots. Could anyone guide me in the direction as to how I can even begin this program? I imagined that I could use nested If/Then statements, but I am flat out stumped. From 1 to 4 I've got Anubis, Isis, Ra, Pharaoh. I figured I would be able to do something like the following and just repeat it two more times for the other possibilities. Code: ```If Anubis distance to Pharaoh > Anubis distance to Isis AND Anubis distance to Ra Then Do Together Anubis move distance to Pharaoh / Pharaoh move distance to Anubis``` but I can't figure out how to make an a > b and c function. Last edited by AcidicPlague; 04-11-2008 at 07:39 PM.
 AcidicPlague Guest   Status: Posts: n/a 04-11-2008, 08:18 PM another idea I had was just to express the objects as variables, but I don't know how to define variables within the code. So If I've got Anubis as 1 and Pharaoh as 4, it'd be Do Together 1 move 1 distance to 4 toward 4 4 move 4 distance to 1 toward 1 then I would somehow make it so 1 became 4 and 4 became 1. But I don't know how.
Lprsti99
Guest

Status:
Posts: n/a
04-15-2008, 01:39 PM

Ok, I created a world, using 4 bumps, that allows you to do the swapping you described. I'm not sure how you'll get different objects (with diferent center positions) to work, but, if nothing else, you could make invisible objects (like the bumps), set the peoples' vehicles set to the objects, and make them move. Hope this helps. Pay special attention to the whichIsFarthest function.
Attached Files
 ObjectSwap.a2w (221.5 KB, 107 views)

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge

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

 Contact Us - Alice.org - Archive - Top