basic animation when player moves

better shot position
This commit is contained in:
kleph 2009-08-17 01:47:25 +02:00
parent e395dc39bb
commit 7e8a2c7e7b

View file

@ -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()