basic animation when player moves
better shot position
This commit is contained in:
parent
e395dc39bb
commit
7e8a2c7e7b
1 changed files with 6 additions and 1 deletions
|
@ -77,6 +77,9 @@ class Bullet(Object):
|
||||||
def __init__(self, frames, type, pos):
|
def __init__(self, frames, type, pos):
|
||||||
Object.__init__(self, frames, pos, (0, 0))
|
Object.__init__(self, frames, pos, (0, 0))
|
||||||
self.type = type
|
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):
|
def update(self):
|
||||||
# destroy when collide or when exists the screen
|
# destroy when collide or when exists the screen
|
||||||
|
@ -103,6 +106,7 @@ class Player(Object):
|
||||||
""" initiate moving sequence """
|
""" initiate moving sequence """
|
||||||
globals.moving_objects.add(self)
|
globals.moving_objects.add(self)
|
||||||
self.speed = (self.speed[0] + vector[0], self.speed[1] + vector[1])
|
self.speed = (self.speed[0] + vector[0], self.speed[1] + vector[1])
|
||||||
|
self.image = self.frames[1]
|
||||||
|
|
||||||
def stop_move(self, vector):
|
def stop_move(self, vector):
|
||||||
""" stop moving sequence """
|
""" stop moving sequence """
|
||||||
|
@ -110,6 +114,7 @@ class Player(Object):
|
||||||
|
|
||||||
if self.speed == (0, 0):
|
if self.speed == (0, 0):
|
||||||
globals.moving_objects.remove(self)
|
globals.moving_objects.remove(self)
|
||||||
|
self.image = self.frames[0]
|
||||||
|
|
||||||
def start_shoot(self):
|
def start_shoot(self):
|
||||||
self.shooting = True
|
self.shooting = True
|
||||||
|
@ -234,7 +239,7 @@ wait_keypress()
|
||||||
nbframe = 0
|
nbframe = 0
|
||||||
|
|
||||||
# create_player
|
# create_player
|
||||||
player = Player(['player1_1.bmp'], (50, 50), (0, 0))
|
player = Player(['player1_1.bmp', 'player1_2.bmp'], (50, 50), (0, 0))
|
||||||
|
|
||||||
# background
|
# background
|
||||||
globals.background = pygame.image.load(os.path.join('data', 'background.bmp')).convert()
|
globals.background = pygame.image.load(os.path.join('data', 'background.bmp')).convert()
|
||||||
|
|
Loading…
Reference in a new issue