def play_level(player, platform_group, badguy_group, hook_group): left_rope_group = pygame.sprite.Group() right_rope_group = pygame.sprite.Group() while True: timer.begin() window.fill((100,100,0)) player.update(platform_group, timer.get_frame_duration(), hook_group) #player update sets velocity others modify hook_group = character.player_input(player, hook_group) for hook in hook_group: hook.update(platform_group, player, timer.get_frame_duration(),left_rope_group,right_rope_group) # this order is important: window.blit(hook.image, hook.rect.topleft) if hook.side == 'left': pygame.draw.line(window, (100,100,255), hook.rect.center, player.rect.center, 2) if hook.side == 'right': pygame.draw.line(window, (255,100,100), hook.rect.center, player.rect.center, 2) for rope in right_rope_group: window.blit(rope.image, rope.rect.topleft) window.blit(player.image, player.rect.topleft) for goomba in badguy_group: window.blit(goomba.image, goomba.rect.topleft) badguy_group.update(platform_group, timer.get_frame_duration()) for platform in platform_group: window.blit(platform.image, platform.rect.topleft) player.move_player(platform_group, timer.get_frame_duration()) pygame.display.update() pygame.time.delay(delay_duration) timer.tick()
def play_level(player, player_group, spike_group, platform_group, badguy_group, hook_group, background_image, level): left_rope_group = pygame.sprite.Group() right_rope_group = pygame.sprite.Group() timer.begin() while not player.win: #game_song.play(-1) if player.reset: #this needs to happen because otherwise play_level never ends #it needs to return level so that play_game knows what level it is, since #level is a local variable for some retarded reason return level #play_game(level) # starts the level over when user presses r window.blit(background_image, (0,0)) duration = timer.get_frame_duration() hook_group = character.player_input(player, hook_group) #checks for hooks #LOL this is retarded if hook_group == 99999: level = main_menu() return level player.colliding(platform_group, duration, hook_group) for hook in hook_group: hook.update(platform_group, player, duration,left_rope_group,right_rope_group) # this order is important: window.blit(hook.image, hook.rect.topleft) if hook.side == 'left': pygame.draw.line(window, hook.color, hook.rect.center, player.rect.center, 2) if hook.side == 'right': pygame.draw.line(window, hook.color, hook.rect.center, player.rect.center, 2) for rope in right_rope_group: window.blit(rope.image, rope.rect.topleft) player.move(duration) window.blit(player.image, player.rect.topleft) for goomba in badguy_group: window.blit(goomba.image, goomba.rect.topleft) badguy_group.update(platform_group, player_group, duration) for platform in platform_group: pygame.draw.rect(window,platform.color,platform.rect) for spike in spike_group: window.blit(spike.image, spike.rect.topleft) draw_deaths(death.counter) spike_group.update(player_group, platform_group, duration) pygame.display.update() pygame.time.delay(delay_duration) timer.tick() if player.win: level +=1 #this needs to happen because otherwise play_level never ends #it needs to return level so that play_game knows what level it is, since #level is a local variable for some retarded reason return level play_game(level)