存储项目的大部分函数
This commit is contained in:
parent
34290da585
commit
a78670aef5
|
@ -26,4 +26,23 @@ def fire_bullet(ai_settings, screen, ship, bullets):
|
|||
# 增加:添加发射音效
|
||||
pygame.mixer.init()
|
||||
sound = pygame.mixer.Sound('sounds/firebullets.wav')
|
||||
sound.play()
|
||||
sound.play()
|
||||
def bossalien_fire_bullet(ai_settings, screen, bossalien, bossbullet, ship):
|
||||
"""增加:BOSS发射子弹"""
|
||||
# 创建一颗子弹
|
||||
bossbullet = BossBullet(ai_settings, screen, bossalien)
|
||||
def check_bossbullet_bottom(ai_settings, screen, stats, sb, ship, aliens, bossalien, bullets, bossbullet):
|
||||
"""当子弹飞出屏幕底部时,重置BOSS子弹位置"""
|
||||
screen_rect = screen.get_rect()
|
||||
if bossbullet.y >= screen_rect.bottom:
|
||||
bossbullet.reset_position(bossalien)
|
||||
def check_keyup_events(event, ship):
|
||||
"""响应松开"""
|
||||
if event.key == pygame.K_RIGHT:
|
||||
ship.moving_right = False
|
||||
elif event.key == pygame.K_LEFT:
|
||||
ship.moving_left = False
|
||||
elif event.key == pygame.K_UP:
|
||||
ship.moving_up = False
|
||||
elif event.key == pygame.K_DOWN:
|
||||
ship.moving_down = False
|
Loading…
Reference in New Issue