Skip to content

Commit

Permalink
add demo track (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
siku2 authored Sep 30, 2023
2 parents 5f3bdc4 + 5e88107 commit 4b3645e
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 98 deletions.
8 changes: 5 additions & 3 deletions prefabs/Track.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
[ext_resource type="Texture2D" uid="uid://dlgfnj8p01ym4" path="res://assets/track.png" id="4_tum5x"]

[sub_resource type="Curve2D" id="Curve2D_nxaiu"]
resource_local_to_scene = true
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 2.08165e-12, 2.08165e-12, 0, 0, 0, 0, 256, 2.08165e-12)
}
point_count = 2

[sub_resource type="ArrayMesh" id="ArrayMesh_hyu12"]
[sub_resource type="ArrayMesh" id="ArrayMesh_umy7o"]
_surfaces = [{
"2d": true,
"aabb": AABB(-1.5, -13.5, 0, 3.00001, 27, 0),
Expand All @@ -25,8 +26,9 @@ _surfaces = [{
}]

[sub_resource type="MultiMesh" id="MultiMesh_mjuev"]
resource_local_to_scene = true
instance_count = 26
mesh = SubResource("ArrayMesh_hyu12")
mesh = SubResource("ArrayMesh_umy7o")
buffer = PackedFloat32Array(1, 0, 0, 5, 0, 1, 0, 2.08165e-12, 1, 4.33681e-20, 0, 15, -4.33681e-20, 1, 0, 2.08165e-12, 1, 0, 0, 25, 0, 1, 0, 2.08165e-12, 1, -4.33681e-20, 0, 35, 4.33681e-20, 1, 0, 2.08165e-12, 1, 0, 0, 45, 0, 1, 0, 2.08165e-12, 1, 0, 0, 55, 0, 1, 0, 2.08165e-12, 1, 0, 0, 65, 0, 1, 0, 2.08165e-12, 1, 0, 0, 75, 0, 1, 0, 2.08165e-12, 1, 0, 0, 85, 0, 1, 0, 2.08165e-12, 1, 0, 0, 95, 0, 1, 0, 2.08165e-12, 1, 0, 0, 105, 0, 1, 0, 2.08165e-12, 1, 0, 0, 115, 0, 1, 0, 2.08165e-12, 1, 4.33681e-20, 0, 125, -4.33681e-20, 1, 0, 2.08165e-12, 1, 0, 0, 135, 0, 1, 0, 2.08165e-12, 1, 0, 0, 145, 0, 1, 0, 2.08165e-12, 1, 0, 0, 155, 0, 1, 0, 2.08165e-12, 1, 0, 0, 165, 0, 1, 0, 2.08165e-12, 1, 0, 0, 175, 0, 1, 0, 2.08165e-12, 1, 0, 0, 185, 0, 1, 0, 2.08165e-12, 1, 0, 0, 195, 0, 1, 0, 2.08165e-12, 1, 4.33681e-20, 0, 205, -4.33681e-20, 1, 0, 2.08165e-12, 1, 4.33681e-20, 0, 215, -4.33681e-20, 1, 0, 2.08165e-12, 1, 0, 0, 225, 0, 1, 0, 2.08165e-12, 1, 0, 0, 235, 0, 1, 0, 2.08165e-12, 1, 0, 0, 245, 0, 1, 0, 2.08165e-12, 1, 0, 0, 255, 0, 1, 0, 2.08165e-12)

[node name="Track" type="Path2D"]
Expand All @@ -36,7 +38,7 @@ script = ExtResource("1_ibb4y")
[node name="Crosstie" type="MeshInstance2D" parent="."]
visible = false
position = Vector2(-50, -50)
mesh = SubResource("ArrayMesh_hyu12")
mesh = SubResource("ArrayMesh_umy7o")
texture = ExtResource("2_hrp4r")

[node name="MultiMeshInstance2D" type="MultiMeshInstance2D" parent="."]
Expand Down
2 changes: 1 addition & 1 deletion prefabs/TrackJunction.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ script = ExtResource("1_w16ft")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_fb8j6")

[connection signal="area_entered" from="." to="." method="_on_track_junction_area_entered"]
[connection signal="area_entered" from="." to="." method="_on_TrackJunction_area_entered"]
134 changes: 48 additions & 86 deletions prefabs/TrackSwitch.tscn
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
[gd_scene load_steps=16 format=3 uid="uid://bm5dq3lcopsvl"]
[gd_scene load_steps=12 format=3 uid="uid://bm5dq3lcopsvl"]

[ext_resource type="Script" path="res://scripts/TrackSwitch.gd" id="1_ucgph"]
[ext_resource type="Script" path="res://scripts/Track.gd" id="2_mym28"]
[ext_resource type="Texture2D" uid="uid://dyk30b1nt2gvq" path="res://assets/crosstie.png" id="3_hpgfb"]
[ext_resource type="PackedScene" uid="uid://d1xy67euifbh6" path="res://prefabs/Track.tscn" id="2_e5vto"]
[ext_resource type="Texture2D" uid="uid://4os8k8h2eoph" path="res://assets/switch_right.png" id="3_nu1m2"]
[ext_resource type="PackedScene" uid="uid://btfdanletw1gi" path="res://prefabs/TrackJunction.tscn" id="4_umyy3"]
[ext_resource type="Texture2D" uid="uid://bk10alqlk6ie2" path="res://assets/switch_left.png" id="4_xc4rb"]
[ext_resource type="Texture2D" uid="uid://dlgfnj8p01ym4" path="res://assets/track.png" id="5_cqy4p"]
[ext_resource type="Texture2D" uid="uid://cfj6l27udpvr7" path="res://assets/arrow.png" id="6_nflxo"]

[sub_resource type="Curve2D" id="Curve2D_nxaiu"]
[sub_resource type="Curve2D" id="Curve2D_pk38d"]
resource_local_to_scene = true
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 2.08165e-12, 2.08165e-12, -24.017, 16.005, 24.017, -16.005, 64, -16, 0, 0, 0, 0, 128, -32)
}
point_count = 3

