Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyGame琐事游戏_Python_Pygame - Fatal编程技术网

Python PyGame琐事游戏

Python PyGame琐事游戏,python,pygame,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.displ

我正在尝试使用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()