Exemple #1
0
 def __init__(self, children=[], **kwargs):
     CadInterface.__init__(self, **kwargs)
     self._children = list(
         filter(None, chain(*[list(self.factory(**x)) for x in children])))
     Point.__init__(self, self.centroid)
     _layer = self.layer
     for x in self.children:
         x.layer = _layer
 def __init__(self, lon, lat, lvl, id=-1):
     Point.__init__(self, lon, lat, lvl)
     self.lon = self.x
     self.lat = self.y
     try:
         self.lvl = self.z
     except Exception:
         self.lvl = None
     self.id = id
Exemple #3
0
 def __init__(self, *args, **kwargs):
     self._direction = 0
     self._length = 0
     if isinstance(args[0], list):
         #
         coord, r = self.to_xg(*args)
     else:
         if len(args) == 4:  # [x, y, z, r]
             coord = args[0:3]
             self._length = args[3]  # Radius
         elif len(args) == 3:
             coord = args
         else:
             coord = args
     Point.__init__(self, *coord)
     CadInterface.__init__(self, **kwargs)
     self._opts = kwargs
     self._d = None
     if kwargs.get('use_syms', None) is True:
         self._children = list([self.factory(**x) for x in self._children])
Exemple #4
0
  def __init__(self, char, center, cells):
    pygame.sprite.Sprite.__init__(self)
    Point.__init__(self, center)
    self.mobility = 1
    # This is the unique name/address of the phone.
    self.id = char

    # These are all of the PCS cells in which this phone can be within.
    self.cells = cells

    # This is the geographic cell in which the phone is within. The center of
    #  this cell has a base station with which this phone can connect with
    #  to make calls, register its location, etc.
    self.num_writes = 0
    self.num_reads = 0
    self.PCS_cell = None
    for h in self.cells:
      if h.contains(self):
        self.PCS_cell = h

    # These member variables are required for this Phone class to be a
    #  sprite.
    self.image = pygame.image.load(
      os.path.join(ABS_PATH, "phone.png")
    ).convert_alpha()
    self.rect = self.image.get_rect()
    self.rect.center = transform_points_for_pygame([center])[0]

    # If the phone is moved, the offset vector will be updated. It is a
    #  direction vector.
    self.offset = (0,0)

    # The label is drawn on top of the sprite.
    label_font = pygame.font.SysFont("monospace", 15)
    self.label = label_font.render(char, True, (255, 255, 255))
    self.draw_text()