[sub_resource type="ArrayMesh" id="ArrayMesh_hyu12"]
[sub_resource type="ArrayMesh" id="ArrayMesh_umy7o"]
_surfaces = [{
"2d": true,
"aabb": AABB(-1.5, -13.5, 0, 3.00001, 27, 0),
Expand All @@ -28,33 +26,23 @@ _surfaces = [{
"vertex_data": PackedByteArray(0, 0, 192, 63, 0, 0, 88, 65, 0, 0, 192, 191, 0, 0, 88, 65, 0, 0, 192, 191, 0, 0, 88, 193, 0, 0, 192, 63, 0, 0, 88, 193)
}]

[sub_resource type="MultiMesh" id="MultiMesh_mjuev"]
[sub_resource type="MultiMesh" id="MultiMesh_m32f0"]
resource_local_to_scene = true
instance_count = 13
mesh = SubResource("ArrayMesh_hyu12")
mesh = SubResource("ArrayMesh_umy7o")
buffer = PackedFloat32Array(0.99808, 0.0619333, 0, 4.99647, -0.0619333, 0.99808, 0, -0.176236, 0.992584, 0.121559, 0, 14.9636, -0.121559, 0.992584, 0, -0.961502, 0.98391, 0.178663, 0, 24.872, -0.178663, 0.98391, 0, -2.30135, 0.969346, 0.2457, 0, 34.6786, -0.2457, 0.969346, 0, -4.24865, 0.94496, 0.327186, 0, 44.3185, -0.327186, 0.94496, 0, -6.89664, 0.901405, 0.432977, 0, 53.6711, -0.432977, 0.901405, 0, -10.4225, 0.847395, 0.530963, 0, 62.5187, -0.530963, 0.847395, 0, -15.0622, 0.910454, 0.413611, 0, 71.1488, -0.413611, 0.910454, 0, -20.1015, 0.949217, 0.314623, 0, 80.3623, -0.314623, 0.949217, 0, -23.9742, 0.971893, 0.235421, 0, 89.9171, -0.235421, 0.971893, 0, -26.9124, 0.985566, 0.169291, 0, 99.6749, -0.169291, 0.985566, 0, -29.0903, 0.993711, 0.111974, 0, 109.553, -0.111974, 0.993711, 0, -30.6376, 0.99852, 0.054383, 0, 119.503, -0.054383, 0.99852, 0, -31.6189)

[sub_resource type="Curve2D" id="Curve2D_ht7f6"]
[sub_resource type="Curve2D" id="Curve2D_41laa"]
resource_local_to_scene = true
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 2.08165e-12, 2.08165e-12, -23.902, -16.064, 23.902, 16.064, 64, 16, 0, 0, 0, 0, 128, 32)
}
point_count = 3

