| |||||||||||
PyWeek - Help on Collision Detection PleaseMy collision detection won't work, why?bt1 = pygame.Rect(0, 0, 5, 5) bt2 = pygame.Rect(0, 0, 5, 5) bt3 = pygame.Rect(0, 0, 5, 5) you_box = pygame.Rect(0, 0, 25, 44) btm1 = Rect.move(bt1, bx, by) btm2 = Rect.move(bt2, bx2, by2) btm3 = Rect.move(bt3, bx3, by3) you_boxm = pygame.Rect.move(you_box, x,y) collide = Rect.collidelistall(you_box, bt1) It won't work, why?! — john on 2007/04/03 09:41 of |Gunboy Comments: (log in to comment) |
Last Challenge
September 2008 [entries, ratings] Previous March 2008 [entries, ratings] September 2007 [entries, ratings] > April 2007 [entries, ratings] September 2006 [entries, ratings] March 2006 [entries, ratings] (June 2006) August 2005 [entries, ratings] Not logged in Login | ||||||||||
By eugman on 2007/04/03 10:38:
You probably need to use move_ip . If you don't move in place then you are just saving to btm1 what you would get if you moved. Just a random guess.By gizmo_thunder on 2007/04/03 11:30:
I hope you are trying to find the collision of other objects with you_box. here is how it should be This will workBy john on 2007/04/03 15:11:
Thanks, it works now!By john on 2007/04/03 15:15:
One prob though, I want to break the loop whenever they collide, how can I do that?By john on 2007/04/03 15:37:
Ok, just worked it out, but it's crashing my code, the only way I can stop it, is if I know how many digits are in the string, or if it's empty, so how can I find out how many digits are in a string, (if there is any).By Tee on 2007/04/03 19:38:
Do you mean the length of a string? len(s) returns that. It returns 0 if the string has no characters (the length is 0).