當前位置: 首頁>>代碼示例>>Python>>正文


Python Menu.links方法代碼示例

本文整理匯總了Python中Menu.Menu.links方法的典型用法代碼示例。如果您正苦於以下問題:Python Menu.links方法的具體用法?Python Menu.links怎麽用?Python Menu.links使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Menu.Menu的用法示例。


在下文中一共展示了Menu.links方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from Menu import Menu [as 別名]
# 或者: from Menu.Menu import links [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.links方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。