Ejemplo n.º 1
0
    def place_puck(self, x, y, vx=False, vy=False):
        table = self.get_table()

        p = Puck("candidate", x, y)
        if not self.can_place(p):
            print "ERROR: manually setting puck, overlapping pucks"
            return

        p.set_vx(vx)
        p.set_vy(vy)
        p.set_name(table.num_pucks() + 1)
        table.set_puck(p)
Ejemplo n.º 2
0
    def spawn_puck(self, velocity=False):
        table = self.get_table()

        candidate_x = random.random() * table.get_width()
        candidate_y = random.random() * table.get_height()

        p = Puck("candidate", candidate_x, candidate_y)
        while not self.can_place(p):
            candidate_x = random.random() * table.get_width()
            candidate_y = random.random() * table.get_height()

            p = Puck("candidate", candidate_x, candidate_y)
        if velocity:
            # -0.5 so that there's a chance they have a negative velocity
            p.set_velocity(Velocity(random.random() - 0.5, random.random() - 0.5))

        p.set_name(table.num_pucks() + 1)
        table.set_puck(p)