def __init__ (self, mapname): self._verbose = False self._route = [] self._floor = array2d (initMapSize, initMapSize, ' ') self._weightings = array2d (initMapSize, initMapSize, [1]) self._currentLineNo = 1 self._loadMap (mapname) self._recreateFloor (None) self._calcWeightings ()
def _calcWeightings (self): del self._weightings self._weightings = array2d (self._floor.high ()[0], self._floor.high ()[1], [1]) for r in rooms.keys (): for w in rooms[r].walls: self._weightLine (w, [wallCost]) for d in rooms[r].doors: self._weightLine (d[0], [1]) for l in rooms[r].lights: self._weightings.set (l[0], l[1], [wallCost]) if debugmap: self.printWeightings ()
def _recreateFloor(self, b): del self._floor self._floor = array2d(initMapSize, initMapSize, ' ') for r in list(rooms.keys()): for w in rooms[r].walls: self._drawLine(w, '#') for d in rooms[r].doors: self._drawLine(d[0], ' ') for l in rooms[r].lights: self._floor.set(l[0], l[1], 'l') if debugmap: self.printFloor() if b != None: self._updateEntities(b)
#!/usr/bin/python from array2d import array2d a = array2d(20, 10, ' ') print a.high() # # printf - keeps C programmers happy :-) # def printf(format, *args): print str(format) % args, def dump(): for j in range(a.high()[1]): s = "" for i in range(a.high()[0]): s += a.get(i, j) printf("%s\n", s) y = a.high()[1] - 1 for i in range(a.high()[0]): a.set(i, 0, '#') a.set(i, y, '#') x = a.high()[0] - 1 for j in range(a.high()[1]):