arrows=[]
badtimer=100
badtimer1=0
badguys=[[640,100]]
healthvalue=196
index=1
for badguy in badguys:
if badguy[0]<-64:
badguys.pop(index)
badguy[0]-=7
index+=1
for badguy in badguys:
screen.blit(badguyimg, badguy)
# 6.3.1 - Attack castle
badrect=pygame.Rect(badguyimg.get_rect())
badrect.top=badguy[1]
badrect.left=badguy[0]
if badrect.left<64:
healthvalue -= random.randint(5,20)
badguys.pop(index)
:はIndexError:私にエラーを与える範囲外のポップ指数(パイソン)3
Traceback (most recent call last):
File "C:\Users\Thinkpad\Desktop\BB_Resources\game.py", line 80, in <module>
badguys.pop(index)
IndexError: pop index out of range
最初のループは 'len(badguys)'まで 'index'を増やして、2番目のループでこの変数を再利用しています... –