From c98b58820f957a9d94756338c0e9c3971b5d2085 Mon Sep 17 00:00:00 2001 From: troido Date: Tue, 2 Jan 2018 11:26:08 +0100 Subject: sprites without a background will now take the background of the sprite below it (if any) --- asciifarm/client/display/fieldpad.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'asciifarm/client/display/fieldpad.py') diff --git a/asciifarm/client/display/fieldpad.py b/asciifarm/client/display/fieldpad.py index bb15a0e..24baa81 100644 --- a/asciifarm/client/display/fieldpad.py +++ b/asciifarm/client/display/fieldpad.py @@ -26,7 +26,16 @@ class FieldPad: win.erase() win.noutrefresh() - def changeCell(self, x, y, char, colour=None, bgcolour=0): + def changeCell(self, x, y, sprites): + """ sprites must always have at least one element """ + char, colour, bgcolour = sprites[0] + if bgcolour == None: + for (ch, co, bg) in sprites: + if bg != None: + bgcolour = bg + break + else: + bgcolour = 0 if colour != None and self.colours: self.pad.addstr(y, x*self.charSize, char, self.colours.get(colour, bgcolour)) else: -- cgit