small racing game im working on
Diffstat (limited to 'ui/map.gd')
-rw-r--r--ui/map.gd25
1 files changed, 23 insertions, 2 deletions
diff --git a/ui/map.gd b/ui/map.gd
index a182caa..fa6d737 100644
--- a/ui/map.gd
+++ b/ui/map.gd
@@ -1,11 +1,32 @@
extends Line2D
@export var track: TrackLoader
+@export var car: Node3D
+@export var player_color: Color
-# Called when the node enters the scene tree for the first time.
func _ready() -> void:
clear_points()
width = track.track.track_width
+ # am on the fence about outlining
+ # var outline := Line2D.new()
+ # outline.width = width + 10
+ # outline.default_color = Color.BLACK
+ # outline.show_behind_parent = true
+ # outline.antialiased = true
+ # outline.joint_mode = LINE_JOINT_ROUND
+ # add_child(outline)
for point_3d in track.curve.get_baked_points():
- var p := Vector2(point_3d.x, point_3d.z) / 2
+ var p := flatten(point_3d)
add_point(p)
+ # outline.add_point(p)
+
+
+func _process(_delta: float) -> void:
+ queue_redraw()
+
+func _draw() -> void:
+ var point := flatten(track.curve.get_closest_point(car.ball.global_position))
+ draw_circle(point, width / 2, player_color)
+
+func flatten(vec: Vector3) -> Vector2:
+ return Vector2(vec.x, vec.z)