Beispiel #1
0
 def __init__(self,
              position=[0, 1],
              velocity=[0, 0],
              acceleration=[0, -0.1],
              friction=0.5,
              size=[1, 2],
              borders=None):
     Entity.__init__(self,
                     position=position,
                     velocity=velocity,
                     acceleration=acceleration,
                     friction=friction,
                     borders=borders)
     self.view = [15, 10]
     self.hitbox = self.size = size
 def __init__(self, n=10, s=5, g=10, radius_borns=[1, 10], **kwargs):
     super().__init__(**kwargs)
     # entities = [Entity(FormAnatomy.random(),
     #             [Motion(s * Vector.random(), 10 * Vector.random(), Vector(0, -g)),
     #              Moment(Vector.random(), 5*Vector.random())], friction=0)
     #             for i in range(n)]
     self.group = Group(*[Entity(CircleAnatomy.random(radius_borns=radius_borns), \
                         [Motion(s*Vector.random(), Vector(0,0), Vector(0, -g))], friction=0.1) \
                         for i in range(n)])
     self.collider = Collider(elasticity=0.9)
     self.born = s
     self.born_elasticity = 0.5
     self.square = Square(0, 0, 2 * self.born)
     self.correctMasses()
Beispiel #3
0
 def __init__(self,position,size,borders):
     """Create camera object using position, size and borders."""
     Entity.__init__(self,position=position,size=size,borders=borders)
     self.moving_function=moving2
 def random(cls, n=10, **kwargs):
     """Create n random entities."""
     entities = [Entity.random() for i in range(n)]
     return cls(*entities, **kwargs)
 def random(cls, n=5, np=3, nm=2, nv=2, dv=2):
     """Create a random entity group using the optional number of entities 'n'."""
     entities = [Entity.random(n=np, nm=nm, nv=nv, d=dv) for i in range(n)]
     entities = dict(zip(range(len(entities)), entities))
     return cls(entities)
 def __init__(self,position,size,borders,friction,controllable,color=WHITE):
     Entity.__init__(self,position=position,size=size,borders=borders,friction=friction,controllable=controllable)
     self.borders=borders
     self.color=color
     self.rectangles=[]
     self.moving_function=lambda x:100*sin(x/10)