Exemplo n.º 1
0
    def __init__(self, level_model):
        super(LevelActor, self).__init__(level_model)
        self.color = 0, 0, 0, 1
        self.background_color = 1, 1, 1, 1
        aabb = b2.b2AABB()
        aabb.lowerBound = level_model.lower_bound
        aabb.upperBound = level_model.upper_bound
        self.world = b2.b2World(aabb, level_model.gravity, True)
        self.start = level_model.start
        self.goal = level_model.goal
        self.extra_joint_actors = []
        self.key_names = {
            pyglet.window.key.DOWN: "down",
            pyglet.window.key.LEFT: "left",
            pyglet.window.key.RIGHT: "right",
            pyglet.window.key.SPACE: "space",
        }
        self.key_press_bindings = {}
        self.key_release_bindings = {}
        self.z = 1

        for body_model in level_model.body_models:
            BodyActor(self, body_model)
        for joint_model in level_model.joint_models:
            self.create_joint(joint_model)

        self.circle_line_loop_display_list = CircleDisplayList()
        self.circle_polygon_display_list = CircleDisplayList(mode=GL_POLYGON)
        self.display_lists = {}
        self.camera = 0, 0
Exemplo n.º 2
0
 def init_world(self):
     aabb = b2.b2AABB()
     aabb.lowerBound = -100, -10
     aabb.upperBound = 100, 100
     self.world = b2.b2World(aabb, (0, -config.gravity), True)