From e70a4da0a6dc3bd67167940a8e132686a381fb46 Mon Sep 17 00:00:00 2001 From: Wickedness Date: Fri, 19 Jun 2026 16:59:58 +0900 Subject: [PATCH] Improve chapter one map controls --- scripts/scenes/battle_scene.gd | 10 +++++++- tools/smoke_chapter_one_polish.gd | 39 +++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/scripts/scenes/battle_scene.gd b/scripts/scenes/battle_scene.gd index 0044fc9..448cfd0 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -48,6 +48,7 @@ const FLOATING_TEXT_LIFETIME := 1.0 const FLOATING_TEXT_RISE := 42.0 const OBJECTIVE_NOTICE_DURATION := 2.6 const EDGE_SCROLL_MARGIN := 48.0 +const EDGE_SCROLL_OUTER_MARGIN := 28.0 const EDGE_SCROLL_MIN_SPEED := 80.0 const EDGE_SCROLL_MAX_SPEED := 430.0 const UNIT_MOVE_ANIMATION_DURATION := 0.18 @@ -3114,7 +3115,10 @@ func _draw_units() -> void: var sprite_modulate := _unit_sprite_modulate(unit, acted) draw_circle(center + Vector2(0, 17), 20, Color(0.0, 0.0, 0.0, 0.30)) + _draw_unit_class_emblem(rect, center, unit, team_color) _draw_pixel_unit_sprite(rect, unit, team_color, sprite_modulate) + _draw_unit_identity_marks(rect, center, unit, team_color) + _draw_unit_class_badge(rect, unit, team_color) var hp_ratio := float(unit["hp"]) / float(max(1, int(unit["max_hp"]))) var hp_back := Rect2(rect.position + Vector2(8, TILE_SIZE - 8), Vector2(TILE_SIZE - 16, 5)) @@ -4385,7 +4389,7 @@ func _clamped_board_scroll_offset(offset: Vector2) -> Vector2: func _edge_scroll_velocity_for_position(mouse_position: Vector2, view_rect: Rect2) -> Vector2: - if not view_rect.has_point(mouse_position): + if not _edge_scroll_activation_rect(view_rect).has_point(mouse_position): return Vector2.ZERO var velocity := Vector2( _edge_scroll_axis_velocity(mouse_position.x, view_rect.position.x, view_rect.end.x, 1.0), @@ -4394,6 +4398,10 @@ func _edge_scroll_velocity_for_position(mouse_position: Vector2, view_rect: Rect return _capped_edge_scroll_velocity(velocity) +func _edge_scroll_activation_rect(view_rect: Rect2) -> Rect2: + return view_rect.grow(EDGE_SCROLL_OUTER_MARGIN) + + func _capped_edge_scroll_velocity(velocity: Vector2) -> Vector2: if velocity == Vector2.ZERO or velocity.length() <= EDGE_SCROLL_MAX_SPEED: return velocity diff --git a/tools/smoke_chapter_one_polish.gd b/tools/smoke_chapter_one_polish.gd index 7b3425e..720d899 100644 --- a/tools/smoke_chapter_one_polish.gd +++ b/tools/smoke_chapter_one_polish.gd @@ -109,6 +109,7 @@ func _check_edge_scroll_velocity_curve(scene, view_rect: Rect2, failures: Array[ "_edge_scroll_axis_velocity", "_edge_scroll_pressure", "_edge_scroll_speed_for_pressure", + "_edge_scroll_activation_rect", "_edge_scroll_next_offset" ]: if not scene.has_method(method_name): @@ -139,9 +140,20 @@ func _check_edge_scroll_velocity_curve(scene, view_rect: Rect2, failures: Array[ if top_left.length() > max_edge_speed + 0.01: failures.append("corner edge scroll should cap diagonal speed: %.2f > %.2f" % [top_left.length(), max_edge_speed]) - var outside_velocity: Vector2 = scene._edge_scroll_velocity_for_position(view_rect.position - Vector2(4.0, 4.0), view_rect) - if outside_velocity != Vector2.ZERO: - failures.append("edge scroll should ignore mouse positions outside the map view: %s" % str(outside_velocity)) + var near_outside_left: Vector2 = scene._edge_scroll_velocity_for_position(view_rect.position - Vector2(4.0, 0.0), view_rect) + if near_outside_left.x <= 0.0: + failures.append("edge scroll should continue when the mouse slightly crosses the left map edge: %s" % str(near_outside_left)) + var near_outside_right: Vector2 = scene._edge_scroll_velocity_for_position(Vector2(view_rect.end.x + 4.0, view_rect.get_center().y), view_rect) + if near_outside_right.x >= 0.0: + failures.append("edge scroll should continue when the mouse slightly crosses the right map edge: %s" % str(near_outside_right)) + var near_outside_corner: Vector2 = scene._edge_scroll_velocity_for_position(view_rect.position - Vector2(4.0, 4.0), view_rect) + if near_outside_corner.x <= 0.0 or near_outside_corner.y <= 0.0: + failures.append("edge scroll should keep diagonal movement just outside the map corner: %s" % str(near_outside_corner)) + if near_outside_corner.length() > max_edge_speed + 0.01: + failures.append("near-outside corner edge scroll should cap diagonal speed: %.2f > %.2f" % [near_outside_corner.length(), max_edge_speed]) + var far_outside_velocity: Vector2 = scene._edge_scroll_velocity_for_position(view_rect.position - Vector2(scene.EDGE_SCROLL_OUTER_MARGIN + 8.0, scene.EDGE_SCROLL_OUTER_MARGIN + 8.0), view_rect) + if far_outside_velocity != Vector2.ZERO: + failures.append("edge scroll should ignore mouse positions far outside the map view: %s" % str(far_outside_velocity)) var hard_right_position := Vector2(view_rect.end.x - 2.0, view_rect.get_center().y) var moved_right: Vector2 = scene._edge_scroll_next_offset(Vector2.ZERO, hard_right_position, view_rect, 0.25) @@ -1194,11 +1206,16 @@ func _check_pixel_unit_helpers(failures: Array[String]) -> void: "_draw_pixel_archer", "_draw_pixel_cavalry", "_draw_pixel_strategist", - "_draw_pixel_heavy" + "_draw_pixel_heavy", + "_draw_unit_class_emblem", + "_draw_unit_class_badge", + "_draw_unit_identity_marks", + "_unit_class_abbrev" ]: if not scene.has_method(method_name): failures.append("missing pixel-map unit helper: %s" % method_name) _check_pixel_unit_profiles(scene, failures) + _check_pixel_unit_class_labels(scene, failures) scene.free() @@ -1244,3 +1261,17 @@ func _check_pixel_unit_profiles(scene, failures: Array[String]) -> void: failures.append("ranged pixel profile should keep an explicit bow silhouette") if str((profiles["infantry"] as Dictionary).get("weapon", "")) != "shield_spear": failures.append("infantry pixel profile should keep shield and spear silhouette") + + +func _check_pixel_unit_class_labels(scene, failures: Array[String]) -> void: + var expected_labels := { + "infantry": "보", + "archer": "궁", + "cavalry": "기", + "strategist": "책", + "bandit": "무" + } + for class_id in expected_labels.keys(): + var label := str(scene._unit_class_abbrev({"class_id": class_id})) + if label != str(expected_labels[class_id]): + failures.append("pixel unit class badge should use Hangul label for %s: %s" % [class_id, label])