()
| 367 | |
| 368 | |
| 369 | def game_loop(): |
| 370 | global score |
| 371 | reset_game() |
| 372 | round_over = False |
| 373 | winner_img = None |
| 374 | game_started = True |
| 375 | |
| 376 | countdown() |
| 377 | |
| 378 | while True: |
| 379 | draw_bg(bg_image, is_game_started=game_started) |
| 380 | |
| 381 | draw_text(f"P1: {score[0]}", score_font, RED, 20, 20) |
| 382 | draw_text(f"P2: {score[1]}", score_font, RED, SCREEN_WIDTH - 220, 20) |
| 383 | draw_health_bar(fighter_1.health, 20, 50) |
| 384 | draw_health_bar(fighter_2.health, SCREEN_WIDTH - 220, 50) |
| 385 | |
| 386 | exit_button = draw_button( |
| 387 | "MAIN MENU", menu_font, BLACK, YELLOW, SCREEN_WIDTH // 2 - 150, 20, 300, 50 |
| 388 | ) |
| 389 | |
| 390 | if not round_over: |
| 391 | fighter_1.move(SCREEN_WIDTH, SCREEN_HEIGHT, fighter_2, round_over) |
| 392 | fighter_2.move(SCREEN_WIDTH, SCREEN_HEIGHT, fighter_1, round_over) |
| 393 | |
| 394 | fighter_1.update() |
| 395 | fighter_2.update() |
| 396 | |
| 397 | if not fighter_1.alive: |
| 398 | score[1] += 1 |
| 399 | round_over = True |
| 400 | winner_img = wizard_victory_img |
| 401 | elif not fighter_2.alive: |
| 402 | score[0] += 1 |
| 403 | round_over = True |
| 404 | winner_img = warrior_victory_img |
| 405 | else: |
| 406 | victory_screen(winner_img) |
| 407 | return |
| 408 | |
| 409 | fighter_1.draw(screen) |
| 410 | fighter_2.draw(screen) |
| 411 | |
| 412 | for event in pygame.event.get(): |
| 413 | if event.type == pygame.QUIT: |
| 414 | pygame.quit() |
| 415 | exit() |
| 416 | if event.type == pygame.MOUSEBUTTONDOWN: |
| 417 | if exit_button.collidepoint(event.pos): |
| 418 | return |
| 419 | |
| 420 | pygame.display.update() |
| 421 | clock.tick(FPS) |
| 422 | |
| 423 | |
| 424 | while True: |
no test coverage detected