aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2017-07-20 14:55:37 +0200
committerKarel Kočí <karel.koci@nic.cz>2017-07-20 14:55:37 +0200
commit5be0a1df47bcd469bd8143caf1975e9bf920aa1e (patch)
treee2916d3889b6feb59d9d35c23c172629c396dcaf
parent580130d99c798c9fb0034f4daba96f8357927f40 (diff)
downloadturris-tetris-5be0a1df47bcd469bd8143caf1975e9bf920aa1e.tar.gz
turris-tetris-5be0a1df47bcd469bd8143caf1975e9bf920aa1e.tar.bz2
turris-tetris-5be0a1df47bcd469bd8143caf1975e9bf920aa1e.zip
Shift rotate
-rw-r--r--turtetris_master/game.py12
1 files 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"