From 5f4a99fe2a12d72bd7afdd9fb658d842fd34e09b Mon Sep 17 00:00:00 2001 From: klonfish Date: Fri, 23 Dec 2016 00:42:50 +0100 Subject: [PATCH 1/2] Fixed full line deletion --- ttrs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ttrs.py b/ttrs.py index 6576326..221beb0 100755 --- a/ttrs.py +++ b/ttrs.py @@ -250,7 +250,9 @@ class TestTtrsPlayer(TtrsPlayer): self.__process_events() return self.__quit - + def reset_rotate(self): + pass + class BalanceTtrsPlayer(TtrsPlayer): def __init__(self, playground, addr, player_id): self.playground = playground @@ -359,12 +361,14 @@ class TtrsGame(): if b.pos.y in to_remove: self.playground.blocks.remove(b) + to_add = set() for b in list(self.playground.blocks): o = len(list(filter(lambda y: y > b.pos.y, to_remove))) if o > 0: self.playground.blocks.remove(b) newb = Block(b.pos + Point(0, o), b.color) - self.playground.blocks.add(newb) + to_add.add(newb) + self.playground.blocks.update(to_add) if ticks - lastfall >= FALL_INTERVAL or self.player.get_drop(): lastfall = ticks From f927e26ca946a20e62fccb82846a40d074e2f13c Mon Sep 17 00:00:00 2001 From: klonfish Date: Fri, 23 Dec 2016 00:55:26 +0100 Subject: [PATCH 2/2] Added blinking of deleted rows --- ttrs.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ttrs.py b/ttrs.py index 221beb0..a01ef23 100755 --- a/ttrs.py +++ b/ttrs.py @@ -357,10 +357,24 @@ class TtrsGame(): to_remove.add(y) if len(to_remove) > 0: + to_delete = set() for b in list(self.playground.blocks): if b.pos.y in to_remove: + to_delete.add(Block(b.pos, (255, 255, 255))) self.playground.blocks.remove(b) + for i in range(2): + for b in to_delete: + self.playground.blocks.add(b) + for cb in self.tick_callbacks: + cb() + time.sleep(0.2) + for b in to_delete: + self.playground.blocks.remove(b) + for cb in self.tick_callbacks: + cb() + time.sleep(0.2) + to_add = set() for b in list(self.playground.blocks): o = len(list(filter(lambda y: y > b.pos.y, to_remove))) @@ -394,13 +408,6 @@ class TtrsGame(): self.player.reset_rotate() except InvalidMoveError: pass - - - - - - - if __name__ == '__main__':