From 104e607cc72b39aa266944cac65c2f095618e8b7 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Tue, 4 Mar 2025 11:12:44 -0600 Subject: [PATCH] cleanup --- Systems/Game/Map/MapGenerator.gd | 10 ++-------- Systems/Game/Map/MapScreen.gd | 24 +++++------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Systems/Game/Map/MapGenerator.gd b/Systems/Game/Map/MapGenerator.gd index 262db42..397922b 100644 --- a/Systems/Game/Map/MapGenerator.gd +++ b/Systems/Game/Map/MapGenerator.gd @@ -170,7 +170,6 @@ func generate_map(): if from_valid and to_valid: valid_connections.append(conn) - # Return the generated map return { "nodes": valid_nodes, "connections": valid_connections, @@ -178,14 +177,11 @@ func generate_map(): "seed": _rng.seed } -# Get a node type based on level - more shops and events in middle levels func _get_random_room_type(level, total_levels): - # Chance of special rooms based on level - var boss_chance = 0.1 + (level / float(total_levels) * 0.1) # Higher chance in later levels - var shop_chance = 0.1 + (level / float(total_levels) * 0.05) # Higher chance in later levels + var boss_chance = 0.1 + (level / float(total_levels) * 0.1) + var shop_chance = 0.1 + (level / float(total_levels) * 0.05) var event_chance = 0.05 - # Last non-final level should have more bosses if level == total_levels - 2: boss_chance += 0.3 @@ -200,14 +196,12 @@ func _get_random_room_type(level, total_levels): else: return RoomType.NORMAL -# Check if a node is connected as a destination in any connection func _is_node_connected_to(node_id, connections): for conn in connections: if conn.to == node_id: return true return false -# Get a unique ID for a new node func _get_next_id(): var id = _next_id _next_id += 1 diff --git a/Systems/Game/Map/MapScreen.gd b/Systems/Game/Map/MapScreen.gd index 5943048..b0d366f 100644 --- a/Systems/Game/Map/MapScreen.gd +++ b/Systems/Game/Map/MapScreen.gd @@ -182,25 +182,21 @@ func display_map(): max_x = max(max_x, x_pos) min_y = min(min_y, y_pos) max_y = max(max_y, y_pos) - - # Add padding to container size + var map_width = max_x - min_x + NODE_SIZE.x * 2 + SCROLL_PADDING_LEFT + SCROLL_PADDING_RIGHT var map_height = max_y - min_y + NODE_SIZE.y * 2 + SCROLL_PADDING_TOP + SCROLL_PADDING_BOTTOM map_container.custom_minimum_size = Vector2(map_width, map_height) - - # Create a padding node at the top + var top_padding = Control.new() top_padding.custom_minimum_size = Vector2(map_width, SCROLL_PADDING_TOP) top_padding.position = Vector2(0, 0) map_container.add_child(top_padding) - - # Create a padding node at the bottom + var bottom_padding = Control.new() bottom_padding.custom_minimum_size = Vector2(map_width, SCROLL_PADDING_BOTTOM) bottom_padding.position = Vector2(0, map_height - SCROLL_PADDING_BOTTOM) map_container.add_child(bottom_padding) - - # Create padding nodes for left and right + var left_padding = Control.new() left_padding.custom_minimum_size = Vector2(SCROLL_PADDING_LEFT, map_height) left_padding.position = Vector2(0, 0) @@ -210,11 +206,7 @@ func display_map(): right_padding.custom_minimum_size = Vector2(SCROLL_PADDING_RIGHT, map_height) right_padding.position = Vector2(map_width - SCROLL_PADDING_RIGHT, 0) map_container.add_child(right_padding) - - # Draw connections first (so they're behind nodes) - - # Modify your display_map function to use the curved connections - # Replace your loop that draws connections with this: + # Draw connections first (so they're behind nodes) for connection in map_connections: @@ -309,7 +301,6 @@ func highlight_current_node(button): button.add_theme_stylebox_override("normal", style) func _on_node_pressed(node_data): - # Check if the node is accessible from current node if is_node_accessible(node_data): # Update current node current_node = node_data @@ -326,7 +317,6 @@ func traversed_node(node_data): traversed_map.append(node_data.id) func is_node_accessible(node_data): - # If no current node, only starting node is accessible if current_node == null: return node_data.type == RoomType.STARTING @@ -351,7 +341,6 @@ func draw_curved_connection(from_node, to_node): elif traversed_map.has(to_node.id) and (traversed_map.has(from_node.id) || from_node.id == 0): line.default_color = LINE_COLOR_SELECTED - # Calculate start and end positions with padding adjustments var start_pos = from_node.position * Vector2(NODE_SPACING_X, NODE_SPACING_Y) + Vector2(SCROLL_PADDING_LEFT, SCROLL_PADDING_TOP) var end_pos = to_node.position * Vector2(NODE_SPACING_X, NODE_SPACING_Y) + Vector2(SCROLL_PADDING_LEFT, SCROLL_PADDING_TOP) @@ -360,7 +349,6 @@ func draw_curved_connection(from_node, to_node): # If nodes are on different levels (y positions) if from_node.position.y != to_node.position.y: - # Calculate control points for a curve var mid_y = (start_pos.y + end_pos.y) / 2 var control_offset = NODE_SPACING_Y * 0.5 * (1 + abs(from_node.position.x - to_node.position.x) * 0.2) @@ -399,7 +387,6 @@ func draw_curved_connection(from_node, to_node): map_container.add_child(line) connection_lines.append(line) -# Helper function for cubic bezier curve calculation func cubic_bezier(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, t: float) -> Vector2: var q0 = p0.lerp(p1, t) var q1 = p1.lerp(p2, t) @@ -410,7 +397,6 @@ func cubic_bezier(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, t: float) return r0.lerp(r1, t) -# Helper function for quadratic bezier curve calculation func quadratic_bezier(p0: Vector2, p1: Vector2, p2: Vector2, t: float) -> Vector2: var q0 = p0.lerp(p1, t) var q1 = p1.lerp(p2, t)