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


Python Menu.credits方法代码示例

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


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

示例1: main

# 需要导入模块: from Menu import Menu [as 别名]
# 或者: from Menu.Menu import credits [as 别名]
def main():
    #screen_size = w, h = (1000,600)
    screen_size = w, h = (1366, 768)
    """screen_size"""

    screen = pygame.display.set_mode(screen_size)
    pygame.display.set_caption("SLC Game")
    """Set up display"""

    main_world = World(screen_size)
    """set up the game handler"""
    
    pygame.mouse.set_visible(False)
    
    menu_cursor_image = main_world.image_funcs.get_image(3, 1)
    menu_cursor_image.set_colorkey((255, 0, 255))

    main_menu = Menu(screen_size)

    clock = pygame.time.Clock()
    """set up the game clock"""

    target_fps = 120.0

    game_states = ["menu", "game", "help", "win", "lose"]
    current_state = game_states[0]

    sleep_timer = 0

    done = False
    while not done:
        """main game loop"""

        to_debug = False
        time_passed_seconds = clock.tick(target_fps) / 1000.0
        pos = pygame.mouse.get_pos()
        mouse_pos = vec2(pos[0], pos[1])
        """get the time (in seconds) since the last frame.
            Used for movement based on time."""

        for event in pygame.event.get():
            """Get every event that has happened since the
            last frame and loop through it."""
            if event.type == pygame.QUIT:
                done = True

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    #done = True
                    current_state = "menu"
                    """This is separate from the pressed keys because
                    this is just a single event rather than every frame
                    the key is pressed down. Good for events you only
                    want happening once."""

                if event.key == pygame.K_F2:
                    """Screenshots"""

                    random_string = ""
                    for i in range(10):
                        random_string += str(random.randint(0, 9))
                        pygame.image.save(screen, random_string + ".png")

                elif event.key == pygame.K_g:
                    to_debug = True

        if current_state == "menu":

            screen.fill((0, 0, 0))

            option = main_menu.handle_mouse_input(mouse_pos, pygame.mouse.get_pressed())
            if option is not None:
                main_world.sound_classes[0].play()

                if option == 1:
                    """start"""
                    current_state = "game"
                    pygame.mixer.music.stop()
                    main_world.game_over = False
                    try:
                        main_world.set_up_level(main_world.levels[main_world.level_index])
                    except IndexError:
                        main_world.level_index = 0
                        main_world.set_up_level(main_world.levels[main_world.level_index])

                elif option == 2:
                    """level select"""
                    current_state = "level select"

                elif option == 3:
                    """help"""
                    current_state = "help"

                elif option == 4:
                    """links"""
                    current_state = "links"

                elif option == 5:
                    """credits"""
                    current_state = "credits"
#.........这里部分代码省略.........
开发者ID:robert-fiedor,项目名称:983-Python-Play,代码行数:103,代码来源:SLCGame.py


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