|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
打飞机代码中,我跟着甲鱼写代码,写到这无论如何都不对,求大佬指点一下
跟着小甲鱼写的这一段:
if not(delay % 8):
bullet_sound.play()
if is_double_bullet:
bullets = bullet2
bullets[bullet2_index].reset((me.rect.centerx - 33,me.rect.centery))
bullets[bullet2_index + 1].reset((me.rect.centerx + 30, me.rect.centery))
bullet2_index = (bullet2_index + 2) % BULLET2_NUM
else:
bullets = bullet1
bullets[bullet1_index].reset(me.rect.midtop)
bullet1_index = (bullet1_index + 1) % BULLET1_NUM
#检测子弹是否击中
for b in bullets:
if b.active:
b.move()
screen.blit(b.image,b.rect)
enemy_hit = pygame.sprite.spritecollide(b,enemies,False,pygame.sprite.collide_mask)
if enemy_hit:
b.active = False
for e in enemy_hit:
if e in mid_enemies or e in big_enemies:
e.hit = True
e.energy -= 1
if e.energy == 0:
e.active = False
else:
e.active = False
我对照了很多次,跟小甲鱼写的一模一样,但是就是报错UnboundLocalError: local variable 'bullets' referenced before assignment,求助到底出了什么问题 |
|