def __init__(self, pos=None, angle=None): """ create a tank in a specified point on the screen """ if not pos: pos = random_point(self.radius) GameObject.__init__(self, pos, angle=angle) self.gun = Gun(self) self._armor = float(tank_max_armor) self.explosion = None self._events.put(EventBorn())
def follow_target(self, with_move=True): if self.is_near_target(): self.debug("near_target - turned to %s" % self.target) self.turn_to(self.target) self.fire() self.state = 'hunt' elif with_move: if self.target: self.debug("target far away - move to") self.move_at(self.target) self.state = 'folow_target' else: self.debug("no target - random") self.state = 'search' self.move_at(random_point()) else: self.debug("target far away and no move - dancing") self.turn_to(self.course + 90) self.state = 'search'
def to_search(self): self.state = 'search' self.target = None self.move_at(random_point())
def collided_with(self, obj): self.debug("collided_with %s", obj.id) self.move_at(random_point())
def stopped(self): self.debug("stopped") self.move_at(random_point())
def born(self): self.move_at(random_point())