restart prelock

This commit is contained in:
adrienmalin 2019-10-01 03:20:54 +02:00
parent b1cef21f00
commit 00e2adf60c
2 changed files with 29 additions and 28 deletions

View File

@ -209,34 +209,6 @@ class TetrArcade(tetrislogic.TetrisLogic, arcade.Window):
self.matrix_bg.alpha = MATRIX_BG_ALPHA self.matrix_bg.alpha = MATRIX_BG_ALPHA
self.matrix.sprites = MatrixSprites(self.matrix) self.matrix.sprites = MatrixSprites(self.matrix)
def on_hide(self):
self.pause()
def on_resize(self, width, height):
super().on_resize(width, height)
center_x = width / 2
center_y = height / 2
self.scale = min(width/WINDOW_WIDTH, height/WINDOW_HEIGHT)
self.bg.scale = max(width/WINDOW_WIDTH, height/WINDOW_HEIGHT)
self.bg.center_x = center_x
self.bg.center_y = center_y
self.matrix_bg.scale = self.scale
self.matrix_bg.center_x = center_x
self.matrix_bg.center_y = center_y
self.matrix_bg.left = int(self.matrix_bg.left)
self.matrix_bg.top = int(self.matrix_bg.top)
self.matrix.sprites.resize(self.scale)
for tetromino in [self.held, self.current, self.ghost] + self.next:
if tetromino:
tetromino.sprites.resize(self.scale)
def toggle_fullscreen(self):
self.set_fullscreen(not self.fullscreen)
def new_game(self): def new_game(self):
self.highlight_texts = [] self.highlight_texts = []
super().new_game() super().new_game()
@ -388,6 +360,34 @@ class TetrArcade(tetrislogic.TetrisLogic, arcade.Window):
anchor_y = 'center' anchor_y = 'center'
) )
def on_hide(self):
self.pause()
def toggle_fullscreen(self):
self.set_fullscreen(not self.fullscreen)
def on_resize(self, width, height):
super().on_resize(width, height)
center_x = width / 2
center_y = height / 2
self.scale = min(width/WINDOW_WIDTH, height/WINDOW_HEIGHT)
self.bg.scale = max(width/WINDOW_WIDTH, height/WINDOW_HEIGHT)
self.bg.center_x = center_x
self.bg.center_y = center_y
self.matrix_bg.scale = self.scale
self.matrix_bg.center_x = center_x
self.matrix_bg.center_y = center_y
self.matrix_bg.left = int(self.matrix_bg.left)
self.matrix_bg.top = int(self.matrix_bg.top)
self.matrix.sprites.resize(self.scale)
for tetromino in [self.held, self.current, self.ghost] + self.next:
if tetromino:
tetromino.sprites.resize(self.scale)
def load_high_score(self): def load_high_score(self):
try: try:
with open(HIGH_SCORE_PATH, "r") as f: with open(HIGH_SCORE_PATH, "r") as f:

View File

@ -216,6 +216,7 @@ class TetrisLogic():
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 # Start lock