Re: [pygame] Pixel Perfect collision suggestion.
Sure, John! We could also submit this patch to pygame, thereby making the basic collision system faster. What say we make a patch? Regards, Karthik John Eriksson wrote: You are right! Your algorithm is actually a bit faster :-D At first it seems you've added some extra loops but when looking closer I saw that you're code check edges first instead of roaming thourgh the pixels top to bottom. Well done! I would like to include your algorithm in the PixelPerfect example if its ok with you? Best Regards /John
Re: [pygame] Pixel Perfect collision suggestion.
I didn't now there where any pixel perfect collision code in pygame? /John ons 2007-01-31 klockan 15:13 +0530 skrev V. Karthik Kumar: > Sure, John! > > We could also submit this patch to pygame, thereby making the basic > collision system faster. What say we make a patch? > > Regards, > Karthik > > John Eriksson wrote: > > You are right! Your algorithm is actually a bit faster :-D > > At first it seems you've added some extra loops but when looking closer > > I saw that you're code check edges first instead of roaming thourgh the > > pixels top to bottom. > > > > Well done! > > > > I would like to include your algorithm in the PixelPerfect example if > > its ok with you? > > > > Best Regards > > /John > >
Re: [pygame] Pixel Perfect collision suggestion.
@John No, there isn't any. @Kamilche: Rectangular/polygon collision is much faster than pixel perfect collision. But ppcol is a viable alternative in certain games such as street fighter or mk (the older ones) Just an idea here. It would be nice if we did have different coll-d algorithms in pygame; because people do a variety of games. Especially rectangular, circular, convex-polygon and ppcol methods. Regards John Eriksson wrote: I didn't now there where any pixel perfect collision code in pygame? /John ons 2007-01-31 klockan 15:13 +0530 skrev V. Karthik Kumar: Sure, John! We could also submit this patch to pygame, thereby making the basic collision system faster. What say we make a patch? Regards, Karthik John Eriksson wrote: You are right! Your algorithm is actually a bit faster :-D At first it seems you've added some extra loops but when looking closer I saw that you're code check edges first instead of roaming thourgh the pixels top to bottom. Well done! I would like to include your algorithm in the PixelPerfect example if its ok with you? Best Regards /John
[pygame] sdl_ttf font render failed
hi pygamers, whenever I use font.render() with the antialias param set to False I get this error: File "pysssi_dist.py", line 258, in printf s = self.print_font.render( str,False,self.color1) pygame.error: SDL_ttf render failed Anyone know why this is so? I'm using libsdl-ttf1.2 and pygame 1.7.1 on an ubuntu system. Easily reproducable: import pygame pygame.init() (6, 0) font = pygame.font.Font(pygame.font.get_default_font(),12) text = font.render("hello world",False,(255,0,0)) Traceback (most recent call last): File "", line 1, in ? pygame.error: SDL_ttf render failed text = font.render("hello world",True,(255,0,0)) (works...) greetings from AT simon
Re: [pygame] Pixel Perfect collision suggestion.
Okay, I modified the code a little bit more. This takes care of the odd number of rows/columns in the intersection window. I guess there shouldn't me any more changes in this. Regards def pp_collide(obj1,obj2): """If the function finds a collision it will return True if not it will return False. """ rect1, rect2, hm1, hm2 = obj1.rect, obj2.rect, obj1.hitmask, obj2.hitmask if not rect1.colliderect(rect2): return False rect = rect1.clip(rect2) w, h, x1, y1, x2, y2 = rect.width, rect.height, rect.x-rect1.x, rect.y-rect1.y, rect.x-rect2.x, rect.y-rect2.y if w%2: for y in range(h): if hm1[x1+w-1][y1+y] and hm2[x2+w-1][y2+y]: return True w=w-1 if h%2: for x in range(w): if hm1[x1+x][y1+h-1] and hm2[x2+x][y2+h-1]: return True h=h-1 while w > 0 and h > 0: for x in range(w): if hm1[x1+x][y1] and hm2[x2+x][y2]: return True if hm1[x1+x][y1+h-1] and hm2[x2+x][y2+h-1]: return True for y in range(1, h-1): if hm1[x1][y1+y] and hm2[x2][y2+y]: return True if hm1[x1+w-1][y1+y] and hm2[x2+w-1][y2+y]: return True w, h, x1, y1, x2, y2 = w-2, h-2, x1+1, y1+1, x2+1, y2+1 return False
[pygame] numpy patched modules for Win available
For anyone with Windows who wants to trying out NumPy with Pygame I have applied the numpy patch to the surfarray and sndarray modules for Pygame 1.8.0 and Python 2.4. The pyd's are available as: http://www3.telus.net/len_l/pygame18-numpy-py24-win.zip The md5 checksum is: fe477c30aaa2085afe29430c16f1a262 *- Just replace the corresponding files in the pygame package directory ( making sure to save the originals :-) ). I can also make Python 2.5 versions of the extension modules available if asked. Have fun, Lenard -- Lenard Lindstrom <[EMAIL PROTECTED]>
Re: [pygame] sdl_ttf font render failed
On Wed, Jan 31, 2007 at 03:42:37PM +0100, Simon Oberhammer wrote: > hi pygamers, > whenever I use font.render() with the antialias param set to False I > get this error: > > File "pysssi_dist.py", line 258, in printf >s = self.print_font.render( str,False,self.color1) > pygame.error: SDL_ttf render failed Actually, you only get this if you call font.render with a string that contains a space character, and with antialias set to False. Seems to be a known bug in the SDL_ttf version that is in Ubuntu. Marius Gedminas -- Always proofread carefully to see if you any words out. signature.asc Description: Digital signature