Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Not looking for a solution, just a push in the right direction..
Old
gballa1993
Junior Member
 
Status: Offline
Posts: 5
Join Date: Dec 2013
Location: Louisiana
Default Not looking for a solution, just a push in the right direction.. - 01-03-2014, 02:39 PM

My assignment is to make a game in which I click on three different objects, when I click on each object, a gorilla moves towards it, moving at a random rate anywhere from 2 meters to 1/2 the gorilla's distance to the object. Once the gorilla gets within 2 meters of the object, the object fades to transparent. Where am I going wrong? I've been working on this for weeks.
Attached Files
File Type: a2w GorillaGam!.a2w (2.09 MB, 24 views)
   
Reply With Quote
Old
mmar
Junior Member
 
Status: Offline
Posts: 11
Join Date: Sep 2011
Default 01-04-2014, 10:25 AM

Looks like you forgot on start app, because app doesn't run in A2.4, and I can't reproduce the problem because of my lack of time. But I suppose you did not analize approaching objects to each other. The system does not deteck the moment the object is within 2 meters of the obstacle. You need to know that the loop you maybe have, should control the distance. Use step by step controling structure, measure the distance, and I'm sure you are going to find the solution.
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 210
Join Date: Dec 2012
Location: Frosno, Ca
Default 01-14-2014, 08:40 AM

Since this is entirely event driven, you don't need to use "When the world starts" unless there is some non-event things to be done. I do see a couple of potential problems though.
  1. If the gorilla is less that 2 meters from the target, then the value of min passed to the random function will be greater than the value of max. I do not know how this would be handeled by Alice.
  2. You are moving at least 2 meters but checking if the gorilla is within 1 meter of the target. In algebra this would work, but it does not always work in Alice due to round offs. If the gorilla is a little over 1 meter from the target then moving 2 meters could put it just over 1 meter from the target in which case, the gorilla would continue to move forward for ever.
  3. Possibly the biggest problem with you code is really simple, the "go to Animal" method does not do anything once the gorilla is within 1 meter of the target except stop. This is where you want to turn the target invisible! The other While events are not needed, just set the target's opacity to 0 in the if part of the condition.


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Reply

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.