0
所以我想要做的是有一套方法,我可以添加諸如字符的對象,使它移動並在同一個窗口上顯示一些文本。這是我的函數調用python(pygames)
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()
這裏它只是顯示字符,沒有文字,但我不明白爲什麼。我試圖將它們添加到數組中並將它們顯示爲這樣。但無濟於事。有任何想法嗎?
afaik你正在創建一個新的屏幕,每次調用...你可能想調用'myscreen = screen(width,height)',然後重用該屏幕....但我不知道 –
Duplicate:http:/ /stackoverflow.com/questions/19406467/calling-functions-python-pygame –
不是真的,我有一個不同的問題,沒有任何顯示 –