示例#1
0
  def __init__(self):
    LivingThing.__init__(self)

    self.x = (random() * 2.0) - 1.0
    self.y = (random() * 2.0) - 1.0
    self.rotation = random() * 360.0
    
    self.sight_distance = 3.0
    self.show_fov = False
示例#2
0
 def __init__(self):
   LivingThing.__init__(self)
   self.x = (random() * 2.0) - 1
   self.y = (random() * 2.0) - 1
   size = random() * 0.02 + 0.02
   self.width = size
   self.height = size
   self.rotation = random() * 360.0
   
   # image
   self.svg = rsvg.Handle('resources/plant.svg')
   
   self.code = """\
示例#3
0
 def draw(self, context):
   LivingThing.draw(self, context)
   if self.show_fov: # draw field-of-view
     Ax = 0.0
     Ay = 0.0
     Bx = (self.sight_distance * math.cos(math.radians(-45.0)))
     By = -(self.sight_distance * math.sin(math.radians(-45.0)))
     Cx = (self.sight_distance * math.cos(math.radians(45.0)))
     Cy = -(self.sight_distance * math.sin(math.radians(45.0)))
     context.set_line_width(0.02)
     context.set_source_rgba(0.0, 1.0, 0.0, 0.9)
     context.move_to(Ax, Ay)
     context.line_to(Bx, By)
     context.line_to(Cx, Cy)
     context.line_to(Ax, Ay)
     context.line_to(self.sight_distance, 0.0)
     #context.rectangle(-0.5, -0.5, 1.0, 1.0)
     #context.fill()
     context.stroke()
示例#4
0
 def draw(self, context):
   LivingThing.draw(self, context)