Compare commits

...

2 Commits

Author SHA1 Message Date
504ebf8e51 reset held piece's minoes coord 2019-10-06 11:16:08 +02:00
4452eb821c refresh on update 2019-10-06 11:12:51 +02:00
2 changed files with 11 additions and 10 deletions

View File

@ -375,14 +375,6 @@ AGAIN""".format(
next_pieces[-1].sprites = TetrominoSprites(next_pieces[-1], self) next_pieces[-1].sprites = TetrominoSprites(next_pieces[-1], self)
for piece, coord in zip(next_pieces, NEXT_PIECES_COORDS): for piece, coord in zip(next_pieces, NEXT_PIECES_COORDS):
piece.coord = coord piece.coord = coord
piece.sprites.refresh()
def on_falling_phase(self, falling_piece, ghost_piece):
falling_piece.sprites.refresh()
ghost_piece.sprites.refresh()
def on_lock_phase(self, locked_piece):
locked_piece.sprites.refresh(texture=LOCKED_TEXTURE)
def on_locked(self, matrix, locked_piece): def on_locked(self, matrix, locked_piece):
for mino in locked_piece: for mino in locked_piece:
@ -401,9 +393,7 @@ AGAIN""".format(
held_piece.coord = HELD_PIECE_COORD held_piece.coord = HELD_PIECE_COORD
if type(held_piece) == I_Tetrimino: if type(held_piece) == I_Tetrimino:
held_piece.coord += Movement.LEFT held_piece.coord += Movement.LEFT
held_piece.sprites.refresh()
ghost_piece.sprites = TetrominoSprites(ghost_piece, self, GHOST_ALPHA) ghost_piece.sprites = TetrominoSprites(ghost_piece, self, GHOST_ALPHA)
ghost_piece.sprites.refresh()
def pause(self): def pause(self):
super().pause() super().pause()
@ -600,6 +590,14 @@ High score could not be saved:
arcade.unschedule(_task) arcade.unschedule(_task)
arcade.schedule(_task, period) arcade.schedule(_task, period)
def on_update(self, delta_time):
for piece in [self.held.piece, self.matrix.ghost] + self.next.pieces:
if piece:
piece.sprites.refresh()
if self.matrix.piece:
texture = LOCKED_TEXTURE if self.phase == Phase.LOCK else NORMAL_TEXTURE
self.matrix.piece.sprites.refresh(texture=texture)
def on_close(self): def on_close(self):
self.save_high_score() self.save_high_score()
if self.music: if self.music:

View File

@ -274,6 +274,9 @@ class TetrisLogic:
self.stop(self.fall) self.stop(self.fall)
self.matrix.piece, self.held.piece = self.held.piece, self.matrix.piece self.matrix.piece, self.held.piece = self.held.piece, self.matrix.piece
for mino, coord in zip(self.held.piece, self.held.piece.MINOES_COORDS):
mino.coord = coord
if self.matrix.piece: if self.matrix.piece:
self.matrix.piece.coord = self.MATRIX_PIECE_COORD self.matrix.piece.coord = self.MATRIX_PIECE_COORD
self.matrix.ghost = self.matrix.piece.ghost() self.matrix.ghost = self.matrix.piece.ghost()