improve lock
This commit is contained in:
parent
54f2554b2a
commit
f2bbafeb8b
@ -255,7 +255,10 @@ AGAIN""".format(
|
|||||||
def move(self, movement, prelock=True):
|
def move(self, movement, prelock=True):
|
||||||
moved = super().move(movement, prelock)
|
moved = super().move(movement, prelock)
|
||||||
if self.current.prelocked:
|
if self.current.prelocked:
|
||||||
self.current.sprites.set_alpha(PRELOCKED_ALPHA)
|
alpha = PRELOCKED_ALPHA
|
||||||
|
else:
|
||||||
|
alpha = NORMAL_ALPHA
|
||||||
|
self.current.sprites.set_alpha(alpha)
|
||||||
if moved:
|
if moved:
|
||||||
size = MINO_SIZE * self.scale
|
size = MINO_SIZE * self.scale
|
||||||
change_x = movement.x * size
|
change_x = movement.x * size
|
||||||
|
@ -223,21 +223,16 @@ class TetrisLogic():
|
|||||||
)
|
)
|
||||||
|
|
||||||
def lock(self):
|
def lock(self):
|
||||||
|
self.current.prelocked = False
|
||||||
|
self.stop(self.lock)
|
||||||
|
|
||||||
# Piece unlocked
|
# Piece unlocked
|
||||||
if self.can_move(
|
if self.can_move(
|
||||||
self.current.coord + Movement.DOWN,
|
self.current.coord + Movement.DOWN,
|
||||||
(mino.coord for mino in self.current)
|
(mino.coord for mino in self.current)
|
||||||
):
|
):
|
||||||
self.restart(self.lock, self.lock_delay)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Start lock
|
|
||||||
self.current.prelocked = False
|
|
||||||
self.stop(self.lock)
|
|
||||||
if self.pressed_actions:
|
|
||||||
self.auto_repeat = False
|
|
||||||
self.restart(self.repeat_action, self.AUTOREPEAT_DELAY)
|
|
||||||
|
|
||||||
# Game over
|
# Game over
|
||||||
if all(
|
if all(
|
||||||
(mino.coord + self.current.coord).y >= self.NB_LINES
|
(mino.coord + self.current.coord).y >= self.NB_LINES
|
||||||
@ -246,6 +241,10 @@ class TetrisLogic():
|
|||||||
self.game_over()
|
self.game_over()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.pressed_actions:
|
||||||
|
self.auto_repeat = False
|
||||||
|
self.restart(self.repeat_action, self.AUTOREPEAT_DELAY)
|
||||||
|
|
||||||
# T-Spin
|
# T-Spin
|
||||||
if (
|
if (
|
||||||
type(self.current) == T
|
type(self.current) == T
|
||||||
|
Loading…
x
Reference in New Issue
Block a user