示例#1
0
    def main(self):
        while 1:
            screen.fill((160, 180, 250))

            # 強制アニメーション
            if self.Player.goal_animation():
                global REMAIN
                REMAIN += 1
                state_change(2)
                return
            if self.Player.dokan_animation() or self.Player.death_animation():
                return

            self.Player.update()
            self.Enemy.update()
            self.Player.item_animation()
            self.Stage.update()

            Text.update()

            # スペースキーで2倍速
            variable_FPS = FPS * (2
                                  if pygame.key.get_pressed()[K_SPACE] else 1)
            clock.tick(variable_FPS)

            pygame.display.update(Rect(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT))

            for event in pygame.event.get():
                # 「×」ボタンが押されたら終了
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()

                if event.type == KEYDOWN:
                    # ESCキーが押されたら終了
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
                    # F1キーが押されたらタイトルに戻る
                    if event.key == K_F1:
                        state_change(0)
                        return
                    # oキーが押されたら自殺
                    if event.key == K_o:
                        Stage.player_object.isDeath = True