fix line remove
This commit is contained in:
parent
f025ad5fd8
commit
f013a061b2
@ -323,6 +323,7 @@ AGAIN""".format(
|
|||||||
self.show_text("LEVEL\n{:n}".format(level))
|
self.show_text("LEVEL\n{:n}".format(level))
|
||||||
|
|
||||||
def on_generation_phase(self, piece):
|
def on_generation_phase(self, piece):
|
||||||
|
self.matrix.sprites.refresh()
|
||||||
self.matrix.ghost.sprites = TetrominoSprites(self.matrix.ghost, self, GHOST_ALPHA)
|
self.matrix.ghost.sprites = TetrominoSprites(self.matrix.ghost, self, GHOST_ALPHA)
|
||||||
for tetromino in [self.matrix.piece, self.matrix.ghost] + self.next.pieces:
|
for tetromino in [self.matrix.piece, self.matrix.ghost] + self.next.pieces:
|
||||||
tetromino.sprites.refresh()
|
tetromino.sprites.refresh()
|
||||||
@ -340,6 +341,15 @@ AGAIN""".format(
|
|||||||
|
|
||||||
def on_lock_phase(self):
|
def on_lock_phase(self):
|
||||||
self.matrix.piece.sprites.refresh()
|
self.matrix.piece.sprites.refresh()
|
||||||
|
self.matrix.sprites.refresh()
|
||||||
|
|
||||||
|
def on_locked(self, piece):
|
||||||
|
piece.sprites.refresh()
|
||||||
|
for mino in piece:
|
||||||
|
self.matrix.sprites.append(mino.sprite)
|
||||||
|
|
||||||
|
def on_line_remove(self, y):
|
||||||
|
self.matrix.sprites.remove_line(y)
|
||||||
|
|
||||||
def swap(self):
|
def swap(self):
|
||||||
super().swap()
|
super().swap()
|
||||||
@ -348,16 +358,6 @@ AGAIN""".format(
|
|||||||
if tetromino:
|
if tetromino:
|
||||||
tetromino.sprites.refresh()
|
tetromino.sprites.refresh()
|
||||||
|
|
||||||
def on_locked(self, piece):
|
|
||||||
piece.sprites.refresh()
|
|
||||||
for mino in piece:
|
|
||||||
self.matrix.sprites.append(mino.sprite)
|
|
||||||
|
|
||||||
def remove_line(self, y):
|
|
||||||
self.matrix.sprites.remove_line(y)
|
|
||||||
super().remove_line(y)
|
|
||||||
self.matrix.sprites.refresh()
|
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
super().pause()
|
super().pause()
|
||||||
if self.play_music:
|
if self.play_music:
|
||||||
|
@ -299,7 +299,17 @@ class TetrisLogic:
|
|||||||
|
|
||||||
if self.pressed_actions:
|
if self.pressed_actions:
|
||||||
self.auto_repeat = False
|
self.auto_repeat = False
|
||||||
|
self.stop(self.repeat_action)
|
||||||
|
|
||||||
|
for mino in self.matrix.piece:
|
||||||
|
coord = mino.coord + self.matrix.piece.coord
|
||||||
|
if coord.y <= self.matrix.lines + 3:
|
||||||
|
self.matrix[coord.y][coord.x] = mino
|
||||||
|
self.on_locked(self.matrix.piece)
|
||||||
|
|
||||||
|
self.pattern_phase()
|
||||||
|
|
||||||
|
def pattern_phase(self):
|
||||||
# T-Spin
|
# T-Spin
|
||||||
if type(self.matrix.piece) == T_Tetrimino and self.matrix.piece.last_rotation_point is not None:
|
if type(self.matrix.piece) == T_Tetrimino and self.matrix.piece.last_rotation_point is not None:
|
||||||
a = self.is_t_slot(0)
|
a = self.is_t_slot(0)
|
||||||
@ -315,18 +325,13 @@ class TetrisLogic:
|
|||||||
else:
|
else:
|
||||||
t_spin = T_Spin.NONE
|
t_spin = T_Spin.NONE
|
||||||
|
|
||||||
for mino in self.matrix.piece:
|
|
||||||
coord = mino.coord + self.matrix.piece.coord
|
|
||||||
if coord.y <= self.matrix.lines + 3:
|
|
||||||
self.matrix[coord.y][coord.x] = mino
|
|
||||||
self.on_locked(self.matrix.piece)
|
|
||||||
|
|
||||||
# Clear complete lines
|
# Clear complete lines
|
||||||
lines_cleared = 0
|
lines_cleared = 0
|
||||||
for y, line in reversed(list(enumerate(self.matrix))):
|
for y, line in reversed(list(enumerate(self.matrix))):
|
||||||
if all(mino for mino in line):
|
if all(mino for mino in line):
|
||||||
lines_cleared += 1
|
lines_cleared += 1
|
||||||
self.remove_line(y)
|
self.on_line_remove(y)
|
||||||
|
self.matrix.pop(y)
|
||||||
self.matrix.append_new_line()
|
self.matrix.append_new_line()
|
||||||
if lines_cleared:
|
if lines_cleared:
|
||||||
self.stats.lines_cleared += lines_cleared
|
self.stats.lines_cleared += lines_cleared
|
||||||
@ -363,14 +368,14 @@ class TetrisLogic:
|
|||||||
else:
|
else:
|
||||||
self.generation_phase()
|
self.generation_phase()
|
||||||
|
|
||||||
if self.auto_repeat:
|
if self.pressed_actions:
|
||||||
self.restart(self.repeat_action, self.AUTOREPEAT_DELAY)
|
self.start(self.repeat_action, self.AUTOREPEAT_DELAY)
|
||||||
|
|
||||||
def on_locked(piece):
|
def on_locked(piece):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def remove_line(self, y):
|
def on_line_remove(self, y):
|
||||||
self.matrix.pop(y)
|
pass
|
||||||
|
|
||||||
def can_move(self, potential_coord, minoes_coords):
|
def can_move(self, potential_coord, minoes_coords):
|
||||||
return all(self.matrix.cell_is_free(potential_coord + mino_coord) for mino_coord in minoes_coords)
|
return all(self.matrix.cell_is_free(potential_coord + mino_coord) for mino_coord in minoes_coords)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user