Tiger12506 wrote: >> Based on your guidance, I figured it out. I need to use a return >> statement, which I had not encountered before. Now I wrote my >> definitions in this way: >> >> def collided(): >> if player_x == robot_x+0.5 and player_y == robot_y+0.5: >> return True >>
Granting that I have not looked at any of the Livewires modules, I just wanted to say... A general check for collision would probably involve the distance formula from geometry collided( (x1,y1), (x2,y2) ): return( sqrt( (x1-x2)**2 + (y1-y2)**2 ) < 1 ) but could probably be simplified to something like: def collided( (x1,y1), (x2,y2) ): return( abs( x1 - x2 ) < .5 and abs( y1 - y2 ) < .5 ) > > This could be simplified more. > Here's an example as a hint. These two functions are the same. > > def f(): > if a == b and c == d: > return True > > def g(): > return (a==b and c == d) > > > >> Then I use that value in another definition like this: >> >> def check_collisions(): >> if collided() == 1: >> print "You have been caught" >> > > And ~ > > if collided(): > print "You have been caught" > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor