Mercurial > skaapsteker
changeset 51:8efb35009ba0
Switch to dirty sprites and layered dirty rendering groups in the hopes that it will provide access to speed-ups later on.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 03 Apr 2011 21:25:34 +0200 |
parents | 7d411ed02eac |
children | a18bf35519f3 |
files | skaapsteker/physics.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/physics.py Sun Apr 03 21:18:31 2011 +0200 +++ b/skaapsteker/physics.py Sun Apr 03 21:25:34 2011 +0200 @@ -8,7 +8,7 @@ import time -class Sprite(pygame.sprite.Sprite): +class Sprite(pygame.sprite.DirtySprite): mobile = True # whether the velocity may be non-zero gravitates = True # whether gravity applies to the sprite @@ -21,6 +21,9 @@ self.rect = pygame.Rect(0, 0, 10, 10) # sub-classes should override self.image = pygame.Surface((10, 10)) self.image.fill((0, 0, 200)) + self.visible = 1 + self.dirty = 1 + self.blendmode = 0 def deltav(self, dv): v_x, v_y = self.velocity @@ -43,7 +46,7 @@ GRAVITY = 9.8 # m/s^2 def __init__(self): - self._all = pygame.sprite.Group() + self._all = pygame.sprite.LayeredDirty() self._mobiles = pygame.sprite.Group() self._gravitators = pygame.sprite.Group() self._last_time = None