def enemy_shoot(self): self.shooting_chance = 1400 for enemy in self.enemies: # Have a random chance of shooting each frame if random.randrange(self.shooting_chance) == 0: self.enemy_bullet = EnemyBullet(enemy.rect.centerx, enemy.rect.bottom, 10, RED) self.all_sprites.add(self.enemy_bullet) self.enemy_bullets.add(self.enemy_bullet)
def enemyshoot(self, enemybullet_image): new_enemybullet = EnemyBullet( enemybullet_image, self.xcor + self.width / 2 - enemybullet_image.get_width() / 2, self.ycor) self.enemybullets_fired.append(new_enemybullet) def change_direction(self): self.direction *= -1
def fire(self): #随机产生子弹,避免一直2连续产生子弹,重叠子啊一起 randomNum = randint(1,100) if randomNum == 25 or randomNum == 75: self.bulletList.append(EnemyBullet(self.x+26,self.y+47,self.screen))
def fire(self): des = self.player.x, self.player.y self.shoot_time = 0 enemy_bullet = EnemyBullet(self.pos, des) gfw.world.add(gfw.layer.enemy_bullet, enemy_bullet)
def fire_enemybullet(alien, setting, screen, bulletss): if len(bulletss) < setting.enemy_bullets_allowed: new_enemy_bullets = EnemyBullet(setting, alien, screen) bulletss.add(new_enemy_bullets)
def enemyshoot(self, enemybullet_image): new_enemybullet = EnemyBullet( enemybullet_image, self.xcor + self.width / 10 - enemybullet_image.get_width() / 20, self.ycor) self.enemybullets_fired.append(new_enemybullet)