添加 '游戏结束3'
This commit is contained in:
parent
fdccf242bf
commit
c7d0dbb99a
|
@ -0,0 +1,36 @@
|
|||
class GameSta():
|
||||
def __init__(self,ai_settings):
|
||||
self.ai_settings=ai_settings
|
||||
self.reset_sta()
|
||||
self.game_active=True
|
||||
def reset_sta(self):
|
||||
self.ship_counts=self.ai_settings.ship_limit
|
||||
self.ship_limit=3
|
||||
from game_sta import GameSta
|
||||
sta=GameSta(ai_settings)
|
||||
gf.update_aliens(ai_settings,aliens,screen,ship,bullets,sta)
|
||||
|
||||
|
||||
def ship_col(ai_settings, aliens, screen, ship, bullets, sta):
|
||||
if sta.ship_counts > 0:
|
||||
sta.ship_counts -= 1
|
||||
aliens.empty()
|
||||
bullets.empty()
|
||||
creat_aliens(ai_settings, screen, aliens, ship)
|
||||
ship.ship_center()
|
||||
sleep(1)
|
||||
else:
|
||||
sta.game_active = False
|
||||
def check_aliens_bottom(ai_settings, aliens, screen, ship, bullets, sta):
|
||||
for alien in aliens.sprites():
|
||||
if alien.rect.bottom >= screen.get_rect().bottom:
|
||||
ship_col(ai_settings, aliens, screen, ship, bullets, sta)
|
||||
break
|
||||
def update_aliens(ai_settings, aliens, screen, ship, bullets, sta):
|
||||
check_aliens_edge(ai_settings, aliens)
|
||||
aliens.update()
|
||||
if pygame.sprite.spritecollideany(ship, aliens):
|
||||
ship_col(ai_settings, aliens, screen, ship, bullets, sta)
|
||||
check_aliens_bottom(ai_settings, aliens, screen, ship, bullets, sta)
|
||||
def ship_center(self):
|
||||
self.center = self.screen_rect.centerx
|
Loading…
Reference in New Issue