Improve chapter one map controls

This commit is contained in:
2026-06-19 16:59:58 +09:00
parent a851eef72b
commit e70a4da0a6
2 changed files with 44 additions and 5 deletions

View File

@@ -48,6 +48,7 @@ const FLOATING_TEXT_LIFETIME := 1.0
const FLOATING_TEXT_RISE := 42.0 const FLOATING_TEXT_RISE := 42.0
const OBJECTIVE_NOTICE_DURATION := 2.6 const OBJECTIVE_NOTICE_DURATION := 2.6
const EDGE_SCROLL_MARGIN := 48.0 const EDGE_SCROLL_MARGIN := 48.0
const EDGE_SCROLL_OUTER_MARGIN := 28.0
const EDGE_SCROLL_MIN_SPEED := 80.0 const EDGE_SCROLL_MIN_SPEED := 80.0
const EDGE_SCROLL_MAX_SPEED := 430.0 const EDGE_SCROLL_MAX_SPEED := 430.0
const UNIT_MOVE_ANIMATION_DURATION := 0.18 const UNIT_MOVE_ANIMATION_DURATION := 0.18
@@ -3114,7 +3115,10 @@ func _draw_units() -> void:
var sprite_modulate := _unit_sprite_modulate(unit, acted) 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_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_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_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)) 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: 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 return Vector2.ZERO
var velocity := Vector2( var velocity := Vector2(
_edge_scroll_axis_velocity(mouse_position.x, view_rect.position.x, view_rect.end.x, 1.0), _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) 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: func _capped_edge_scroll_velocity(velocity: Vector2) -> Vector2:
if velocity == Vector2.ZERO or velocity.length() <= EDGE_SCROLL_MAX_SPEED: if velocity == Vector2.ZERO or velocity.length() <= EDGE_SCROLL_MAX_SPEED:
return velocity return velocity

View File

@@ -109,6 +109,7 @@ func _check_edge_scroll_velocity_curve(scene, view_rect: Rect2, failures: Array[
"_edge_scroll_axis_velocity", "_edge_scroll_axis_velocity",
"_edge_scroll_pressure", "_edge_scroll_pressure",
"_edge_scroll_speed_for_pressure", "_edge_scroll_speed_for_pressure",
"_edge_scroll_activation_rect",
"_edge_scroll_next_offset" "_edge_scroll_next_offset"
]: ]:
if not scene.has_method(method_name): 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: 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]) 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) var near_outside_left: Vector2 = scene._edge_scroll_velocity_for_position(view_rect.position - Vector2(4.0, 0.0), view_rect)
if outside_velocity != Vector2.ZERO: if near_outside_left.x <= 0.0:
failures.append("edge scroll should ignore mouse positions outside the map view: %s" % str(outside_velocity)) 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 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) 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_archer",
"_draw_pixel_cavalry", "_draw_pixel_cavalry",
"_draw_pixel_strategist", "_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): if not scene.has_method(method_name):
failures.append("missing pixel-map unit helper: %s" % method_name) failures.append("missing pixel-map unit helper: %s" % method_name)
_check_pixel_unit_profiles(scene, failures) _check_pixel_unit_profiles(scene, failures)
_check_pixel_unit_class_labels(scene, failures)
scene.free() 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") failures.append("ranged pixel profile should keep an explicit bow silhouette")
if str((profiles["infantry"] as Dictionary).get("weapon", "")) != "shield_spear": if str((profiles["infantry"] as Dictionary).get("weapon", "")) != "shield_spear":
failures.append("infantry pixel profile should keep shield and spear silhouette") 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])