alice-teacher s Digest, Vol 74, Issue 5 Collision detection

robert durtschi robert.durtschi at gcsu.edu
Mon Nov 14 10:23:48 EST 2016


An Introduction to Alice 2.2 by Charles W. Herbert has a nice piece of code in Chapter 10


Basically you set up a "While the world is running" event that calls your collision detection method.

In that particular chapter there is a penguin that can fall through a hole, collide with a snowbank, or reach a flag (Victory!)

Basically the detection code checks each "goal" in turn.

For the list of holes:

    for all the holes together

       If penguin is within 1 meter of hole  (where the holes are 1 meter radius)

            penguin move down 5 meters
            etc.

For the snowbank which is defined as a 10.5 meter circle with center at the middle

      if penguin is at least 10.5 meters away from snowbank

         penguin move toward snowbank 0.25 meters

         etc

for the flagpole
    if penguin distance to flagpole <= 1 meter
        do victory stuff.

where the if parts are the first 3 items in the penguin's function tab.

Hope this helps
You can email me at robert.durtschi at gcsu.edu if you have any further questions

________________________________

From: alice-teachers <alice-teachers-bounces+mrgrog=outlook.com at lists.andrew.cmu.edu> on behalf of Nichols, Denise via alice-teachers <alice-teachers at lists.andrew.cmu.edu>
Sent: Wednesday, November 9, 2016 10:08 AM
To: alice-teachers at lists.andrew.cmu.edu
Subject: alice-teacher Collision Detection in Alice 2

Hello all,
Next month, I am hoping to have my class to the point where they can make simple games in Alice 2.  However, last year, we had a lot of trouble with collision detection in Alice 2.4.  Does anyone have any suggestions and/or materials for covering this topic?
Denise Nichols
Computer Teacher
York Catholic High School
dnichols at yorkcatholic.org<mailto:dnichols at yorkcatholic.org>
717-846-8871
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20161110/1f4dc1c4/attachment-0001.html>


End of alice-teachers Digest, Vol 74, Issue 5
*********************************************
F
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20161114/b7ea2bbe/attachment.html>


More information about the alice-teachers mailing list