Tonu Mikk wrote: > Eric Brunson wrote: > >> 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 ) >> >> >> > Thanks Eric for your suggestions. I believe Livewires modules have > simplified collision checking for programming novices like myself. > There are two shapes that I am working with, a circle and a square. The > position of the circle is defined by the center coordinates whereas the > position of the square is defined by the lower left corner of the > square. When my circle is 0.5 points in diameter, I can add this much > to both x and y coordinates of the square which will then give me the > point where the square is sitting on top of the circle. It took me a > long time to figure this out. I had to re-read the Graphics guide sheet > that came with Livewires multiple times to try to get it to work > correctly. I believe this part of my code is OK. > >
Good deal and good luck. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor