gpt4 book ai didi

python - 为什么我的解析器无法在不崩溃的情况下将 Sprite 绘制到屏幕上?

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:32 26 4
gpt4 key购买 nike

我正在使用光线转换开发一款名为 HypoPixel 的游戏,但我发现了另一个错误。我无法打开游戏,它只是崩溃了,当我在 IDE 中使用它时,它不会给出错误。

我只是用了简单的

elif event.type == pygame.MOUSEBUTTONDOWN:

程序,但自从我添加这个之后它就一直崩溃

pygame.init()

Screen = "None"

Sobj = "None"

Width = 800

Height = 600

Time = 0

MouseX, MouseY = pygame.mouse.get_pos()

Frame = pygame.display.set_mode((Width,Height))

pygame.display.set_caption("HypoPixel")

FPS = pygame.time.Clock()

def button(DisplayText,ButtonPosition,Function):
pass
def mapX(MapXPos):
pass
def mapY(MapYPos):
pass
def mapZ(MapZPos):
pass

def ReDisplayItem():
if Sobj == "None":
Raycast('Assets/Textures/Extra/ItemBox.png',0,0,160,160)
elif Sobj == "Loom":
Raycast('Assets/Textures/Extra/IBO.png',0,0,160,160)
Raycast('Assets/Textures/Blocks/loom_side.png',10,10,140,140)

def Raycast(TTR, RayXPos, RayYPos, RaySizeX, RaySizeY):
RaycastThis = pygame.image.load(TTR)
RaycastThis = pygame.transform.scale(RaycastThis,(RaySizeX,RaySizeY))
Frame.blit(RaycastThis, (RayXPos, RayYPos))
Loop = True
Raycast('Assets/Textures/Screens/Skybox/Earth.png',0,0,800,600)
Raycast('Assets/Textures/Extra/ItemBox.png',0,0,160,160)
while Loop == True:
Time = Time + 1
while Sobj == "None":
RCT = 'Assets/Textures/Blocks/air.png'
while Sobj == "Loom":
RCT = 'Assets/Textures/Blocks/loom_side.png'
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
Raycast(RCT,MouseX,MouseY,160,160)
elif event.type == pygame.KEYDOWN:
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
exit()
elif event.type == pygame.KEYDOWN and event.key == pygame.K_0:
Raycast('Assets/Textures/Extra/ItemBox.png',0,0,160,160)
Sobj = "None"
elif event.type == pygame.KEYDOWN and event.key == pygame.K_1:
Raycast('Assets/Textures/Blocks/loom_side.png',10,10,140,140)
Sobj = "Loom"
if Time >= 2400 and Time < 4800:
Raycast('Assets/Textures/Screens/Skybox/EarthNight.png',0,0,800,600)
ReDisplayItem()
elif Time >= 4800:
Time = 0
Raycast('Assets/Textures/Screens/Skybox/Earth.png',0,0,800,600)
ReDisplayItem()
pygame.display.update()

FPS.tick(60)

我希望应用程序能够像平常一样打开,并为我的游戏的 Alpha 测试添加新的绘制 block 的功能,但它崩溃了,没有任何错误迹象。

最佳答案

没关系,我意识到我必须使用

if

elif

而不是 while 循环,对于困惑的 Stack OverFlow 社区表示歉意。 :(

关于python - 为什么我的解析器无法在不崩溃的情况下将 Sprite 绘制到屏幕上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54412494/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com