我正在使用光线投射制作一个名为HypoPixel的游戏,我发现了另一个bug。我无法打开游戏,它只是崩溃,当我在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测试绘制块,但它崩溃了,没有任何错误的迹象
不管怎样,我意识到我必须使用
以及
不是while循环,而是为混乱堆栈溢出社区感到抱歉。(
相关问题 更多 >
编程相关推荐