[sub_resource type="ArrayMesh" id="ArrayMesh_v08lw"]
_surfaces = [{
"2d": true,
"aabb": AABB(-1.5, -13.5, 0, 3.00001, 27, 0),
"attribute_data": PackedByteArray(0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0),
"format": 33558545,
"index_count": 6,
"index_data": PackedByteArray(3, 0, 0, 0, 1, 0, 1, 0, 2, 0, 3, 0),
"primitive": 3,
"vertex_count": 4,
"vertex_data": PackedByteArray(0, 0, 192, 63, 0, 0, 88, 65, 0, 0, 192, 191, 0, 0, 88, 65, 0, 0, 192, 191, 0, 0, 88, 193, 0, 0, 192, 63, 0, 0, 88, 193)
}]

[sub_resource type="MultiMesh" id="MultiMesh_uh3fl"]
[sub_resource type="MultiMesh" id="MultiMesh_pixd6"]
resource_local_to_scene = true
instance_count = 13
mesh = SubResource("ArrayMesh_v08lw")
mesh = SubResource("ArrayMesh_umy7o")
buffer = PackedFloat32Array(0.998161, -0.0606213, 0, 4.9967, 0.0606213, 0.998161, 0, 0.169378, 0.992717, -0.120468, 0, 14.9649, 0.120468, 0.992717, 0, 0.941638, 0.984055, -0.177863, 0, 24.8746, 0.177863, 0.984055, 0, 2.27142, 0.969439, -0.245334, 0, 34.6825, 0.245334, 0.969439, 0, 4.21167, 0.944761, -0.32776, 0, 44.323, 0.32776, 0.944761, 0, 6.85753, 0.90068, -0.434483, 0, 53.6727, 0.434483, 0.90068, 0, 10.3906, 0.845464, -0.534033, 0, 62.5102, 0.534033, 0.845464, 0, 15.0492, 0.909689, -0.415289, 0, 71.1239, 0.415289, 0.909689, 0, 20.116, 0.949047, -0.315133, 0, 80.3316, 0.315133, 0.949047, 0, 24.0021, 0.971927, -0.235281, 0, 89.8854, 0.235281, 0.971927, 0, 26.9434, 0.985684, -0.168601, 0, 99.6439, 0.168601, 0.985684, 0, 29.1182, 0.993824, -0.110965, 0, 109.523, 0.110965, 0.993824, 0, 30.6578, 0.998585, -0.0531809, 0, 119.475, 0.0531809, 0.998585, 0, 31.6286)

[sub_resource type="Theme" id="Theme_nwi6f"]
Expand All @@ -64,45 +52,29 @@ CheckButton/icons/unchecked = ExtResource("4_xc4rb")
[node name="TrackSwitch" type="Node2D"]
script = ExtResource("1_ucgph")

[node name="LeftTrack" type="Path2D" parent="."]
curve = SubResource("Curve2D_nxaiu")
script = ExtResource("2_mym28")

[node name="Crosstie" type="MeshInstance2D" parent="LeftTrack"]
visible = false
position = Vector2(-50, -50)
mesh = SubResource("ArrayMesh_hyu12")
texture = ExtResource("3_hpgfb")
[node name="LeftTrack" parent="." instance=ExtResource("2_e5vto")]
curve = SubResource("Curve2D_pk38d")

[node name="MultiMeshInstance2D" type="MultiMeshInstance2D" parent="LeftTrack"]
z_index = 1
multimesh = SubResource("MultiMesh_mjuev")
texture = ExtResource("3_hpgfb")
[node name="MultiMeshInstance2D" parent="LeftTrack" index="1"]
multimesh = SubResource("MultiMesh_m32f0")

