aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar IcECreAm777 <hgk.1998@googlemail.com>2023-07-09 17:43:41 +0200
committerLibravatar IcECreAm777 <hgk.1998@googlemail.com>2023-07-09 17:43:41 +0200
commit53a5ceb792bf3db3114dd06dbbc90c0f2c683afe (patch)
treecacac10e038171dff4bcb1541f2b3e4258ff72e6
parenta9c6a7cf69010079139ae7942bdff5dac450c827 (diff)
parentf977fc5a19ba8e315a2482ad8f99749422c2f83a (diff)
download2023-53a5ceb792bf3db3114dd06dbbc90c0f2c683afe.tar.gz
2023-53a5ceb792bf3db3114dd06dbbc90c0f2c683afe.tar.bz2
2023-53a5ceb792bf3db3114dd06dbbc90c0f2c683afe.zip
Merge branch 'master' of bunny.garden:jam/gmtk/2023
Please enter a commit message to explain why this merge is necessary,
-rw-r--r--Assets/road.pngbin252 -> 0 bytes
-rw-r--r--Assets/road.png.import34
-rw-r--r--Scripts/Road.gd82
-rw-r--r--Scripts/drawing.gd6
4 files changed, 1 insertions, 121 deletions
diff --git a/Assets/road.png b/Assets/road.png
deleted file mode 100644
index 5acc2e9..0000000
--- a/Assets/road.png
+++ /dev/null
Binary files differ
diff --git a/Assets/road.png.import b/Assets/road.png.import
deleted file mode 100644
index 59a81a8..0000000
--- a/Assets/road.png.import
+++ /dev/null
@@ -1,34 +0,0 @@
-[remap]
-
-importer="texture"
-type="CompressedTexture2D"
-uid="uid://bcn7tgs6a4fm7"
-path="res://.godot/imported/road.png-c3c47e2cc8c90beae2ad5c8a3bb2c3ca.ctex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://Assets/road.png"
-dest_files=["res://.godot/imported/road.png-c3c47e2cc8c90beae2ad5c8a3bb2c3ca.ctex"]
-
-[params]
-
-compress/mode=0
-compress/high_quality=false
-compress/lossy_quality=0.7
-compress/hdr_compression=1
-compress/normal_map=0
-compress/channel_pack=0
-mipmaps/generate=false
-mipmaps/limit=-1
-roughness/mode=0
-roughness/src_normal=""
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/normal_map_invert_y=false
-process/hdr_as_srgb=false
-process/hdr_clamp_exposure=false
-process/size_limit=0
-detect_3d/compress_to=1
diff --git a/Scripts/Road.gd b/Scripts/Road.gd
deleted file mode 100644
index 4b19c70..0000000
--- a/Scripts/Road.gd
+++ /dev/null
@@ -1,82 +0,0 @@
-extends Line2D
-
-var epsilon = 2
-
-@onready var leftBorder = $LeftBorder
-@onready var rightBorder = $RightBorder
-
-# Called when the node enters the scene tree for the first time.
-func _ready():
- pass # Replace with function body.
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-func _process(delta):
- pass
-
-func simplify():
- points = simplify_rec(points, epsilon)
-
-func simplify_rec(pointArray: PackedVector2Array, epsilon: float):
- var dmax = 0
- var index = -1
- if pointArray.size() < 3:
- return pointArray
- var end = pointArray.size() - 1
- for i in range(1, end-1):
- var d = find_perpendicular_distance(pointArray[i], pointArray[0], pointArray[end])
- if d > dmax:
- index = i
- dmax = d
-
- if dmax > epsilon:
- var recResults1 = simplify_rec(pointArray.slice(0, index), epsilon)
- var recResults2 = simplify_rec(pointArray.slice(index, end), epsilon)
- recResults1.append_array(recResults2)
- return recResults1
- else:
- return [pointArray[0], pointArray[end]]
-
-func find_perpendicular_distance(p: Vector2, p1: Vector2, p2: Vector2):
- var result
- var slope
- var intercept
- if p1.x == p2.x:
- result = p.x - p1.x
- else:
- slope = (p2.y - p1.y) / (p2.x - p1.x)
- intercept = p1.y - (slope * p1.x)
- result = abs(slope * p.x - p.y + intercept) / sqrt(pow(slope, 2) + 1)
-
- return result
-
-func get_bisector(left_side: bool, p2: Vector2, p1: Vector2 = p2, p3: Vector2 = p2):
- var v1 = (p2 - p1).normalized()
- var v2 = (p2 - p3).normalized()
- var normal
- if v1 == -v2:
- normal = v2.rotated(-PI/2)
- else:
- normal = (v1 + v2).normalized()
- if v2.rotated(-PI/2).dot(v1) < 0:
- normal = -normal
-
- if left_side:
- normal = -normal
- return normal
-
-
-func draw_borders():
- for pointIndex in range(0, points.size() - 1):
- var normal
- if pointIndex == 0:
- continue
- elif pointIndex == points.size() -1:
- continue
- #normal = Vector2.ZERO
- else:
- normal = get_bisector(true, points[pointIndex], points[pointIndex-1], points[pointIndex+1])
-
- var point = points[pointIndex] + (normal*50)
- leftBorder.add_point(point)
- point = points[pointIndex] - (normal*50)
- rightBorder.add_point(point)
diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd
index 6b94f6e..832c42d 100644
--- a/Scripts/drawing.gd
+++ b/Scripts/drawing.gd
@@ -2,7 +2,7 @@ extends Node
var drawing = false
-@onready var line = $Road
+@onready var line: Line2D = $TrackLine
@onready var path: Path2D = $TrackPath
func _ready():
@@ -16,10 +16,6 @@ func start_drawing():
func _end_drawing():
drawing = false
- line.simplify()
- line.draw_borders()
- for point in line.points:
- path.curve.add_point(point)
owner.set_driving(true)