Mercurial > skaapsteker
diff skaapsteker/sprites/base.py @ 366:249ba3bd6904
Very, very frightening.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 14:46:23 +0200 |
parents | 02bf05964619 |
children | 92cf515a6cf6 |
line wrap: on
line diff
--- a/skaapsteker/sprites/base.py Sat Apr 09 14:39:18 2011 +0200 +++ b/skaapsteker/sprites/base.py Sat Apr 09 14:46:23 2011 +0200 @@ -236,12 +236,29 @@ DAMAGE = 10 - def setup(self, hits): + PROJECTILE_SIZE = (0, 0) # pixels + VELOCITY = (10, 10) # pixels/s + + def setup(self, direction, hits, **opts): + super(Projectile, self).setup(**opts) + self.facing = direction + if isinstance(hits, tuple): self.hits = hits + (Geography,) else: self.hits = (hits, Geography) + if self.facing == "left": + shift = (-self.PROJECTILE_SIZE[0] / 2, self.PROJECTILE_SIZE[1]) + dv = (-self.VELOCITY[0], self.VELOCITY[1]) + else: + shift = (self.PROJECTILE_SIZE[0] / 2, self.PROJECTILE_SIZE[1]) + dv = (self.VELOCITY[0], self.VELOCITY[1]) + + self.rect.move_ip(shift) + self.collide_rect.move_ip(shift) + self.deltav(dv) + def explode(self): self.kill()