Here's an alternative demo showing the use of towards():

###
def food(pos=[0,100]):
    x,y=pos
    old=position()
    up();tracer(0)
    goto((x,y))
    down();circle(2);up()
    goto(old)
    down();tracer(1)
    pos[0]+=10
    print x,y
    return x,y

reset()
bug=food()
while hypot(*[position()[x]-bug[x] for x in [0,1]])>4:
    setheading(towards(bug))
    forward(15)
    clear()
    bug=food()
write('  caught!')
done() 
###


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"edupython" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/edupython
-~----------~----~----~----~------~----~------~--~---

Reply via email to