PyGame 琐事游戏

时间:2021-05-27 19:22:16

标签: python pygame

我正在尝试使用 PyGame 制作一个琐事游戏。我是初学者,我不知道如何在屏幕上输入答案。有人知道怎么做吗?

import pygame 

pygame.init()
sw = 700
sh = 700
white = [255,255,255]
screen = pygame.display.set_mode((sw, sh))
pygame.display.set_caption("Caca de vaca")
screen.fill(white)
pygame.display.update() 

def set_text(string, coordx, coordy, fontSize):
    font = pygame.font.Font("freesansbold.ttf", fontSize)
    text = font.render(string, True, (0,0,0))
    textRect = text.get_rect()
    textRect.center = (coordx, coordy)
    return(text, textRect)

ans = totalText = set_text("Do you wanna play? (yes/no)", 150,50,20)
screen.blit(totalText[0], totalText[1])
totalText = set_text("Input", 40,100,20)
input(totalText)
screen.blit(totalText[0], totalText[1])

pygame.display.update()

run = True

while run:
    pygame.time.delay(100)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

pygame.display.update()

0 个答案:

没有答案
相关问题