Таким образом, мое отображение паузы продолжает возвращаться после того, как я нажимаю кнопку, которая продолжает все.
Это включено в код: def paused(): global pause clock = pygame.time.Clock()
while pause:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
screen.fill(0)
screen.blit(intropic, (0, 0))
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
# print(mouse)
if 270 + 120 > mouse[0] > 270 and 590 + 50 > mouse[1] > 590:
pygame.draw.rect(screen, (0, 0, 0), (268, 588, 124, 54))
pygame.draw.rect(screen, (0, 255, 0), (270, 590, 120, 50))
if click[0] == 1:
pause = False
else:
pygame.draw.rect(screen, (0, 0, 0), (268, 588, 124, 54))
pygame.draw.rect(screen, (100, 255, 100), (270, 590, 120, 50))
if 770 + 150 > mouse[0] > 770 and 590 + 50 > mouse[1] > 590:
pygame.draw.rect(screen, (0, 0, 0), (768, 588, 154, 54))
pygame.draw.rect(screen, (255, 0, 0), (770, 590, 150, 50))
if click[0] == 1:
pygame.quit()
exit()
else:
pygame.draw.rect(screen, (0, 0, 0), (768, 588, 154, 54))
pygame.draw.rect(screen, (255, 100, 100), (770, 590, 150, 50))
healthfont = pygame.font.Font(None, 40)
start = healthfont.render("Weiter", True, (0, 0, 0))
textRect1 = start.get_rect()
textRect1.topright = [370, 603]
screen.blit(start, textRect1)
healthfont = pygame.font.Font(None, 40)
end = healthfont.render("Beenden", True, (0, 0, 0))
textRect1 = end.get_rect()
textRect1.topright = [900, 603]
screen.blit(end, textRect1)
pausefont = pygame.font.Font(None, 80)
pausetxt = pausefont.render("Pause", True, (0, 0, 0))
textRect1 = pausetxt.get_rect()
textRect1.center = [800, 300]
screen.blit(pausetxt, textRect1)
pygame.display.flip()
Это код, если вы нажмете P:
if keys[4]:
pause = True
paused()
Также есть глобальная пауза = False
Любая помощь высоко ценится
butt_rect = pygame.Rect( 768, 588, 154, 54 )
для хранения этих прямоугольников, тогда вы можете использоватьbutt_rect.collidepoint( pygame.mouse.get_pos() )
. Это убережет ваш основной цикл от перенасыщения числами. - person Kingsley   schedule 27.11.2020