alice-teacher looking for some info

James Vanderhyde jvanderhyde at benedictine.edu
Fri Nov 11 11:09:04 EST 2011


OK, then, I will assume that the student has an event that calls some method when the up key is typed. Within the method, instead of simply moving forward, put the code to move forward inside an IF block. The condition on the IF will check the distance to the bush, and only allow the forward movement if the distance is greater than a certain amount. (Dr. Slater just posted some instructions to help with the distance check.)

This will work for one bush. If you have several bushes, you need a similar condition for each bush, and you can connect them with an AND.

This will quickly get tedious for more than 2 or 3 bushes, so a better approach would be to write a function that loops through a list of bushes and checks the distance to each one. The function returns true if the distance in front of the girl object is clear of objects.

James
--
Dr. James Vanderhyde
Math and Computer Science
Benedictine College
jvanderhyde at benedictine.edu
http://vanderhyde.us/~james/pro/



On 11/11/11 9:58 AM, "Karen" <kgayowsky1 at gmail.com> wrote:

Thank you for your reply Dr. Vanderhyde.

The students are just now writing events and event handling methods.  I believe she is using the arrows up and down to control the walking of her object, but she wants the girl to be stopped and not be allowed to even by accident to go through the bushes.

Thanks for any suggestions

Karen Gayowsky
ICS Teacher
St. Anne's High School

On Fri, Nov 11, 2011 at 10:37 AM, James Vanderhyde <jvanderhyde at benedictine.edu> wrote:
This is a bitt difficult, and there are many ways to do it. The topic is called "collision detection." My students have implemented it several different ways, but none has been completely satisfactory.

How is the girl object controlled? This is important to figuring out the best way to handle collisions.

James
--
Dr. James Vanderhyde
Math and Computer Science
Benedictine College
jvanderhyde at benedictine.edu <http://jvanderhyde@benedictine.edu>
http://vanderhyde.us/~james/pro/ <http://vanderhyde.us/%7Ejames/pro/>




On 11/10/11 1:45 PM, "Karen" <kgayowsky1 at gmail.com <http://kgayowsky1@gmail.com> > wrote:

Hello All:
A student of mine is trying to have her object (girl) stop instead of going through objects (bushes).
Can anyone help with that code?  She does not want the object to be able to go through another wall type object.
Thanks in advance for any info

Karen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.andrew.cmu.edu/mailman/private/alice-teachers/attachments/20111111/fe447abf/attachment.html 


More information about the alice-teachers mailing list