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

问题描述 投票:1回答:1

我正在开发一款名为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测试增加绘制块的能力,但它崩溃了,没有任何错误迹象。

python python-3.x 3d raycasting
1个回答
0
投票

NeverMind,我意识到我必须使用

if

elif

而不是while循环,对不起Stack OverFlow社区的混乱。 :(

© www.soinside.com 2019 - 2024. All rights reserved.