[node name="HeadPoint" type="PathFollow2D" parent="LeftTrack"]
position = Vector2(2.08165e-12, 2.08165e-12)
[node name="HeadPoint" parent="LeftTrack" index="2"]
rotation = -0.244979
loop = false

[node name="TrackJunction" parent="LeftTrack/HeadPoint" instance=ExtResource("4_umyy3")]
parent = NodePath("../..")
side = 2
[node name="TrackJunction" parent="LeftTrack/HeadPoint" index="0"]
parent = NodePath("../../..")

[node name="TailPoint" type="PathFollow2D" parent="LeftTrack"]
[node name="TailPoint" parent="LeftTrack" index="3"]
position = Vector2(128, -32)
rotation = -0.244979
progress = 133.506
loop = false

[node name="TrackJunction" parent="LeftTrack/TailPoint" instance=ExtResource("4_umyy3")]
parent = NodePath("../..")
[node name="TrackJunction" parent="LeftTrack/TailPoint" index="0"]
parent = NodePath("../../..")
side = 0

[node name="TrackLine" type="Line2D" parent="LeftTrack"]
z_index = 2
[node name="TrackLine" parent="LeftTrack" index="4"]
points = PackedVector2Array(2.08165e-12, 2.08165e-12, 1.76493, -0.031045, 6.62261, -0.249297, 10.0063, -0.487274, 13.9174, -0.842432, 18.2738, -1.33823, 22.9936, -1.99813, 25.4642, -2.39694, 27.9949, -2.84558, 30.5755, -3.34697, 33.1957, -3.90405, 35.8452, -4.51975, 38.514, -5.197, 41.1916, -5.93874, 43.8678, -6.74789, 46.5325, -7.62739, 49.1753, -8.58017, 51.7861, -9.60917, 54.3545, -10.7173, 56.8703, -11.9075, 59.3234, -13.1828, 61.7033, -14.5459, 64, -16, 66.2967, -17.4541, 68.6766, -18.8172, 71.1297, -20.0925, 73.6455, -21.2827, 76.2139, -22.3908, 78.8247, -23.4198, 81.4675, -24.3726, 84.1322, -25.2521, 86.8084, -26.0613, 89.486, -26.803, 92.1548, -27.4802, 94.8044, -28.0959, 97.4245, -28.653, 100.005, -29.1544, 102.536, -29.6031, 105.006, -30.0019, 109.726, -30.6618, 114.083, -31.1576, 117.994, -31.5127, 121.377, -31.7507, 126.235, -31.969, 128, -32)
width = 20.0
texture = ExtResource("5_cqy4p")
texture_mode = 1

[node name="Pointer" type="PathFollow2D" parent="LeftTrack"]
visible = false
Expand All @@ -111,58 +83,41 @@ position = Vector2(64, -16)
rotation = -0.58782
progress = 66.7532

[node name="Sprite2D" type="Sprite2D" parent="LeftTrack/Pointer"]
[node name="Sprite" type="Sprite2D" parent="LeftTrack/Pointer"]
texture = ExtResource("6_nflxo")

[node name="RightTrack" type="Path2D" parent="."]
[node name="RightTrack" parent="." instance=ExtResource("2_e5vto")]
z_index = 1
curve = SubResource("Curve2D_ht7f6")
script = ExtResource("2_mym28")
curve = SubResource("Curve2D_41laa")

[node name="Crosstie" type="MeshInstance2D" parent="RightTrack"]
visible = false
position = Vector2(-50, -50)
mesh = SubResource("ArrayMesh_v08lw")
texture = ExtResource("3_hpgfb")
[node name="MultiMeshInstance2D" parent="RightTrack" index="1"]
multimesh = SubResource("MultiMesh_pixd6")

[node name="MultiMeshInstance2D" type="MultiMeshInstance2D" parent="RightTrack"]
z_index = 1
multimesh = SubResource("MultiMesh_uh3fl")
texture = ExtResource("3_hpgfb")

