本文整理汇总了Python中Engine.Engine.check_balloons方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.check_balloons方法的具体用法?Python Engine.check_balloons怎么用?Python Engine.check_balloons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine.Engine
的用法示例。
在下文中一共展示了Engine.check_balloons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_game
# 需要导入模块: from Engine import Engine [as 别名]
# 或者: from Engine.Engine import check_balloons [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()