当前位置: 首页>>代码示例>>Python>>正文


Python Maze.display_maze方法代码示例

本文整理汇总了Python中maze.Maze.display_maze方法的典型用法代码示例。如果您正苦于以下问题:Python Maze.display_maze方法的具体用法?Python Maze.display_maze怎么用?Python Maze.display_maze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maze.Maze的用法示例。


在下文中一共展示了Maze.display_maze方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Main

# 需要导入模块: from maze import Maze [as 别名]
# 或者: from maze.Maze import display_maze [as 别名]

#.........这里部分代码省略.........
            murdoc_win = pygame.image.load(MURDOC_WIN).convert()

            if winner == "McGyver":
                self.window.blit(mcgyver_win, (0, 0))
                self.message_to_screen("You win", WHITE, -75)
                pygame.display.update()
            elif winner == "Murdoc":
                self.window.blit(murdoc_win, (0, 0))
                self.message_to_screen("You loose", WHITE, -75)
                pygame.display.update()
            self.message_to_screen("Press P to play agin or Q to quit", WHITE)
            pygame.display.flip()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.game_over = False
                    self.game_exit = True

                if event.type == pygame.KEYDOWN:
                    if event.key == K_p:
                        self.game_over = False
                        self.game_exit = False
                        # Reset the object
                        self.maze.__init__()
                        self.maze.mac.__init__()
                        display_screen = False
                    elif event.key == K_q:
                        self.game_over = False
                        self.game_exit = True
                        display_screen = False

    def event_in_pygame(self):

        move = True

        while move:
            for event in pygame.event.get():

                # check for closing window
                if event.type == pygame.QUIT:
                    self.game_exit = True
                    self.game_over = False
                    move = False
                elif event.type == KEYDOWN:
                    # Escape to quit
                    if event.key == K_ESCAPE:
                        self.game_exit = True
                        self.game_over = False
                        move = False

                    # Arrow keys to move McGyver
                    elif event.key == K_RIGHT:
                        self.maze.mac.move(self.maze, 'right')
                    elif event.key == K_LEFT:
                        self.maze.mac.move(self.maze, 'left')
                    elif event.key == K_UP:
                        self.maze.mac.move(self.maze, 'up')
                    elif event.key == K_DOWN:
                        self.maze.mac.move(self.maze, 'down')
                    # Show the items colectted
                    elif event.key == K_TAB:
                        self.show_items_collected()
                    elif event.key == K_ESCAPE:
                        self.game_over = False
                        self.game_exit = True

                    self.maze.display_maze(self.window)
                    pygame.display.flip()
                    self.game_over = self.maze.game_over()
            
            if self.game_over:
                move = False

    # Main loop
    def main_loop(self):

        pygame.display.flip()
                        
        while not self.game_exit:

            # Slow down the loop
            pygame.time.Clock().tick(30)

            # Display the maze
            self.maze.display_maze(self.window)

            # Refresh the screen
            pygame.display.flip()

            # While McGyver have not find the guardian, he can move around the map
            if not self.game_over:

                self.event_in_pygame()

            # Show a screen where you can quit or play again
            else:

                self.screen_game_over()

        self.game_exit = True
开发者ID:sneakyPeat,项目名称:Maze,代码行数:104,代码来源:main.py


注:本文中的maze.Maze.display_maze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。