def update(self, dt): super().update(dt) self.direc = self.angle_to(self.player) if self.pos.distance_to(self.player.rect.center) < 300: self.vel = vectool.from_angle(self.direc + (self.orbit * 90)) * self.speed else: self.vel = vectool.from_angle(self.direc + (self.orbit * 45)) * self.speed self.pos += self.vel self.rotate_img() if self.checkShoot(): self.shoot()
def __init__(self, game, pos, direc=0, speed=7): pygame.sprite.Sprite.__init__(self, game.all_sprites, game.bullet_sprites) self.game = game self.pos = Vector2(pos) self.direc = direc self.speed = speed self.rotate_img() self.vel = vectool.from_angle(self.direc) * self.speed
def __init__(self, game, center, img): pygame.sprite.Sprite.__init__(self, game.all_sprites, game.collect_sprites) self.game = game self.pos = Vector2(center) self.direc = randint(0, 359) self.vel = vectool.from_angle(self.direc) * randint(2, 5) self.image = img self.image = pygame.transform.rotate(self.image, self.direc) self.rect = self.image.get_rect() self.rect.center = self.pos
def __init__(self, game): super().__init__(game) self.pos = self.spawnPos() self.direc = 0 self.img = self.game.img["tankbase-red.png"] self.rotate_img() self.speed = 1 self.vel = vectool.from_angle(self.direc) * self.speed self.health = 5 self.turret = EnemyTurret(self.game, self) self.shoot_speed = 0.5 self.size = 8
def __init__(self, game): super().__init__(game) self.pos = self.spawnPos() self.direc = self.angle_to(self.player) self.img = self.game.img["red_01.png"] self.rotate_img() self.speed = 2 self.orbit = 1 if random() < 0.5 else -1 self.vel = vectool.from_angle(self.direc + (self.orbit * 90)) * self.speed self.health = 2 self.shoot_speed = 0.25 self.size = 4
def update(self, dt=None): self.direc = vectool.angle_to(self, self.target) self.rotate_img() self.turret_end = self.rect.center + (vectool.from_angle(self.direc) * 26)
def direc_vec(self): return vectool.from_angle(self.direc)