From 03c0970c0313f5850ba341faf1ddc3981c5cd40c Mon Sep 17 00:00:00 2001 From: Frederic Date: Mon, 26 Dec 2016 15:37:27 +0100 Subject: [PATCH] game-over detection --- ttrs.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ttrs.py b/ttrs.py index ca7cb3d..1d8c738 100755 --- a/ttrs.py +++ b/ttrs.py @@ -301,6 +301,7 @@ class TtrsGame(threading.Thread): lastfall = 0 lastmove = 0 dropping = False + top_row = { Point(x, -1) for x in range(self.playground.height) } while self.running: self.__call_callbacks() time.sleep(TICK_TIME) @@ -311,6 +312,10 @@ class TtrsGame(threading.Thread): self.running = False break + if not self.playground.block_points.isdisjoint(top_row): + self.running = False + break + if mino is None: newminocls = self.rnd.choice(Tetrimino.__subclasses__()) mino = newminocls(self.playground, spawnpos)