所以我想做的是有一组方法,我可以在其中添加诸如字符之类的对象,使其移动并在同一个窗口上显示一些文本。这就是我所拥有的
import pygame,sys
from pygame.locals import *
def get_font():
game_font = pygame.font.Font(None,30)
def screen(width,height,name):
pygame.init()
pygame.font.init()
screen=pygame.display.set_mode((width,height))
pygame.display.update()
return window
def name(name="", array=[]):
pygame.init()
pygame.font.init()
myfont = pygame.font.SysFont(None, 15)
label = myfont.render(name, 1, (255,255,0))
result=screen(640,480,name).blit(label, (100, 100))
array.append(name)
pygame.display.update()
return name
def drawCharacter(array=[]):
initialise()
character = pygame.image.load("resources/images/character.png")
drawcharacter = window(640,480,character).blit(character, (100, 400))
array.append(character)
pygame.display.update()
return drawcharacter
name("akunama tata pig")
drawCharacter()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit(0)
pygame.display.update()
这里只是显示字符,没有文字,但我不明白为什么。我尝试将它们添加到数组中并像那样显示它们。但无济于事。有任何想法吗?