diff --git a/src/scripts/debug_overlay.gd b/src/scripts/debug_overlay.gd index 782640d..48d7797 100644 --- a/src/scripts/debug_overlay.gd +++ b/src/scripts/debug_overlay.gd @@ -25,6 +25,14 @@ func _ready(): info_label.add_theme_color_override("font_color", Color.WHITE) info_label.add_theme_font_size_override("font_size", 20) info_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT + + # Load standard_font.png as bitmap font + var standard_font_resource = null + if ResourceLoader.exists("res://assets/fonts/standard_font.png"): + standard_font_resource = load("res://assets/fonts/standard_font.png") + if standard_font_resource: + info_label.add_theme_font_override("font", standard_font_resource) + add_child(info_label) # Position in top right diff --git a/src/scripts/dungeon_generator.gd b/src/scripts/dungeon_generator.gd index 5df64d7..1ba3f81 100644 --- a/src/scripts/dungeon_generator.gd +++ b/src/scripts/dungeon_generator.gd @@ -148,8 +148,8 @@ func generate_dungeon(map_size: Vector2i, seed_value: int = 0, level: int = 1) - if rng.randf() < 0.3: # 30% chance for a hole _add_hole_to_room(room, grid, tile_grid, map_size, rng) - # 5. Mark start room (first room) - var start_room_index = 0 + # 5. Mark start room (random room for variety) + var start_room_index = rng.randi() % all_rooms.size() var exit_room_index = -1 # Declare exit_room_index early to avoid scope issues all_rooms[start_room_index].modifiers.append({"type": "START"}) diff --git a/src/scripts/enemy_slime.gd b/src/scripts/enemy_slime.gd index f8448fb..6eb7ea1 100644 --- a/src/scripts/enemy_slime.gd +++ b/src/scripts/enemy_slime.gd @@ -181,12 +181,29 @@ func _damaged_behavior(_delta): state_timer = idle_duration func _set_animation(anim_name: String): - if current_animation != anim_name: - current_animation = anim_name - current_frame = 0 - time_since_last_frame = 0.0 + # Validate animation exists before setting it + if anim_name in ANIMATIONS: + if current_animation != anim_name: + current_animation = anim_name + current_frame = 0 + time_since_last_frame = 0.0 + else: + # Invalid animation name - fall back to IDLE + print("EnemySlime: Invalid animation '", anim_name, "' - falling back to IDLE") + if current_animation != "IDLE": + current_animation = "IDLE" + current_frame = 0 + time_since_last_frame = 0.0 func _update_animation(delta): + # Safety check: ensure current_animation exists in ANIMATIONS + if not current_animation in ANIMATIONS: + print("EnemySlime: ERROR - current_animation '", current_animation, "' not in ANIMATIONS! Resetting to IDLE") + current_animation = "IDLE" + current_frame = 0 + time_since_last_frame = 0.0 + return + # Update animation frame timing time_since_last_frame += delta if time_since_last_frame >= ANIMATIONS[current_animation]["frameDurations"][current_frame] / 1000.0: diff --git a/src/scripts/game_ui.gd b/src/scripts/game_ui.gd index a8f85d1..33fe4c5 100644 --- a/src/scripts/game_ui.gd +++ b/src/scripts/game_ui.gd @@ -44,23 +44,39 @@ func _ready(): func _check_command_line_args(): var args = OS.get_cmdline_args() + print("GameUI: Parsing command-line arguments: ", args) # Parse arguments var should_host = false var should_join = false + var should_debug = false var join_address = "127.0.0.1" var local_count = 1 for arg in args: if arg == "--host": should_host = true + print("GameUI: Found --host argument") elif arg == "--join": should_join = true + print("GameUI: Found --join argument") + elif arg == "--room-debug": + should_debug = true + print("GameUI: Found --room-debug argument") elif arg.begins_with("--address="): join_address = arg.split("=")[1] elif arg.begins_with("--players="): local_count = int(arg.split("=")[1]) + print("GameUI: Parsed flags - should_host: ", should_host, ", should_join: ", should_join, ", should_debug: ", should_debug) + + # Set debug flag only if --room-debug is used with --host or --join + if should_debug and (should_host or should_join): + network_manager.show_room_labels = true + print("Debug mode enabled: room labels will be shown") + else: + print("GameUI: Debug mode NOT enabled - should_debug: ", should_debug, ", should_host: ", should_host, ", should_join: ", should_join) + # Auto-start based on arguments if should_host: print("Auto-hosting due to --host argument") diff --git a/src/scripts/game_world.gd b/src/scripts/game_world.gd index 5dfe6fd..c7a4c77 100644 --- a/src/scripts/game_world.gd +++ b/src/scripts/game_world.gd @@ -535,9 +535,9 @@ func _generate_dungeon(): print("GameWorld: Generating dungeon level ", current_level) - # Generate seed (deterministic for level 1, can be random for future levels) + # Generate seed (random for all levels) if dungeon_seed == 0: - dungeon_seed = randi() if current_level > 1 else 12345 # Fixed seed for level 1 for testing + dungeon_seed = randi() # Create dungeon generator var generator = load("res://scripts/dungeon_generator.gd").new() @@ -2146,6 +2146,15 @@ func _create_level_text_ui_programmatically() -> Node: var vbox = VBoxContainer.new() vbox.set_anchors_preset(Control.PRESET_CENTER) + + # Center horizontally and position higher up + var screen_size = get_viewport().get_visible_rect().size + vbox.offset_left = -screen_size.x / 2 + vbox.offset_right = screen_size.x / 2 + vbox.offset_top = -250 # Position higher up from center + vbox.offset_bottom = screen_size.y / 2 - 250 + vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL # Expand to fill width for proper centering + canvas_layer.add_child(vbox) # Level label @@ -2154,6 +2163,15 @@ func _create_level_text_ui_programmatically() -> Node: level_label.text = "LEVEL 1" level_label.add_theme_font_size_override("font_size", 64) level_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + level_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL # Expand to center properly + + # Load standard_font.png as bitmap font + var standard_font_resource = null + if ResourceLoader.exists("res://assets/fonts/standard_font.png"): + standard_font_resource = load("res://assets/fonts/standard_font.png") + if standard_font_resource: + level_label.add_theme_font_override("font", standard_font_resource) + vbox.add_child(level_label) # Add script diff --git a/src/scripts/network_manager.gd b/src/scripts/network_manager.gd index 57b2497..3c2b162 100644 --- a/src/scripts/network_manager.gd +++ b/src/scripts/network_manager.gd @@ -14,6 +14,7 @@ const MAX_PLAYERS = 8 var players_info = {} # Dictionary of peer_id -> {local_player_count: int, player_names: []} var local_player_count = 1 # How many local players on this machine var is_hosting = false +var show_room_labels = false # Show room labels when in debug mode func _ready(): # Connect multiplayer signals diff --git a/src/scripts/room_trigger.gd b/src/scripts/room_trigger.gd index 9dac26b..70ab702 100644 --- a/src/scripts/room_trigger.gd +++ b/src/scripts/room_trigger.gd @@ -26,6 +26,7 @@ func _ready(): call_deferred("_find_room_entities") # Create debug label (deferred to avoid blocking on font load during startup) + # Only create if debug mode is enabled call_deferred("_create_debug_label") func _on_body_entered(body): @@ -426,6 +427,17 @@ func _find_room_spawners(): func _create_debug_label(): # Create a debug label to show puzzle type and trigger status above the room + # Only create if debug mode is enabled + var network_manager = get_node_or_null("/root/NetworkManager") + if not network_manager: + print("RoomTrigger: NetworkManager not found, skipping debug label") + return + if not network_manager.show_room_labels: + print("RoomTrigger: Debug mode not enabled (show_room_labels = false), skipping debug label for room (", room.x, ", ", room.y, ")") + return + + print("RoomTrigger: Creating debug label for room (", room.x, ", ", room.y, ") - debug mode enabled") + # Skip if label already exists if debug_label and is_instance_valid(debug_label): return