import pygame
BLACK = (0, 0, 0)
base_x = 500
base_y = 500
def draw_hangman(win, stage):
"""
Draws the hangman figure on the left side of the screen.
:param win: Pygame window surface to draw on
:param stage: Number of incorrect guesses (0-7)
"""
# Gallows base
pygame.draw.line (win, BLACK, (base_x, base_y), (base_x + 200, base_y), 5)
pygame.draw.line (win, BLACK, (base_x + 100, base_y), (base_x + 100, base_y - 300), 5)
pygame.draw.line (win, BLACK, (base_x + 100, base_y - 300), (base_x + 50, base_y - 300), 5)
pygame.draw.line (win, BLACK, (base_x + 50, base_y - 300), (base_x + 50, base_y - 260), 5)
# Draw parts based on stage
if stage >= 1:
# head
pygame.draw.circle (win, BLACK, (base_x + 50, base_y - 240), 20, 3)
if stage >= 2:
# body
pygame.draw.line (win, BLACK, (base_x + 50, base_y - 220), (base_x + 50, base_y - 160), 3)
if stage >= 3:
# left hand
pygame.draw.line (win, BLACK, (base_x + 50, base_y - 200), (base_x + 20, base_y - 180), 3)
if stage >= 4:
# right hand
pygame.draw.line (win, BLACK, (base_x + 50, base_y - 200), (base_x + 80, base_y - 180), 3)
if stage >= 5:
# ledt leg
pygame.draw.line (win, BLACK, (base_x + 50, base_y - 160), (base_x + 20, base_y - 120), 3)
if stage >= 6:
# right leg
pygame.draw.line (win, BLACK, (base_x + 50, base_y - 160), (base_x + 80, base_y - 120), 3)