alice-teacher s Digest, Vol 34, Issue 6 - Mr. Shoes

Robert Durtschi robert.durtschi at gcsu.edu
Wed May 8 16:55:33 EDT 2013


Hi Sarah;

Your student's problem reminds me of the collision check method from the "Penguin Splash" world in chapter 10 of "AN INTRODUCTION TO PROGRAMMING USING ALICE 2.2, SECOND EDITION" by Charles W. Herbert

Comparing your world with that one, I suspect that the shoes are not disappearing  because the method is only called once... Yep.  In fact it looks like it may not be called at all.  

I found this out by using one of the few debugging tools offered by Alice.  I dragged a print just before the first "if" in method "Mr Shoes.Shoesdissaperingemphetiment":

     print ( Mr Shoes distance to sneaker )   <<<added>>>
       If ( Mr Shoes is within 2 meters of sneaker )  

It looks like the event that invokes it never makes it to the "during" part.
The solution is to put the invocation of (call to) Mr Shoes.Shoesdissaperingemphetiment into a SEPARATE "while the world is running" event:

    Let <arrows> move Mr Shoes 

    While the world is running 
        Begin: world.my first method 
        During: <None>  
        End: <None>  

    While the world is running            <<<added>>>
       Begin: <None>  
       During: Mr Shoes.Shoesdissaperingemphetiment 
       End: <None>  

Yes.  That looks like it works.

Just in case your student is not familiar with how to set that event up:
  1. click on "create new event" button
  2. choose "when the world starts"
  3. right click on the new "when the world starts" event and choose "change to"
  4 drag the method into the "none" in the "while the world is running" part


There is a shortcut that I also found in the penguin splash world that might be useful.
If you set up an object list variable "shoes" in the world properties tab your distance check can be reduced to one "if" instead of 10. Another advantage is you can add more sneakers or remove sneakers without having to change the code.

After adding the rest of the shoes to the world
click on "create new variable" in the world Properties tab
select "object" as the type
click on the "make a list" checkbox
inside the window that pops up click on "new item" button
click on "none" and select "sneaker => the entire sneaker"
click on "new item" again
click on "none" and select  "sneaker2 => the entire sneaker2"
etc. until all the sneakers have been added to the shoes list.

You can update the list at any time by clicking on the list. Not the name, the list itself.

Now you can go to the "Mr Shoes.Shoesdissaperingemphetiment" drag a "for all together" from the bottom of the screen and drag your first "if..." inside of it and change all occurances of "sneaker" to "item from shoes"

I'll do that in your world and attach it so you can see how it works.

Best
Bob Durtschi


________________________________________
   1.  Need help with student Alice world (Sarah Rave)

Our 8th grade students decided they wanted to make simple video games for
their Alice assignment. This has been their first introduction to if/else
statements and many have found it challenging. One student is creating a
game where the character, Mr Shoes, has to go around and collect shoes. He
has built a timer and written a method to have Mr Shoes walk while the arrow
keys move him around the screen.

Our problem is if Mr Shoes waits for the instructions and the timer to
begin, the shoes don't disappear. If Mr Shoes goes to the shoe while the
instructions are being given, then when the timer starts, the shoe
disappears as desired.

I am going to attempt to attach a Word doc with screen shots of all of the
methods and the alice world itself. I have been monkeying around with this
world and have replaced his If/Else statement with a While statement. It
didn't change anything.

Thanks for any help you can provide.

Sarah Rave

Sarah Rave

Mountain Discovery Charter School
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NS8-MrShoes.a2w
Type: application/octet-stream
Size: 2566540 bytes
Desc: NS8-MrShoes.a2w
Url : http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20130508/f9be1610/attachment-0001.obj 


More information about the alice-teachers mailing list