def update(self): Block.update(self) self.rotate() for enemy in pygame.sprite.spritecollide(self, self.enemies, False): if enemy.harmful: enemy.kill() resources.getSound('hurt.wav').play() if self.hitTick > 0: break self.lives -= 1 self.hitTick = 100 self.imgTick = 80 self.orig_img = self.player_hurt_img for _ in pygame.sprite.spritecollide(self, self.newLife, True): resources.getSound('life.wav').play() self.imgTick = 80 self.orig_img = self.player_newlife_img self.lives += 1 if self.hitTick > 0: self.hitTick -= 1 if self.imgTick > 0: self.imgTick -= 1 if self.imgTick == 0: self.orig_img = self.player_img
def run(playmusic=True): if playmusic and pygame.mixer: resources.getSound('bgmusic.wav').play(-1) while GAME_MODE != GAME_QUIT: if GAME_MODE == GAME_PLAY: gameLoop() elif GAME_MODE == GAME_MENU: menuLoop() elif GAME_MODE == GAME_LOGO: logoLoop() elif GAME_MODE == GAME_OVER: gameOverLoop() elif GAME_MODE == GAME_INFO: instructionLoop() pygame.mixer.quit() pygame.quit() quit(0)