for bullent in self.bullets:
# 判断子弹是否超出上边界
if bullent.y > -31: # 没有出边界
bullent.display()
bullent.move()
else: #飞出边界
deleted_bullets.append(bullent)
for enemy in enemy_list:
if bullent.is_hit_enemy(enemy): #判断是否击中敌机
enemy.is_hited = True
deleted_bullets.append(bullent)
global score
score += 10
break
for out_window_bullet in deleted_bullets:
self.bullets.remove(out_window_bullet)
def move_left(self): # 往左飞
if self.x >= 0 and not self.is_hited:
self.x -= 5
def move_right(self): # 往右飞
if self.x <= WINDOW_WIDTH- 120 and not self.is_hited:
self.x += 5
def move_up(self): # 往上飞
if self.y >= 0 and not self.is_hited:
self.y -= 5
def move_down(self): # 往下飞
if self.y <= WINDOW_HEIGHT - 78 and not self.is_hited:
self.y += 5