def update_ball(self): if self.ball.fired: self.ball.update() else: bx, by = self.ball.sprite.position px, py = self.paddle.sprite.position self.ball.sprite.position = (px, by) collide = collides(self.ball.sprite, self.paddle.sprite) if collide: self.ball.hit() if self.ball.dead(): self.game_over()
def update_blocks(self): # 判断是否撞到了砖块 for b in self.blocks: if collides(self.ball.sprite, b): # self.ball_speedy = -self.ball_speedy self.ball.hit() self.remove(b) self.blocks.remove(b) self.gold += 1 # self.speed += 1 self.update_hud() print('金币', self.gold) break
def update_blocks(self): # 判断是否撞到了砖块 for b in self.blocks: if collides(self.ball.sprite, b): # self.ball_speedy = -self.ball_speedy self.ball.hit() self.remove(b) self.blocks.remove(b) self.gold += 1 # self.speed += 1 self.update_hud() print('捉到', self.gold, '只皮卡丘') break if len(self.blocks) == 0: self.game_win()