Hi, I just had a conversation with some people at #pygame on IRC, and it seems that at least me and unlucky777 agree that it would be cool to be able to pass an offset value to the drawing function on pygame sprite groups. The idea is that people who think about a "camera" (or when writing games have something more natural to work with).
Anyway, unlucky777 came up wth some modified renderUpdates sprite group to solve a scrolling problem, while I caught myself putting offset information on the update method of my sprite classes so I could deal with the same problem (but apparently in an uglier way). I'm attaching unlycky777's relevant piece of code, and also what I came up with. Personally, I like unlucky's idea better. Any thoughts? -Thiago
#from the sprite (module?) class RenderUpdates(Group): def draw(self, surface, offset): spritedict = self.spritedict surface_blit = surface.blit dirty = self.lostsprites self.lostsprites = [] dirty_append = dirty.append for s in self.sprites(): r = spritedict[s] newrect = surface_blit(s.image, s.rect.move(offset)) if r is 0: dirty_append(newrect) else: if newrect.colliderect(r): dirty_append(newrect.union(r)) else: dirty_append(newrect) dirty_append(r) spritedict[s] = newrect return dirty