Added config to increase or decrease game speed when score rising
This commit is contained in:
parent
836f635a6b
commit
a04e422547
@ -65,6 +65,7 @@
|
||||
}
|
||||
},
|
||||
"store_width": 10,
|
||||
"block_size": 30
|
||||
"block_size": 30,
|
||||
"high_score_inc_speed": true
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user