1

Код дисплея и картинки:

def run_game():
    game = True
    while game:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
        display1()
        scream.play()
        pygame.display.flip()

def display1():
    while True:
        display.blit(disp, (0, 0))
        for e in pygame.event.get():
            while e.type == pygame.MOUSEBUTTONUP:

                display.blit(smile, (0, 0))

                display.blit(smile2, (0, 0))

                display.blit(smile, (0, 0))
                display.blit(smile2, (0, 0))
                pygame.display.update()

при нажатии кнопки на мышке картинка не меняется и потом программа вылетает без ошибок

1 ответ 1

1

Вы два раза отрисоваваете smile и smile2 и лишь потом обновляет экран, вам надо после каждой отрисовки добавит pygame.display.update либо добавить цикл for

for smile_ in (smile, smile2):
    display.blit(smile_, (0, 0))
    pygame.display.update()

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.