small racing game im working on
make minimap fit
[skip ci]
| -rw-r--r-- | ui/hud.tscn | 17 | ||||
| -rw-r--r-- | ui/map.gd | 9 |
2 files changed, 21 insertions, 5 deletions
diff --git a/ui/hud.tscn b/ui/hud.tscn index a8b93d7..d453c77 100644 --- a/ui/hud.tscn +++ b/ui/hud.tscn @@ -49,7 +49,9 @@ anchors_preset = 12 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_top = -105.0 +offset_left = 345.0 +offset_top = -130.0 +offset_right = -345.0 grow_horizontal = 2 grow_vertical = 0 theme = ExtResource("1_ie2j2") @@ -118,9 +120,16 @@ bbcode_enabled = true text = "[center] [b][color=#4682b4]N[/color][/b][/center]" script = ExtResource("5_g6cg4") -[node name="MiniMap" type="Line2D" parent="."] +[node name="MiniMapContainer" type="MarginContainer" parent="."] +custom_minimum_size = Vector2(500, 500) +layout_mode = 1 +offset_left = 25.0 +offset_top = 25.0 +offset_right = 525.0 +offset_bottom = 525.0 + +[node name="MiniMap" type="Line2D" parent="MiniMapContainer"] texture_repeat = 2 -scale = Vector2(0.5, 0.5) width = 40.0 default_color = Color(0.854902, 0.854902, 0.854902, 1) gradient = SubResource("Gradient_2kvil") @@ -139,7 +148,7 @@ layout_mode = 1 offset_right = 25.0 [connection signal="assigned" from="." to="Dashboard/laps" method="assigned"] -[connection signal="assigned" from="." to="MiniMap" method="assigned"] +[connection signal="assigned" from="." to="MiniMapContainer/MiniMap" method="assigned"] [connection signal="assigned" from="." to="Dashboard/speed/speed" method="car_assigned" unbinds=3] [connection signal="assigned" from="." to="Dashboard/timer/time" method="assigned" unbinds=1] [connection signal="assigned" from="." to="Dashboard/gears/gears" method="assigned" unbinds=3] @@ -28,7 +28,8 @@ func _ready() -> void: add_point(p) path.curve = curve add_child(path) - global_position = -box.position + Vector2(25, 25) + global_position = -box.position + scale = vec((add((get_parent() as Container).get_rect().size) / add(box.size))/2) mkfollower(track.finish, finish_indicator, Color.WHITE, false, true) func _process(_delta: float) -> void: @@ -54,6 +55,12 @@ func mkfollower(node: Node3D, tex: Texture, mod := Color.WHITE, back := false, r else: followers.push_back([follower,sprite, node]) +func vec(f: float) -> Vector2: + return Vector2(f, f) + +func add(v: Vector2) -> float: + return v.x + v.y + func flatten(v: Vector3) -> Vector2: return Vector2(v.x, v.z) |