From 5be0a1df47bcd469bd8143caf1975e9bf920aa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 20 Jul 2017 14:55:37 +0200 Subject: Shift rotate --- turtetris_master/game.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/turtetris_master/game.py b/turtetris_master/game.py index 3a5d463..de7b7e2 100644 --- a/turtetris_master/game.py +++ b/turtetris_master/game.py @@ -183,10 +183,14 @@ class Game: rotated = [ [self.stone[y][x] for y in range(len(self.stone))] for x in range(len(self.stone[0]) - 1, -1, -1)] - if not self.__check_collision__(self.stone_x, self.stone_y, rotated): - self.__clear_stone__() - self.stone = rotated - self.__render_stone__() + for shift in [0, 1, -1, 2, -2]: + shifted_x = self.stone_x + shift + if not self.__check_collision__(shifted_x, self.stone_y, rotated): + self.__clear_stone__() + self.stone = rotated + self.stone_x = shifted_x + self.__render_stone__() + break def __move__(self, left): "Move stone left or right" -- cgit v1.2.3