From c18693a9e735372c1e15a43e1d95baf1fe77f24f Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 20 May 2014 08:32:11 +0900 Subject: [PATCH] Updating scoring --- tetris.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tetris.py b/tetris.py index 8cdc8cc..0da4838 100755 --- a/tetris.py +++ b/tetris.py @@ -191,6 +191,8 @@ class Game: lines_per_level = 10 base_speed = 800 speed_multiplier = 2 + soft_drop_bonus = 1 + hard_drop_bonus = 2 def __init__(self): font_path = pygame.font.get_default_font() @@ -308,9 +310,8 @@ class Game: lines_cleared = self.board.settle() if lines_cleared > 0: - self.score += (self.current_level() + 1) * self.line_multipliers[lines_cleared - 1] + self.update_score((self.current_level() + 1) * self.line_multipliers[lines_cleared - 1]) self.lines_cleared += lines_cleared - self.scoreboard_dirty = True self.tetrad = self.tetrad_next.centered(self.board.grid_dims[0]) self.tetrad_next = Tetrad.random() @@ -334,6 +335,7 @@ class Game: def move_down(self): if self.active: + self.update_score(self.soft_drop_bonus) self.lower_tetrad() @@ -345,7 +347,7 @@ class Game: def drop(self): if self.active: while self.lower_tetrad(): - pass + self.update_score(self.hard_drop_bonus) def current_level(self): @@ -356,6 +358,12 @@ class Game: return self.base_speed - self.current_level() * self.speed_multiplier + def update_score(self, value): + if value > 0: + self.score += value + self.scoreboard_dirty = True + + # # Engine #