Untitled
unknown
plain_text
a year ago
1.3 kB
2
Indexable
Never
class Mapmanager(): def __init__(self): self.model = 'block' self.texture = 'block.png' self.colors = [ (0.2, 0.2, 0.35, 1), (0.2, 0.2, 0.3, 1), (0.5, 0.5, 0.2, 1), (0.0, 0.6, 0.0, 1) ] self.startNew() self.addBlock((0, 10, 0)) def getColor(self, z): if z < len(self, colors): return self.colors[z] else: return self.colors[len(self.colors)-1] def clean(self): self.land.removeNode() self.startNew() def startNew(self): self.land = render.attachNewNode('Land') def addblock(self, position): self.block = loader.loadModel(self.model) self.block.setTexture(loader.loadTexture(self.texture)) self.block.setPos(position) self.block = self.getColor(int(postion[2])) self.block.setColor(self.color) self.block.reparentTo(self.land) def loadLand(self, filename): self.clean() with open(filename): y = 0 for line in file: x = 0 line = line.split(' ') for z0 in range(int(z) + 1): block = self.addBlock((x, y, z0)) x += 1 y += 1