import pygame import sys
pygame.init()
screen_width, screen_height = 800, 600 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("Игра: Работа с клиентами")
WHITE = (255, 255, 255) BLACK = (0, 0, 0) GREY = (169, 169, 169)
font = pygame.font.SysFont(None, 36)
phone_img = pygame.image.load('phone_icon.png') # Убедись, что иконка телефона есть в той же папке
dialog_text = "Здравствуйте, у меня возникла проблема с заказом, можете помочь?" response_options = [
"1. Здравствуйте, конечно, расскажите подробнее о вашей проблеме.",
"2. Извините, это не в нашей компетенции.",
"3. Мы не можем помочь в данный момент."
]
button_rects = [
pygame.Rect(50, 500, 700, 50),
pygame.Rect(50, 550, 700, 50),
pygame.Rect(50, 600, 700, 50),
]
game_status = "waiting" # waiting, playing, finished
def draw_text(text, x, y):
text_surface = font.render(text, True, BLACK)
screen.blit(text_surface, (x, y))
def draw_buttons():
for i, rect in enumerate(button_rects):
pygame.draw.rect(screen, GREY, rect)
draw_text(response_options[i], rect.x + 10, rect.y + 10)
def game_loop():
global game_status
while True:
screen.fill(WHITE)
mouse_pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if game_status == "waiting":
# Принятие звонка
if phone_rect.collidepoint(mouse_pos):
game_status = "playing"
elif game_status == "playing":
# Обработка выбора ответа
for i, rect in enumerate(button_rects):
if rect.collidepoint(mouse_pos):
if i == 0: # Правильный ответ
game_status = "finished"
else: # Неправильный ответ
game_status = "waiting" # Перезапуск сцены
if game_status == "waiting":
# Отображаем телефон для принятия звонка
phone_rect = phone_img.get_rect(center=(screen_width // 2, screen_height // 2 - 100))
screen.blit(phone_img, phone_rect)
draw_text("Нажмите на телефон, чтобы принять звонок", 200, 50)
elif game_status == "playing":
# Отображаем диалог
draw_text(dialog_text, 50, 50)
draw_buttons()
elif game_status == "finished":
# Завершение сцены
draw_text("Клиент доволен, задача выполнена!", 250, 50)
pygame.display.flip()
game_loop()