여기서 뭐가 잘못된거예요...?

조회수 51회
import pygame.locals
import gameCode.player_ant
import gameCode.soil
pygame.init()
display = pygame.display.set_mode((1280, 720))
displaySurface = pygame.Surface(display.get_size())
clock = pygame.time.Clock()
setPlayerX = 0
setPlayerY = 10
esc = True
playerFlipX = False
playerFlipY = False
mousePosX = 0
mousePosY = 0
soilPosGroupX = list()
soilPosGroupY = list()
soilTag = 0
soilGroup = list()
soilGroupLen = len(soilGroup)
print(soilGroupLen)
pointed = True
checkSoil = 0
soilMouse_betweenX = list()
soilMouse_betweenY = list()
soilMouse_betweenX_abs = list()
soilMouse_betweenY_abs = list()
soilMouse_betweenX_min = 0
soilMouse_betweenY_min = 0
soilMouse_betweenX_min_num = 0
soilMouse_betweenY_min_num = 0
soilMouse_betweenX_Last_min = 0
soilMouse_between_min_pos_soilX = 0
soilMouse_between_min_pos_soilY = 0
def sign(number):
    if number > 0:
        boolReturn = True
    elif number < 0:
        boolReturn = False
    elif number == 0:
        boolReturn = None
    return boolReturn
while esc:
    pygame.display.init()
    display.fill((255, 255, 255))
    mouseClick1, mouseClick2, mouseClick3 = pygame.mouse.get_pressed()
    mousePosX, mousePosY = pygame.mouse.get_pos()
    if soilGroupLen > 0:
        for checkSoil in range(soilGroupLen):
            soilPosGroupX_out = soilPosGroupX[checkSoil]
            soilPosGroupY_out = soilPosGroupY[checkSoil]
            soilMouse_betweenX[checkSoil] = mousePosX - soilPosGroupX_out
            soilMouse_betweenY[checkSoil] = mousePosY - soilPosGroupY_out
            soilMouse_betweenX_abs[checkSoil] = abs(soilMouse_betweenX[checkSoil])
            soilMouse_betweenY_abs[checkSoil] = abs(soilMouse_betweenX[checkSoil])
            if checkSoil == soilGroupLen:
                soilMouse_betweenX_min = min(soilMouse_betweenX_abs)
                soilMouse_betweenY_min = min(soilMouse_betweenY_abs)
                soilMouse_betweenX_min_num = soilMouse_betweenX_abs.index(soilMouse_betweenX_min)
                soilMouse_between_min_pos_soilX = soilMouse_betweenX_abs.index(soilMouse_betweenX_min)
                soilMouse_between_min_pos_soilY = soilMouse_betweenY_abs.index(soilMouse_betweenY_min)
                pointX_bool = sign(soilMouse_between_min_pos_soilX)
                pointY_bool = sign(soilMouse_between_min_pos_soilY)
                print(pointX_bool)
                print(pointY_bool)

    if mouseClick1 and soilGroupLen == 0:
        soilTag += 1
        soilPosXSet = mousePosX - 50
        soilPosYSet = mousePosY - 50
        soilPosGroupX.append(soilPosXSet)
        soilPosGroupY.append(soilPosYSet)
        exec("global soilObject%s" % (soilTag))
        exec("soilObject%s = pygame.image.load('image/soil.bmp')" % (soilTag))
        exec("soilGroup.append(soilObject%s)" % (soilTag))
    elif mouseClick1 and soilGroupLen > 0:
        soilTag += 1
        soilPosXSet = mousePosX - 50
        soilPosYSet = mousePosY - 50
        soilPosGroupX.append(soilPosXSet)
        soilPosGroupY.append(soilPosYSet)
        exec("global soilObject%s" % (soilTag))
        exec("soilObject%s = pygame.image.load('image/soil.bmp')" % (soilTag))
        exec("soilGroup.append(soilObject%s)" % (soilTag))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            esc = False
    playerObject = gameCode.player_ant.Player(0, playerFlipX, playerFlipY)
    playerX, playerFlipX = playerObject.event()
    setPlayerX += playerX
    display.blit(playerObject.loadImage, (setPlayerX, setPlayerY))
    playerRender = pygame.sprite.RenderPlain(playerObject)
    playerObject.update()
    loopSoilBlit = 0
    soilGroupLen = len(soilGroup)
    if soilGroupLen > 0:
        for loopSoilBlit in range(soilGroupLen):
            soilGroup_out = soilGroup[loopSoilBlit]
            soilPosGroupX_out = soilPosGroupX[loopSoilBlit]
            soilPosGroupY_out = soilPosGroupY[loopSoilBlit]
            display.blit(soilGroup_out, (soilPosGroupX_out, soilPosGroupY_out))
    else:
        pass

    pygame.display.flip()
    pygame.display.update()
    clock.tick(60)
pygame.quit()

여기

soilPosGroupX_out = soilPosGroupX[checkSoil]
 soilMouse_betweenX[checkSoil] = mousePosX - soilPosGroupX_out

IndexError: list assignment index out of range 라고 에러가 났네요... 뭐가 잘못된 거죠?

1 답변

답변을 하려면 로그인이 필요합니다.

Hashcode는 개발자들을 위한 무료 QnA 사이트입니다. 계정을 생성하셔야만 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)

ᕕ( ᐛ )ᕗ
로그인이 필요합니다

Hashcode는 개발자들을 위한 무료 QnA사이트 입니다. 계정을 생성하셔야만 글을 작성하실 수 있습니다.