Beispiel #1
0
 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())
Beispiel #2
0
 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'
Beispiel #3
0
 def to_search(self):
     self.state = 'search'
     self.target = None
     self.move_at(random_point())
Beispiel #4
0
 def collided_with(self, obj):
     self.debug("collided_with %s", obj.id)
     self.move_at(random_point())
Beispiel #5
0
 def stopped(self):
     self.debug("stopped")
     self.move_at(random_point())
Beispiel #6
0
 def born(self):
     self.move_at(random_point())