From ca31e8da2442bb13327f4e9e1fe526d5dca07893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 21 Jul 2017 15:15:23 +0200 Subject: Light game area as little as possible --- turtetris_master/game.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'turtetris_master') diff --git a/turtetris_master/game.py b/turtetris_master/game.py index 40d2da7..92c5fa5 100644 --- a/turtetris_master/game.py +++ b/turtetris_master/game.py @@ -25,7 +25,7 @@ SHAPES = [ ] COLORS = [ - 'black', + '010101', 'FFFF00', '88FF00', '00FF88', @@ -45,6 +45,9 @@ class Game: self.mx = [None]*(matrix.width - 2) for i in range(len(self.mx)): self.mx[i] = [0]*matrix.height + for x in range(len(self.mx)): # Light game area up + for y in range(len(self.mx[x])): + matrix.pixel(x, y, COLORS[0]) self.stone_next = SHAPES[randrange(len(SHAPES))][:] # Don't have to check result as it should always be successful if not self.new_stone(): @@ -103,7 +106,7 @@ class Game: if self.stone[x][y] != 0: self.matrix.pixel(self.matrix.width - x - 3 - self.stone_x, self.matrix.height - 1 - y - self.stone_y, - 'black') + COLORS[0]) def __check_collision__(self, x, y, stone): "Check if stone collides. Returns True of so." @@ -126,11 +129,11 @@ class Game: if ii < i: self.matrix.pixel(self.matrix.width - 1, ii, 'green') else: - self.matrix.pixel(self.matrix.width - 1, ii, 'black') + self.matrix.pixel(self.matrix.width - 1, ii, COLORS[0]) if ii < y: self.matrix.pixel(self.matrix.width - 2, ii, 'green') else: - self.matrix.pixel(self.matrix.width - 2, ii, 'black') + self.matrix.pixel(self.matrix.width - 2, ii, COLORS[0]) def __place__(self): "Stone can't move so place it, check lines and generate new one" -- cgit v1.2.3