Код: Выделить всё
import pygame
import random
pygame.init()
ds = pygame.display.set_mode((800, 700))
myFont = pygame.font.SysFont("arial", 20, bold=False, italic=False)
titleFont = pygame.font.SysFont("arial", 30, bold=True, italic=False)
left_previous = False
startGame = False
timeDone = False
def drawStartMenu():
ds.fill((139, 212, 238))
pygame.draw.rect(ds, (46, 56, 21), (335, 405, 150, 35), 0)
pygame.draw.rect(ds, (187, 240, 53), (330, 400, 150, 35), 0)
startText = myFont.render("START", False, (222,222,222)) # Start text render
startText2 = myFont.render("START", False, (23, 23, 23)) # Start text render
ds.blit(startText2, (381, 406), area=None, special_flags=0) # Start text
ds.blit(startText, (382, 405), area=None, special_flags=0) # Start text
def drawBackground():
ds.fill((64, 142, 50))
def drawEndMenu():
drawBackground()
pygame.draw.rect(ds, (143, 171, 186), (150, 100, 500, 500), 0)
def drawTimer():
global startGame
if startGame == True:
sideClock = pygame.time.Clock()
sideClock.tick(60)
mainClock = pygame.time.get_ticks()
clockOutput = int((20 - (mainClock / 1000)))
clockText = titleFont.render(str(clockOutput), False, (255, 255, 255))
ds.blit(clockText, (750, 650), area=None, special_flags=0)
if clockOutput == 0:
global timeDone
timeDone = True
else:
pygame.time.wait(99999999999999999999999999999999999999999999999999)
drawStartMenu()
while True:
pygame.event.pump()
(left, mid, right) = pygame.mouse.get_pressed()
(mouseX, mouseY) = pygame.mouse.get_pos()
keys = pygame.key.get_pressed()
# Exit/Start Commands
if left == True and left_previous == False:
rgb_value = ds.get_at((mouseX, mouseY))
if rgb_value == (187, 240, 53) or rgb_value == (222,222,222):
startGame = True
if startGame == True:
drawBackground()
drawTimer()
if timeDone == True:
drawEndMenu()
pygame.display.update()
left_previous = left
Подробнее здесь: https://stackoverflow.com/questions/790 ... g-until-it