From 850aad353e60589ef6fe4e8b97689abe90007c93 Mon Sep 17 00:00:00 2001 From: adrienmalin <41926238+adrienmalin@users.noreply.github.com> Date: Tue, 1 Oct 2019 02:40:34 +0200 Subject: [PATCH] fix swap --- TetrArcade.py | 10 ++++++---- tetrislogic/tetrislogic.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/TetrArcade.py b/TetrArcade.py index c49eb6f..80df3d4 100644 --- a/TetrArcade.py +++ b/TetrArcade.py @@ -230,8 +230,10 @@ class TetrArcade(tetrislogic.TetrisLogic, arcade.Window): font_name = FONT_NAME, anchor_x = 'right' ) - self.on_resize(WINDOW_WIDTH, WINDOW_HEIGHT) - self.new_game() + self.scale = 1 + + def on_hide(self): + self.pause() def on_resize(self, width, height): super().on_resize(width, height) @@ -296,7 +298,7 @@ class TetrArcade(tetrislogic.TetrisLogic, arcade.Window): def swap(self): super().swap() - self.ghost = TetrominoSprites(self.ghost, self, GHOST_ALPHA) + self.ghost.sprites = TetrominoSprites(self.ghost, self, GHOST_ALPHA) for tetromino in [self.held, self.current, self.ghost]: if tetromino: tetromino.sprites.update() @@ -387,7 +389,7 @@ class TetrArcade(tetrislogic.TetrisLogic, arcade.Window): start_x = self.matrix_bg.center_x, start_y = self.matrix_bg.center_y, color = HIGHLIGHT_TEXT_COLOR, - font_size = HIGHLIGHT_TEXT_SIZE, + font_size = HIGHLIGHT_TEXT_SIZE * self.scale, align = 'center', font_name = FONT_NAME, anchor_x = 'center', diff --git a/tetrislogic/tetrislogic.py b/tetrislogic/tetrislogic.py index e43935c..fd11739 100644 --- a/tetrislogic/tetrislogic.py +++ b/tetrislogic/tetrislogic.py @@ -2,7 +2,7 @@ import random from .utils import Coord, Movement, Rotation, T_Spin, Line -from .tetromino import Tetromino, T +from .tetromino import Tetromino, T, I from .consts import ( NB_LINES, NB_COLS, NB_NEXT, LOCK_DELAY, FALL_DELAY, @@ -326,7 +326,7 @@ class TetrisLogic(): self.current.prelocked = False self.stop(self.lock) self.current, self.held = self.held, self.current - if self.held.__class__ == Tetromino.I: + if type(self.held) == I: self.held.coord = HELD_I_COORD else: self.held.coord = HELD_COORD