def run_bullet(self, dt): x, y = self.position if y > config.WINDOS_HEIGHT + self.height: self.unschedule(self.run_bullet) feiji_event.dispatch_event('on_bullet_resuable', self) y += 10 self.position = x, y self.cshape.center = collision.eu.Vector2(x, y)
def run_enemy(self, dt): x, y = self.position y -= 10 self.position = x, y self.cshape.center = collision.eu.Vector2(x, y) if y <= -self.height: self.unschedule(self.run_enemy) feiji_event.dispatch_event('on_enemy_resuable', self)
def _game_over(self, dt): self.kill() # self.unschedule(self.update_position) self.unschedule(self._game_over) #分发事件 feiji_event.dispatch_event('on_game_over')
def explode(self): self.position = 0, -100 self.unschedule(self.run_bullet) self.cshape.center = collision.eu.Vector2(*self.position) feiji_event.dispatch_event('on_bullet_resuable', self)
def _prepare_to_use(self, dt): self.position = 0, -100 self.cshape.center = collision.eu.Vector2(*self.position) feiji_event.dispatch_event('on_enemy_resuable', self) self.image = pyglet.resource.image('img/enemy/enemy_small1.png') self.unschedule(self._prepare_to_use)
def pause_game(self): feiji_event.dispatch_event("on_game_resume")
def parse_game(self): feiji_event.dispatch_event("on_game_pause")
def rest_game(self): feiji_event.dispatch_event('on_game_start')