Edit chunks when character is written to map

This commit is contained in:
Joscha 2017-04-06 07:31:27 +00:00
parent 5b4a6a4a83
commit 9f02d63a7d

View file

@ -91,7 +91,14 @@ class Map():
return coords
def write(self, char):
pass
with self.chunkpool as pool:
chunk = pool.get(chunkx(self.cursorx), chunky(self.cursory))
if not chunk:
chunk = pool.create(chunkx(self.cursorx), chunky(self.cursory))
chunk.setch(inchunkx(self.cursorx), inchunky(self.cursory), char)
self.move_cursor(1, 0)
def move_cursor(self, dx, dy):
self.cursorx += dx