Beispiel #1
0
    def update(self):
        cars = self.frame.get(Vehicle)
        for c in cars:
            if self.step % 5:
                px = (c.Velocity.X * math.cos(self.rotation) -
                      c.Velocity.Y * math.sin(self.rotation))
                py = (c.Velocity.X * math.sin(self.rotation) +
                      c.Velocity.Y * math.cos(self.rotation))
                c.Velocity = Vector3(px, py, c.Velocity.Z)
            c.Position += c.Velocity * self.timestep

        if self.step % 40 == 0:
            # First route: from a random place to another random place
            v = Vehicle()
            v.Position = Vector3(500, 500, 25.5)
            v.Velocity = Vector3(10, 10, 0)
            v.Name = "[testcar] Car %s" % self.step
            v.Lenght = 5
            v.Width = 2
            self.frame.add(v)
            self.todelete.append(v.ID)

        if len(self.todelete) > 360 / self.rotating_degree:
            car = self.frame.get(Vehicle, self.todelete[0])
            self.frame.delete(Vehicle, car)
            del self.todelete[0]

        self.step += 1
Beispiel #2
0
 def initialize(self):
     logger.debug("%s Initializing", LOG_HEADER)
     self.frame.add(Vehicle())
Beispiel #3
0
 def initialize(self):
     logger.debug("%s Initializing", LOG_HEADER)
     for i in xrange(1):
         self.frame.add(Vehicle())