From 7e8a2c7e7b093bf52800ab1c8bec50edc249c366 Mon Sep 17 00:00:00 2001 From: kleph Date: Mon, 17 Aug 2009 01:47:25 +0200 Subject: [PATCH] basic animation when player moves better shot position --- pyshoot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyshoot.py b/pyshoot.py index 6d7c5cb..25b7570 100755 --- a/pyshoot.py +++ b/pyshoot.py @@ -77,6 +77,9 @@ class Bullet(Object): def __init__(self, frames, type, pos): Object.__init__(self, frames, pos, (0, 0)) self.type = type + # recenter the sprite + # self.rect = self.rect.move((0, - self.rect.height / 2)) + self.rect = self.rect.move((-32, - self.rect.height / 2)) def update(self): # destroy when collide or when exists the screen @@ -103,6 +106,7 @@ class Player(Object): """ initiate moving sequence """ globals.moving_objects.add(self) self.speed = (self.speed[0] + vector[0], self.speed[1] + vector[1]) + self.image = self.frames[1] def stop_move(self, vector): """ stop moving sequence """ @@ -110,6 +114,7 @@ class Player(Object): if self.speed == (0, 0): globals.moving_objects.remove(self) + self.image = self.frames[0] def start_shoot(self): self.shooting = True @@ -234,7 +239,7 @@ wait_keypress() nbframe = 0 # create_player -player = Player(['player1_1.bmp'], (50, 50), (0, 0)) +player = Player(['player1_1.bmp', 'player1_2.bmp'], (50, 50), (0, 0)) # background globals.background = pygame.image.load(os.path.join('data', 'background.bmp')).convert()