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


Python Engine.check_kittens方法代碼示例

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


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

示例1: run_game

# 需要導入模塊: from Engine import Engine [as 別名]
# 或者: from Engine.Engine import check_kittens [as 別名]
def run_game():
    # Get access to our game settings
    settings = Settings()
    engine = Engine()
 
    # initialize game
    pygame.init()
    screen = pygame.display.set_mode( (settings.screen_width, settings.screen_height), 0, 32)
    clock = pygame.time.Clock()
    scoreboard = Scoreboard(screen, settings)
    play_button = Button(screen, settings.screen_width/2-settings.button_width/2,
                            settings.screen_height/2-settings.button_height/2, settings, "Play Balloon Ninja")
    game_over_button = Button(screen, play_button.x_position, play_button.y_position-2*settings.button_height,
                            settings, "Game Over")
    instructions = Instructions(screen, settings)
 
    # Create a list to hold our balloons, and our kittens
    balloons = []
    kittens = []
 
    # Create our dagger
    sword = Sword(screen, settings.scoreboard_height)
 
    # main event loop
    while True:
        # Advance our game clock, get the current mouse position, and check for new events
        time_passed = clock.tick(50)
        mouse_x, mouse_y = pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]
        engine.check_events(settings, scoreboard, sword, play_button, mouse_x, mouse_y, balloons)
 
        # Redraw the empty screen before redrawing any game objects
        screen.fill(settings.bg_color)
 
        if settings.game_active:
            # Update the sword's position and check for popped or disappeared balloons
            engine.update_sword(sword, mouse_x, mouse_y, settings)
            engine.check_balloons(balloons, kittens, sword, scoreboard, screen, settings, time_passed)
            engine.check_kittens(kittens, sword, scoreboard, screen, settings, time_passed)
 
            # If all balloons have disappeared, either through popping or rising,
            #  release a new batch of balloons.
            if len(balloons) == 0:
                # If we are not just starting a game, increase the balloon speed and points per balloon,
                #  and increment batches_finished
                if scoreboard.balloons_popped > 0:
                    #  Increase the balloon speed, and other factors, for each new batch of balloons.
                    settings.balloon_speed *= settings.speed_increase_factor
                    settings.kitten_ratio *= settings.speed_increase_factor
                    settings.points_per_balloon = int(round(settings.points_per_balloon * settings.speed_increase_factor))
                    scoreboard.batches_finished += 1
                # If player has completed required batches, increase batch_size
                if scoreboard.batches_finished % settings.batches_needed == 0 and scoreboard.batches_finished > 0:
                    settings.batch_size += 1
                engine.release_batch(screen, settings, balloons, kittens)
        else:
            # Game is not active, so...
            #  Show play button
            play_button.blitme()
            #  Show instructions for first few games.
            if settings.games_played < 3:
                instructions.blitme()
            #  If a game has just ended, show Game Over button
            if settings.games_played > 0:
                game_over_button.blitme()
 
        # Display updated scoreboard
        scoreboard.blitme()
 
        # Show the redrawn screen
        pygame.display.flip()
開發者ID:WeirdbutCoolGamer,項目名稱:Balloon-Ninja,代碼行數:72,代碼來源:balloon_ninja.py


注:本文中的Engine.Engine.check_kittens方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。