diff --git a/src/components/GameProgress.gd b/src/components/GameProgress.gd index b559b7e..2fa13df 100644 --- a/src/components/GameProgress.gd +++ b/src/components/GameProgress.gd @@ -11,9 +11,11 @@ var time_passed := 0. var time_passed_formated: String: get: return loop_timer.get_elapsed_time() +var max_reached_level := 0 func add_one(): figures_passed += 1 + # TODO implement levelup logic func reset(): figures_passed = 0 @@ -39,6 +41,7 @@ func _on_game_state(old_state: GameStateManager.GameState, new_state: GameStateM func _physics_process(delta: float) -> void: debug_stats_container.nodes_passed.label_text = str(figures_passed) debug_stats_container.time_passed.label_text = loop_timer.get_elapsed_time() + debug_stats_container.current_level.label_text = str(max_reached_level) gui.game_state_label.set_text(str(figures_passed)) func get_score(): diff --git a/src/components/gui/DebugStatsContainer.gd b/src/components/gui/DebugStatsContainer.gd index da13728..e83683f 100644 --- a/src/components/gui/DebugStatsContainer.gd +++ b/src/components/gui/DebugStatsContainer.gd @@ -5,6 +5,7 @@ class_name DebugStatsContainer @onready var angle: Label = $VBoxContainer/Angle @onready var nodes_passed: DebugLabel = $VBoxContainer/NodesPassed @onready var time_passed: DebugLabel = $VBoxContainer/TimePassed +@onready var current_level: DebugLabel = $VBoxContainer/CurrentLevel var width_percent := 20 diff --git a/src/components/gui/DebugStatsContainer.tscn b/src/components/gui/DebugStatsContainer.tscn index 8acec33..7e29155 100644 --- a/src/components/gui/DebugStatsContainer.tscn +++ b/src/components/gui/DebugStatsContainer.tscn @@ -113,6 +113,12 @@ label_text = "0" type = 8 regular_update = true +[node name="CurrentLevel" type="Label" parent="VBoxContainer"] +layout_mode = 2 +text = ": 0" +script = ExtResource("3_ows3h") +label_text = "0" + [node name="DebugStatsTimer" type="Timer" parent="."] unique_name_in_owner = true autostart = true diff --git a/src/components/level_system/PatternGen.gd b/src/components/level_system/PatternGen.gd index 4c16476..cbc4d24 100644 --- a/src/components/level_system/PatternGen.gd +++ b/src/components/level_system/PatternGen.gd @@ -1,45 +1,37 @@ extends Node class_name PatternGen -var level_queue := LevelQueue.new() - const MAX_LEVEL := 10 - enum SpawnMode {TUTORIAL, DEBUG, QUEUE} -@export var level := 0: +@export var level: int = G.settings.DEFAULT_LEVEL: set(val): level = clamp(0, MAX_LEVEL, val) +var level_queue := LevelQueue.new() func _ready(): + G.level_changed.connect(_on_level_changed) add_patterns() -func upgrade_level(): - level += 1 - -func downgrade_level(): - level -= 1 +func _on_level_changed(new_level: int): + level = new_level func next_pattern() -> int: if level_queue.length <= 0: add_patterns() return level_queue.next_item() - func add_patterns(): var current_level: Dictionary = LevelPatterns.levels[level] if current_level.get("random"): - var p: int = current_level.level_patterns.pick_random() - for i in LevelPatterns.patterns[p]: - level_queue.add_item(i) - else: - for pattern in current_level.level_patterns: - for type in LevelPatterns.patterns[pattern]: - level_queue.add_item(type) - -func update_patterns_based_on_level(): - # Clear the queue to avoid mixing patterns from different levels - level_queue.items_queue.clear() - # Add patterns corresponding to the current level - add_patterns() + var random_pattern: int = current_level.level_patterns.pick_random() + queue_pattern(random_pattern) + return + + for pattern in current_level.level_patterns: + queue_pattern(pattern) + +func queue_pattern(pattern: int): + for type in LevelPatterns.patterns[pattern]: + level_queue.add_item(type) diff --git a/src/components/settings/DefaultConfig.gd b/src/components/settings/DefaultConfig.gd index ef83acf..f773b43 100644 --- a/src/components/settings/DefaultConfig.gd +++ b/src/components/settings/DefaultConfig.gd @@ -7,6 +7,7 @@ const settings = { DESPAWNER_MODE=16633, SCALE_FACTOR=10, ROTATION_SPEED=12, + MAX_LEVEL=0, }, user_settings = { FPS_COUNTER_ENABLED=true, @@ -17,5 +18,6 @@ const settings = { VSYNC_ENABLED=true, CONTROL_TYPE="FREE_SPIN", IS_CONTROL_INVERTED=false, + DEFAULT_LEVEL=0, } } diff --git a/src/components/spawners/LoopSpawner.gd b/src/components/spawners/LoopSpawner.gd index 9cbde88..91434dd 100644 --- a/src/components/spawners/LoopSpawner.gd +++ b/src/components/spawners/LoopSpawner.gd @@ -5,6 +5,7 @@ class_name LoopSpawner @onready var loop_timer: LoopTimer = %LoopTimer @onready var scale_timer: ScaleTimer = %ScaleTimer @onready var game_progress: GameProgress = %GameProgress +@onready var pattern_gen: PatternGen = %PatternGen @export var figureRoot: FigureRoot @@ -69,16 +70,14 @@ enum FigureType {ICOSAHEDRON, OCTAHEDRON} enum SpawnMode {CENTER, SIDE, RANDOM, QUEUE} func get_spawn_type(): - var s = SpawnMode + var s = PatternGen.SpawnMode match G.settings.SPAWN_MODE: - s.CENTER: # 0 + s.TUTORIAL: # 0 return 3 - s.SIDE: # 1 + s.DEBUG: # 1 return 1 - s.RANDOM: # 2 - return randi_range(0, 19) - s.QUEUE: # 3 - pass + s.QUEUE: # 2 + return pattern_gen.next_pattern() func spawn_figure(figure: Figure) -> void: var new_figure diff --git a/src/globals.gd b/src/globals.gd index 41798f4..6026abf 100644 --- a/src/globals.gd +++ b/src/globals.gd @@ -15,3 +15,6 @@ var settings := {} enum FontType {HEX, EMOJI} @warning_ignore("unused_signal") signal font_changed(new_font: FontType) + +@warning_ignore("unused_signal") +signal level_changed(new_level: int) diff --git a/src/scenes/LoopScene.tscn b/src/scenes/LoopScene.tscn index dcb2ad0..e7b21ca 100644 --- a/src/scenes/LoopScene.tscn +++ b/src/scenes/LoopScene.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=34 format=3 uid="uid://dhbnayqnukkof"] +[gd_scene load_steps=35 format=3 uid="uid://dhbnayqnukkof"] [ext_resource type="Script" path="res://src/scenes/init/LoopScene.gd" id="1_rcesrc"] [ext_resource type="Shader" path="res://src/shaders/LoopSceneSky.gdshader" id="1_xr744"] @@ -26,6 +26,7 @@ [ext_resource type="Texture2D" uid="uid://dho54u5o0pgkt" path="res://assets/build/textures/1x/LoopGuiTileInv.png" id="14_xcs0c"] [ext_resource type="Script" path="res://src/components/settings/Config.gd" id="18_tjx6c"] [ext_resource type="Script" path="res://src/components/GameProgress.gd" id="19_mtejl"] +[ext_resource type="Script" path="res://src/components/level_system/PatternGen.gd" id="27_sueui"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_kgifq"] shader = ExtResource("1_xr744") @@ -258,3 +259,7 @@ script = ExtResource("18_tjx6c") [node name="GameProgress" type="Node" parent="."] unique_name_in_owner = true script = ExtResource("19_mtejl") + +[node name="PatternGen" type="Node" parent="."] +unique_name_in_owner = true +script = ExtResource("27_sueui")