Commits

Anonymous committed 4b7ba49

RenderClear.clear() can take func

Comments (0)

Files changed (4)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+March 4, 2002
+        sprite.RenderClear can accept a function as bgd
+
 February 19, 2002
 	event.peek() returns next event [BREAK?]
 	Event objects have 'truth' operator

docs/ref/pygame_sprite.html

 </tt></font><ul>
            Clears the area of all drawn sprites. the bgd
            argument should be Surface which is the same
-           dimensions as the surface.
+           dimensions as the surface. The bgd can also be
+	   a function which gets called with the passed
+	   surface and the area to be cleared.
 </ul><br>&nbsp;<br>
 
 <a name=RenderClear.draw><font size=+2><b>RenderClear.draw
 
            Clears the area of all drawn sprites. the bgd
            argument should be Surface which is the same
-           dimensions as the surface."""
-        surface_blit = surface.blit
-        for r in self.lostsprites:
-            surface_blit(bgd, r, r)
+           dimensions as the surface. The bgd can also be
+	   a function which gets called with the passed
+	   surface and the area to be cleared."""
+	if callable(bgd):
+            for r in self.lostsprites:
+                bgd(surface, r)
+            for r in self.spritedict.values():
+                if r is not 0: bgd(surface, r)
+	else:
+            surface_blit = surface.blit
+            for r in self.lostsprites:
+                surface_blit(bgd, r, r)
+            for r in self.spritedict.values():
+                if r is not 0: surface_blit(bgd, r, r)
         self.lostsprites = []
-        for r in self.spritedict.values():
-            if r is not 0:
-                surface_blit(bgd, r, r)
 
 
 class RenderUpdates(RenderClear):
 	high = screen->h;
 	if(screen->flags & SDL_OPENGL)
 		return RAISE(PyExc_SDLError, "Cannot update an OPENGL display");
-
         
 	/*determine type of argument we got*/
 	if(PyTuple_Size(arg) == 0)
                         ++count;
                 }
         
-                SDL_UpdateRects(screen, count, rects);
+                if(count)
+                    SDL_UpdateRects(screen, count, rects);
                 PyMem_Free((char*)rects);
 	}
 	RETURN_NONE
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.