Pygame PlayAgain Функция не работает - не позволит пользователю играть снова - PullRequest
0 голосов
/ 03 мая 2019

наша игра не запустится снова.Мы хотим, чтобы это началось снова, когда пользователь нажимает Y на конце экрана.Мы подозреваем, что это как-то связано с циклом while.Где наша ошибка?

Мы уже пытались поместить KeepGoing == False в начало цикла и перепробовали все логические значения для каждой переменной в цикле.

# Для выбора того, заканчивается игра или нет: keepGoing = True choice = False

clock = pygame.time.Clock()

screen.fill(GREEN)



# Set vars
font = pygame.font.SysFont("Comic Sans MS", 20)
done = False
display_end = True
end_page = 1

#Loop to keep the pages going:
while not done and display_end:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        if event.type == pygame.MOUSEBUTTONDOWN:
            end_page += 1               
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_y:
                choice = True
            if event.key == pygame.K_n:
                keepGoing = False



    pygame.display.flip()
    # Set the screen background
    screen.fill(GREEN)

    if end_page == 1:
        text = font.render("You lose :( Score: "+str(score)+" points", True, BLACK)
        text2 = font.render("Do you want to play again?", True, BLACK)
        text3 = font.render("If no, click once. If yes, press Y.", True, BLACK)
        screen.blit(text, [125, 150])
        screen.blit(text2, [125, 250])
        screen.blit(text3, [125, 350])





pygame.display.flip()
return done
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...