move up held in next pieces
This commit is contained in:
parent
fe69557bc6
commit
0db5dd4d0d
@ -26,7 +26,7 @@ from tetrislogic import TetrisLogic, Color, Phase, Coord, I_Tetrimino, Movement
|
||||
# Matrix
|
||||
LINES = 20
|
||||
COLLUMNS = 10
|
||||
NEXT_PIECES = 5
|
||||
NEXT_PIECES = 6
|
||||
|
||||
# Delays (seconds)
|
||||
LOCK_DELAY = 0.5
|
||||
@ -36,8 +36,8 @@ AUTOREPEAT_PERIOD = 0.010
|
||||
|
||||
# Piece init coord
|
||||
MATRIX_PIECE_COORD = Coord(4, LINES)
|
||||
NEXT_PIECES_COORDS = [Coord(COLLUMNS + 4, LINES - 4 * n - 3) for n in range(COLLUMNS)]
|
||||
HELD_PIECE_COORD = Coord(-5, LINES - 3)
|
||||
NEXT_PIECES_COORDS = [Coord(COLLUMNS + 4, LINES - 4 * n) for n in range(NEXT_PIECES)]
|
||||
HELD_PIECE_COORD = Coord(-5, LINES)
|
||||
|
||||
# Window
|
||||
WINDOW_WIDTH = 800
|
||||
@ -212,10 +212,6 @@ class TetrArcade(TetrisLogic, arcade.Window):
|
||||
self.bg = arcade.Sprite(WINDOW_BG_PATH)
|
||||
self.matrix.bg = arcade.Sprite(MATRIX_BG_PATH)
|
||||
self.matrix.bg.alpha = MATRIX_BG_ALPHA
|
||||
self.held.bg = arcade.Sprite(HELD_BG_PATH)
|
||||
self.held.bg.alpha = BAR_ALPHA
|
||||
self.next.bg = arcade.Sprite(NEXT_BG_PATH)
|
||||
self.next.bg.alpha = BAR_ALPHA
|
||||
self.matrix.sprites = MatrixSprites(self.matrix)
|
||||
self.on_resize(self.init_width, self.init_height)
|
||||
|
||||
@ -401,11 +397,12 @@ AGAIN""".format(
|
||||
if combo_score:
|
||||
self.show_text("COMBO x{:n}\n{:n}".format(nb_combo, combo_score))
|
||||
|
||||
def on_hold(self, held_piece):
|
||||
def on_hold(self, held_piece, falling_piece, ghost_piece):
|
||||
held_piece.coord = HELD_PIECE_COORD
|
||||
if type(held_piece) == I_Tetrimino:
|
||||
held_piece.coord += Movement.LEFT
|
||||
held_piece.sprites.refresh()
|
||||
ghost_piece.sprites = TetrominoSprites(ghost_piece, self, GHOST_ALPHA)
|
||||
|
||||
def pause(self):
|
||||
super().pause()
|
||||
@ -455,8 +452,6 @@ AGAIN""".format(
|
||||
|
||||
if self.phase not in (Phase.STARTING, Phase.PAUSED):
|
||||
self.matrix.bg.draw()
|
||||
self.held.bg.draw()
|
||||
self.next.bg.draw()
|
||||
self.matrix.sprites.draw()
|
||||
|
||||
for tetromino in [
|
||||
@ -545,14 +540,6 @@ AGAIN""".format(
|
||||
self.matrix.bg.left = int(self.matrix.bg.left)
|
||||
self.matrix.bg.top = int(self.matrix.bg.top)
|
||||
|
||||
self.held.bg.scale = self.scale
|
||||
self.held.bg.right = self.matrix.bg.left
|
||||
self.held.bg.top = self.matrix.bg.top
|
||||
|
||||
self.next.bg.scale = self.scale
|
||||
self.next.bg.left = self.matrix.bg.right
|
||||
self.next.bg.top = self.matrix.bg.top
|
||||
|
||||
self.matrix.sprites.resize(self.scale)
|
||||
|
||||
for tetromino in [
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 499 B |
Binary file not shown.
Before Width: | Height: | Size: 475 B |
@ -175,6 +175,7 @@ class TetrisLogic:
|
||||
pass
|
||||
|
||||
def generation_phase(self):
|
||||
self.phase = Phase.GENERATION
|
||||
self.matrix.piece = self.next.pieces.pop(0)
|
||||
self.next.pieces.append(Tetromino())
|
||||
self.matrix.piece.coord = self.MATRIX_PIECE_COORD
|
||||
@ -273,16 +274,16 @@ class TetrisLogic:
|
||||
self.stop(self.fall)
|
||||
self.matrix.piece, self.held.piece = self.held.piece, self.matrix.piece
|
||||
|
||||
self.on_hold(self.held.piece)
|
||||
|
||||
if self.matrix.piece:
|
||||
self.matrix.piece.coord = self.MATRIX_PIECE_COORD
|
||||
self.matrix.ghost = self.matrix.piece.ghost()
|
||||
self.on_hold(self.held.piece, self.matrix.piece, self.matrix.ghost)
|
||||
self.falling_phase()
|
||||
else:
|
||||
self.generation_phase()
|
||||
self.on_hold(self.held.piece, self.matrix.piece, self.matrix.ghost)
|
||||
|
||||
def on_hold(self, held_piece):
|
||||
def on_hold(self, held_piece, falling_piece, ghost_piece):
|
||||
pass
|
||||
|
||||
def pattern_phase(self):
|
||||
|
@ -42,6 +42,7 @@ class Color:
|
||||
class Phase:
|
||||
|
||||
STARTING = "STARTING"
|
||||
GENERATION = "GENERATION"
|
||||
FALLING = "FALLING"
|
||||
LOCK = "LOCK"
|
||||
PATTERN = "PATTERN"
|
||||
|
Loading…
x
Reference in New Issue
Block a user