From 9f02d63a7d796003e7f29552120f3ab4340c0d51 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 6 Apr 2017 07:31:27 +0000 Subject: [PATCH] Edit chunks when character is written to map --- maps.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/maps.py b/maps.py index 04eecd1..08e768a 100644 --- a/maps.py +++ b/maps.py @@ -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