alice-teacher collsion detection (s Digest, Vol 38, Issue 2)

Robert Durtschi robert.durtschi at gcsu.edu
Fri Sep 6 20:51:15 EDT 2013


The book "An Introduction to Programming Using Alice 2.2 Second Edition" by Charles W. Herbert has a rather nice collision detection method in Chapter 10: "TUTORIAL 10B—DON'T SPLASH THE PENGUIN!"

I'll see if I can paste the relevent code here:


[cid:7f31b7cb-8e93-4dcc-95e5-14d80edf775e]

This is a screenshot of what the playing field looks like. The goal is to manuever the penquin past the holes to the flag.  The collison dectection code checks if the penguin is within 1.1 meter of the center of each hole in the list; within 1/2 meter of the flag; or if trying to go through the snowbank surrounding the arena.



It rather cleverly defines the snowBank as a donut with the center in the center of the playing field.  so the check is to see if the penguin is 10.5 meters from the center of the snowBank boundry



We found that if one didn't use a "Do together" it was possible for the penguin to beat its way through the snowbank and disappear over the horizon.



the check is invoked by a runtime event:


While the world is running

Begin:

<None>


During:

World.checkPenguinLocation


End:

<None>





The first check below: For all hole1.holes , every item_from_holes together" runs through the list of holes.  If the penguin is less than 1.1 meter from the center of any of the holes it pops up a "splash" billboard that covers the screen.



The second check If ( penguin is at least 10.5 meters away from snowBank ) checks if the penguin is too far from the center of the snowbank donut (center of the playing field) and moves it back towards the center.



The third checks If ( ( penguin distance to flagpole ) < 0.5 ) when the penguin is close enough to the goal.  It then invokes another method to indicate "Victory"
World.checkPenguinLocation ( )
No variables

Do together


For all hole1.holes , every item_from_holes together


If ( ( penguin distance to item_from_holes ) < 1.1 )


penguin move down 5 meters duration = 0.25 seconds

splash set opacity to 1 (100%)

Else


Do Nothing

If ( penguin is at least 10.5 meters away from snowBank )


penguin move amount = 1 meter toward target = snowBank duration = 0 seconds style = abruptly

Else


Do Nothing

If ( ( penguin distance to flagpole ) < 0.5 )


World.reachedFlagpole

Else


Do Nothing


________________________________________
From: alice-teachers-bounces+robert.durtschi=gcsu.edu at lists.andrew.cmu.edu [alice-teachers-bounces+robert.durtschi=gcsu.edu at lists.andrew.cmu.edu] on behalf of alice-teachers-request at lists.andrew.cmu.edu [alice-teachers-request at lists.andrew.cmu.edu]
Sent: Thursday, September 05, 2013 12:00 PM
To: alice-teachers at lists.andrew.cmu.edu
Subject: alice-teachers Digest, Vol 38, Issue 2

Send alice-teachers mailing list submissions to
        alice-teachers at lists.andrew.cmu.edu

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
or, via email, send a message with subject or body 'help' to
        alice-teachers-request at lists.andrew.cmu.edu

You can reach the person managing the list at
        alice-teachers-owner at lists.andrew.cmu.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of alice-teachers digest..."


Today's Topics:

   1.  Collision and walking speed questions (Lori Fuller)


----------------------------------------------------------------------

Message: 1
Date: Wed, 04 Sep 2013 13:46:25 -0400
From: "Lori Fuller" <lori.fuller at browardschools.com>
Subject: alice-teacher Collision and walking speed questions
To: alice-teachers at lists.andrew.cmu.edu
Message-ID:
        <fc.0119ec0746d675b63b9aca00e8ed6537.46d6890f at browardschools.com>
Content-Type: text/plain; charset="utf-8"

I have an advanced student among all of my beginners... and he is working
on a maze game.
2 questions:
1.   In Alice 2.3, is it possible to set up a collision indication method?
If so, where do I find information on this?
2.  Is there a way to slow down the person object walking while using the
arrow keys as controllers?



thanks,

Lori Fuller, M.Ed.
Monarch High School
Career Technology Department Head
Technology Coordinator
Asst. Athletic Director

"A posse ad esse", from possibility to actuality...

Big brother is watching so watch what you put in the email!

Under Florida law, e-mail addresses, and all communications, including
e-mail communications, made or received in connection with the transaction
of School Board business are public records, which must be retained as
required by law and must be disclosed upon receipt of a public records
request, except as may be excluded by federal or state laws.  If you do
not want your e-mail address released in response to a public records
request, do not send electronic mail to this entity. Instead, contact this
office by phone or in writing.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20130904/b630acd1/attachment-0001.html

------------------------------

_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers


End of alice-teachers Digest, Vol 38, Issue 2
*********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20130907/2c6a7bd1/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: don't splash the penguin fig 10-11.png
Type: image/png
Size: 134644 bytes
Desc: don't splash the penguin fig 10-11.png
Url : http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20130907/2c6a7bd1/attachment-0001.png 


More information about the alice-teachers mailing list