예제 #1
0
    def loadAttributes(self, tyles, data):
        graphs = {}
        for tyle in tyles:
            name = tyle.data['name']
            if not name in graphs:
                graphs[name] = graph.Graph()
            (x, y, w, h) = tyle.rect()
            p0 = (x, y)
            p1 = (x + w, y)
            p2 = (x + w, y + h)
            p3 = (x, y + h)
            graphs[name].addEdge(p0, p1)
            graphs[name].addEdge(p1, p2)
            graphs[name].addEdge(p2, p3)
            graphs[name].addEdge(p3, p0)

        for key in graphs.keys():
            info = {}
            info = data[key]
            g = graphs[key]

            cs = g.getCicles()
            for poly in cs:
                block = GameObject.GameObject(self.world)
                block.collider = Collider.PolygonCollider(
                    block, 0, 0, self.toVector2(poly))
                self.world.AddObject(block)
                if 'static' in info.keys():
                    block.collider.static = info['static']
                if 'trigger' in info.keys():
                    block.collider.isTrigger = info['trigger']
                if 'light' in info.keys():
                    light = block.addComponent(LightSource.SpotLight)
                    if 'intensity' in info.keys():
                        light.intensity = int(info['intensity'])
                    if 'radius' in info.keys():
                        light.radius = int(info['radius'])
예제 #2
0
 def __init__(self):
     self.scene = None
     gameobject = GameObject()
     self.go_to(TitleScene(gameobject))