|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我按照教程改了代码,为什么还是敌机一被消灭,消灭的音效还是循环播放啊?
# 绘制大飞机
for each in big_enemies:
if each.active:
each.move()
if switch_image:
screen.blit(each.image1, each.rect)
else:
screen.blit(each.image2, each.rect)
# 当大飞机进入画面时播放音效
if each.rect.bottom == -50:
enemy3_fly_sound.play(-1)
else: # 毁灭
if not(delay % 5):
if e3_destroy_index == 0:
enemy3_down_sound.play()
screen.blit(each.destroy_images[e3_destroy_index],each.rect)
e3_destroy_index = (e3_destroy_index + 1) % 6
if e3_destroy_index == 0:
enemy3_fly_sound.stop()
each.reset()
# 绘制中飞机
for each in mid_enemies:
if each.active:
each.move()
screen.blit(each.image, each.rect)
else: # 毁灭
if not(delay % 5):
if e2_destroy_index == 0:
enemy2_down_sound.play()
screen.blit(each.destroy_images[e2_destroy_index], each.rect)
e2_destroy_index = (e2_destroy_index + 1) % 4
if e2_destroy_index == 0:
each.reset()
# 绘制小飞机
for each in small_enemies:
if each.active:
each.move()
screen.blit(each.image, each.rect)
else:# 毁灭
if not(delay % 5):
if e1_destroy_index == 0:
enemy1_down_sound.play()
screen.blit(each.destroy_images[e1_destroy_index], each.rect)
e1_destroy_index = (e1_destroy_index + 1) % 4
if e1_destroy_index == 0:
each.reset() |
|