teststrecke-game/scripts/generate_road_polyon.gd

27 lines
920 B
GDScript

extends Polygon2D
@export var line_road_left: Line2D
@export var line_road_right: Line2D
@export var left_road_show_closed: bool=false
@export var right_road_show_closed: bool=false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var road=PackedVector2Array()
road.append_array(line_road_right.points)
if (line_road_right.closed or right_road_show_closed) and line_road_right.points.size()>0:
road.append(line_road_right.points[0]) #add first point again to close gap
if (line_road_left.closed or left_road_show_closed) and line_road_left.points.size()>0:
road.append(line_road_left.points[0]) #add first point to close gap
var reversed=PackedVector2Array(line_road_left.points)
reversed.reverse()
road.append_array(reversed)
polygon=road
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass