Browse Source

game-over detection

master
Fr3deric 8 years ago committed by Frederic
parent
commit
03c0970c03
  1. 5
      ttrs.py

5
ttrs.py

@ -301,6 +301,7 @@ class TtrsGame(threading.Thread): @@ -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): @@ -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)

Loading…
Cancel
Save