Вам нужно увеличить счетчик button
, когда пользователь нажимает кнопку мыши.
Функция drawIntro
должна вызываться не в цикле событий один раз для события pygame.MOUSEMOTION
, а в основном цикле while
.Кроме того, измените MOUSEMOTION
на MOUSEBUTTONDOWN
, чтобы увеличить button
один раз за клик.
Условия в функции drawIntro
неверны.
import pygame
pygame.init()
SIZE = (1000, 700)
screen = pygame.display.set_mode(SIZE)
clock = pygame.time.Clock()
button = 0
fontIntro = pygame.font.SysFont("Times New Roman",30)
def drawIntro(screen):
#start
if button == 0: # == 0
screen.fill((0, 0, 0))
text = fontIntro.render("Sigle click to start", 1, (255,255,255))
screen.blit(text, (300, 300, 500, 500))
elif button == 1: #page1
screen.fill((0, 0, 0))
text = fontIntro.render("page 1", True, (255, 255, 255))
screen.blit(text, (300,220,500,200))
elif button == 2: #page2
screen.fill((0, 0, 0))
text = fontIntro.render("page 2", True, (255, 255, 255))
screen.blit(text, (300,220,500,200))
elif button == 3: #page3
screen.fill((0, 0, 0))
text = fontIntro.render("page3", True, (255, 255, 255))
screen.blit(text, (200,190,500,200))
running = True
while running:
for evnt in pygame.event.get():
if evnt.type == pygame.QUIT:
running = False
if evnt.type == pygame.MOUSEBUTTONDOWN: # Once per click.
button += 1
drawIntro(screen)
pygame.display.flip()
pygame.quit()