Alice Community

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

tHobbs 10-13-2008 09:02 AM

Gatekeeper Help
 
I am quite confused on the Gatekeeper Project (page 178, Learning To Program w/Alice book).

I cannot seem to think of a code to make two of the objects switch places, I can get one, but the getting the other is confusing.

Any suggestions?

lanceA 10-13-2008 04:24 PM

[quote=tHobbs;7057]I am quite confused on the Gatekeeper Project (page 178, Learning To Program w/Alice book).

I cannot seem to think of a code to make two of the objects switch places, I can get one, but the getting the other is confusing.

Any suggestions?[/quote]
If you have two objects beside one another you probably need to determine which object was "clicked" first. Then you can use the function [I]Object[/I] [B]is to the left of[/B] (or right of). Then maybe use a Do Together and place statements like:
If object clicked is to the left of object NOT clicked
Do Together
Object1 [B]move left[/B] Object1 [B]Distance to[/B] Object2
Object2 [B]move right[/B] Object2 [B]Distance to Object1[/B]

otherwise the object clicked is on the right and you place the opposite code in your Else portion of the If statement.

I used the Do Together structure because this allows Alice to compute distances from each object before any of the objects move.

Good luck

dan2343 10-14-2008 09:11 AM

Does anyone have a completed version of the gatekeeper?

tHobbs 10-14-2008 05:05 PM

[QUOTE=dan2343;7076]Does anyone have a completed version of the gatekeeper?[/QUOTE]

why would you want a complicated one?

lanceA 10-14-2008 07:17 PM

[quote=dan2343;7076]Does anyone have a completed version of the gatekeeper?[/quote]

I do, but I am a teacher and unfortunatly can not give it to you? Does your teacher also come here to see if any of his/her students are looking for others to do their homework? Several teachers have introduced themselves to their students in this forum.

It's extremely hard to learn to program unless you first try to do it yourself.

To solve this problem use my previous post about moving Objects. The solution to the project is to have the Gatekeeper in position 4.

As you already know, you will need to write your own methods and Event Handlers.

If you stop and thank about it the code will not be that difficult to write. Visualize the problem that you need to solve for this project, draw it on paper if you need to. Logically visualize the steps you need to go through in order to solve this problem.

Good luck, :)


All times are GMT -5. The time now is 04:42 PM.

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