Python Pygame def函数
我在pygame中定义了一些函数Python Pygame def函数,python,pygame,function,Python,Pygame,Function,我在pygame中定义了一些函数 import time import pygame, sys from pygame.locals import* def screen(a,b,z,v): screen = pygame.display.set_mode((a,b),z,v) def image1(a,x,y): b = pygame.image.load(a).convert() screen.blit(b,(x,y)) 我添加了一些代码: a = "white.j
import time
import pygame, sys
from pygame.locals import*
def screen(a,b,z,v):
screen = pygame.display.set_mode((a,b),z,v)
def image1(a,x,y):
b = pygame.image.load(a).convert()
screen.blit(b,(x,y))
我添加了一些代码:
a = "white.jpg"
screen(50,50,0,32)
然而,我没有像往常一样得到一扇窗户。为什么会这样?为了让问题更清楚,我得到的是:
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
它被卡在那里,无法加载,有时python提示符会自动关闭。有人能解释一下吗?
*编辑:
我在代码中定义了其他函数。似乎定义的函数太多了。如何停止错误?可能缺少其他位,但在执行其他操作之前,需要调用
pygame.init()
您可以在屏幕函数中添加该调用,或者在主代码中调用该调用之前:
def screen(a,b,z,v):
pygame.init()
screen = pygame.display.set_mode((a,b),z,v)
或
可能缺少其他位,但在执行任何其他操作之前,需要调用pygame.init()
您可以在屏幕函数中添加该调用,或者在主代码中调用该调用之前:
def screen(a,b,z,v):
pygame.init()
screen = pygame.display.set_mode((a,b),z,v)
或