Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)

 AcidicPlague 04-11-2008 07:07 PM

Need Assistance

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][B]If[/B] Anubis distance to Pharaoh > Anubis distance to Isis [B]AND [/B]Anubis distance to Ra
[B]Then[/B] Do Together Anubis move distance to Pharaoh / Pharaoh move distance to Anubis[/code]

but I can't figure out how to make an [b]a > b and c[/b] function.

 AcidicPlague 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 04-15-2008 01:39 PM

1 Attachment(s)
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 [I]them[/I] move. Hope this helps. Pay special attention to the whichIsFarthest function.

 All times are GMT -5. The time now is 11:29 AM.