From a04e4225473038398a50fb59ae64a816470c8a98 Mon Sep 17 00:00:00 2001 From: Anry Das Date: Sun, 16 Nov 2025 09:12:29 +0200 Subject: [PATCH] Added config to increase or decrease game speed when score rising --- configs/config_000.json | 3 ++- das_tetris_gui.py | 20 ++++++++++++++------ tetris_config.py | 5 ++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/configs/config_000.json b/configs/config_000.json index 1d51871..02eff90 100644 --- a/configs/config_000.json +++ b/configs/config_000.json @@ -65,6 +65,7 @@ } }, "store_width": 10, - "block_size": 30 + "block_size": 30, + "high_score_inc_speed": true } } \ No newline at end of file diff --git a/das_tetris_gui.py b/das_tetris_gui.py index f77e9c1..77cbb57 100644 --- a/das_tetris_gui.py +++ b/das_tetris_gui.py @@ -220,12 +220,20 @@ class TetrisGame: elapsed = (current_ticks - self.last_time) / 1000.0 # Convert to seconds self.last_time = current_ticks - if self.score > 5000: - self.fall_speed = 0.55 - elif self.score > 10000: - self.fall_speed = 0.6 - elif self.score > 15000: - self.fall_speed = 0.65 + if cfg.HIGH_SCORE_INC_SPEED: + if self.score > 5000: + self.fall_speed = 0.55 + elif self.score > 10000: + self.fall_speed = 0.6 + elif self.score > 15000: + self.fall_speed = 0.65 + else: + if self.score > 5000: + self.fall_speed = 0.45 + elif self.score > 10000: + self.fall_speed = 0.4 + elif self.score > 15000: + self.fall_speed = 0.35 if not self.game_over and not self.paused: self.fall_time += elapsed diff --git a/tetris_config.py b/tetris_config.py index eb74825..505051c 100644 --- a/tetris_config.py +++ b/tetris_config.py @@ -133,6 +133,8 @@ COLORS = { 'game_over': (255, 0, 0) } +HIGH_SCORE_INC_SPEED = False + def store_config(): blocks_to_save = {'ALL_BLOCKS': BlockType} @@ -151,7 +153,7 @@ def store_config(): def load_config(): - global KEY_CONFIG, COLORS, CONTROLS_TEXT, STORE_WIDTH, BLOCK_SIZE, BLOCK_TYPE + global KEY_CONFIG, COLORS, CONTROLS_TEXT, STORE_WIDTH, BLOCK_SIZE, BLOCK_TYPE, HIGH_SCORE_INC_SPEED es = EnumSerializer if not os.path.isfile(CONFIG_JSON) or not os.path.isfile(CONFIG_JSON) : @@ -164,6 +166,7 @@ def load_config(): COLORS = config_data['CONFIG']['colors'] STORE_WIDTH = config_data['CONFIG']['store_width'] BLOCK_SIZE = config_data['CONFIG']['block_size'] + HIGH_SCORE_INC_SPEED = True if str(config_data['CONFIG']['high_score_inc_speed']).lower() == 'true' else False with open(CONFIG_BLOCKS_JSON) as block_fd: blocks_data = json.load(block_fd)