Добрый день, я хотел бы задать вопрос об этой ошибке, которую я получаю в своей игре. Я делаю простую игру в pygame, но я не могу понять, почему у меня такая ошибка. я буду печатать соответствующий код:Пиксельный индекс за пределами допустимого диапазона
bottomX=-1000
bottomY=300
FishList = []
NumFish=0
while NumFish<20:
xfish=random.randrange(5,2550)
yfish=random.randrange(20,150)
IsInWater=(bottom.get_at([xFish+5,yFish+7])== (80,86,210,255))
if IsInWater:
FishList.append([xFish,yFish])
NumFish= NumFish + 1
for i in range(len(FishList)):
[xFish,yFish] = FishList[i]
mXp = random.randrange(-5,5) #Move in X
mYp = random.randrange(-5,6) #Move in y
FishStillInWater = (xFish+mXp+5>0 and xFish+mXp+5<3000 and yFish+mYp+7>10 and yFish+mYp+7 < 200 and (fundo.get_at([xFish+mXp+5,yFish+mYp+7])== (80,86,210,255)))
if FishStillInWater:
# If in water, moves
FishList[i][0] = xFish + mXp
FishList[i][1] = yGish + mYp
pygame.draw.rect(screen,red,[bottomX + FishList[i][0],300 + FishList[i][1],15,10],0)
for x in range(-7,7):
for y in range(-5,5):
FishDies=screen.get_at([bottomX + FishList[i][0]+x,300 + FishList[i][1]+y])==(0,0,0,255)# 0,0,0,255 is the color of the "bullets"
if FishDies:
yFish = 10000
points= points + 5
Ошибка является:
FishDies = screen.get_at ([bottomX + FishList [I] [0] + X, 300 + FishList [ i] [1] + y]) == (0,0,0,255) IndexError: индекс пикселя за пределами допустимого диапазона
Thx для вашего времени, ребята, надеюсь, что вы можете мне помочь, если вам нужно что-то еще, чтобы понять код скажите мне plz
Если вы добавили 'print [bottomX + FishList [i] [0] + x, 300 + FishList [i] [1] + y]' чуть выше строки, вызывающей ошибку, вы можете получить некоторые понять, почему это происходит. – Marius