[node name="HeadPoint" type="PathFollow2D" parent="RightTrack"]
position = Vector2(2.08165e-12, 2.08165e-12)
[node name="HeadPoint" parent="RightTrack" index="2"]
rotation = 0.244979
loop = false

[node name="TrackJunction" parent="RightTrack/HeadPoint" instance=ExtResource("4_umyy3")]
parent = NodePath("../..")
side = 2
[node name="TrackJunction" parent="RightTrack/HeadPoint" index="0"]
parent = NodePath("../../..")

[node name="TailPoint" type="PathFollow2D" parent="RightTrack"]
[node name="TailPoint" parent="RightTrack" index="3"]
position = Vector2(128, 32)
rotation = 0.244979
progress = 133.535
loop = false

[node name="TrackJunction" parent="RightTrack/TailPoint" instance=ExtResource("4_umyy3")]
parent = NodePath("../..")
[node name="TrackJunction" parent="RightTrack/TailPoint" index="0"]
parent = NodePath("../../..")
side = 1

[node name="TrackLine" type="Line2D" parent="RightTrack"]
z_index = 2
[node name="TrackLine" parent="RightTrack" index="4"]
points = PackedVector2Array(2.08165e-12, 2.08165e-12, 1.76964, 0.028625, 6.63878, 0.241, 10.0295, 0.475391, 13.9477, 0.826875, 18.311, 1.31917, 23.0368, 1.976, 25.5098, 2.37353, 28.0427, 2.82108, 30.6249, 3.32162, 33.2462, 3.87813, 35.8963, 4.49355, 38.5649, 5.17086, 41.2417, 5.91302, 43.9163, 6.723, 46.5786, 7.60376, 49.218, 8.55827, 51.8245, 9.58948, 54.3875, 10.7004, 56.8969, 11.8939, 59.3423, 13.173, 61.7135, 14.5408, 64, 16, 66.2865, 17.4592, 68.6577, 18.827, 71.1031, 20.1061, 73.6125, 21.2996, 76.1756, 22.4105, 78.782, 23.4417, 81.4214, 24.3962, 84.0837, 25.277, 86.7583, 26.087, 89.4351, 26.8291, 92.1037, 27.5065, 94.7538, 28.1219, 97.3751, 28.6784, 99.9574, 29.1789, 102.49, 29.6265, 104.963, 30.024, 109.689, 30.6808, 114.052, 31.1731, 117.97, 31.5246, 121.361, 31.759, 126.23, 31.9714, 128, 32)
width = 20.0
texture = ExtResource("5_cqy4p")
texture_mode = 1

[node name="Pointer" type="PathFollow2D" parent="RightTrack"]
z_index = 2
position = Vector2(63.9881, 15.9924)
rotation = 0.591495
progress = 66.7532
position = Vector2(64, 16)
rotation = 0.591739
progress = 66.7674

[node name="Sprite2D" type="Sprite2D" parent="RightTrack/Pointer"]
[node name="Sprite" type="Sprite2D" parent="RightTrack/Pointer"]
texture = ExtResource("6_nflxo")

[node name="Button" type="CheckButton" parent="."]
Expand All @@ -179,4 +134,11 @@ keep_pressed_outside = true
shortcut_in_tooltip = false
metadata/_edit_use_anchors_ = true

[connection signal="wheel_at_head" from="LeftTrack" to="." method="_on_LeftTrack_wheel_at_head"]
[connection signal="wheel_at_tail" from="LeftTrack" to="." method="_on_LeftTrack_wheel_at_tail"]
[connection signal="wheel_at_head" from="RightTrack" to="." method="_on_RightTrack_wheel_at_head"]
[connection signal="wheel_at_tail" from="RightTrack" to="." method="_on_RightTrack_wheel_at_tail"]
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]

[editable path="LeftTrack"]
[editable path="RightTrack"]
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ brake={
[rendering]

textures/canvas_textures/default_texture_filter=0
environment/defaults/default_clear_color=Color(0.239216, 0.576471, 0.505882, 1)
Loading

0 comments on commit 4b3645e

Please sign in to comment.