Skip to content

Commit 9c17c25

Browse files
committed
Update and improve Truck Town for Godot 3.1.2
Conform to style guide
1 parent 97f9632 commit 9c17c25

File tree

9 files changed

+525
-3423
lines changed

9 files changed

+525
-3423
lines changed

3d/truck_town/car_base.tscn

Lines changed: 31 additions & 173 deletions
Large diffs are not rendered by default.

3d/truck_town/car_select.gd

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
21
extends Control
32

4-
# Member variables
53
var town = null
64

7-
85
func _back():
96
town.queue_free()
107
show()
@@ -20,13 +17,13 @@ func _load_scene(car):
2017
hide()
2118

2219

23-
func _on_van_1_pressed():
20+
func _on_MiniVan_pressed():
2421
_load_scene("res://car_base.tscn")
2522

2623

27-
func _on_van_2_pressed():
24+
func _on_TrailerTruck_pressed():
2825
_load_scene("res://trailer_truck.tscn")
2926

3027

31-
func _on_van_3_pressed():
32-
_load_scene("res://crane.tscn")
28+
func _on_TowTruck_pressed():
29+
_load_scene("res://tow_truck.tscn")

3d/truck_town/car_select.tscn

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[ext_resource path="res://Images/choose_trailer.png" type="Texture" id=3]
66
[ext_resource path="res://Images/choose_tow.png" type="Texture" id=4]
77

8-
[node name="base" type="Control"]
8+
[node name="CarSelect" type="Control"]
99
anchor_left = 0.5
1010
anchor_top = 0.5
1111
anchor_right = 0.5
@@ -22,7 +22,7 @@ __meta__ = {
2222
"_edit_use_anchors_": false
2323
}
2424

25-
[node name="van 1" type="Button" parent="."]
25+
[node name="MiniVan" type="Button" parent="."]
2626
margin_left = 4.0
2727
margin_top = 160.0
2828
margin_right = 340.0
@@ -31,7 +31,7 @@ size_flags_horizontal = 2
3131
size_flags_vertical = 2
3232
icon = ExtResource( 2 )
3333

34-
[node name="van 2" type="Button" parent="."]
34+
[node name="TrailerTruck" type="Button" parent="."]
3535
margin_left = 344.0
3636
margin_top = 160.0
3737
margin_right = 680.0
@@ -40,14 +40,14 @@ size_flags_horizontal = 2
4040
size_flags_vertical = 2
4141
icon = ExtResource( 3 )
4242

43-
[node name="van 3" type="Button" parent="."]
43+
[node name="TowTruck" type="Button" parent="."]
4444
margin_left = 684.0
4545
margin_top = 160.0
4646
margin_right = 1020.0
4747
margin_bottom = 400.0
4848
size_flags_horizontal = 2
4949
size_flags_vertical = 2
5050
icon = ExtResource( 4 )
51-
[connection signal="pressed" from="van 1" to="." method="_on_van_1_pressed"]
52-
[connection signal="pressed" from="van 2" to="." method="_on_van_2_pressed"]
53-
[connection signal="pressed" from="van 3" to="." method="_on_van_3_pressed"]
51+
[connection signal="pressed" from="MiniVan" to="." method="_on_MiniVan_pressed"]
52+
[connection signal="pressed" from="TrailerTruck" to="." method="_on_TrailerTruck_pressed"]
53+
[connection signal="pressed" from="TowTruck" to="." method="_on_TowTruck_pressed"]

3d/truck_town/follow_camera.gd

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
1-
21
extends Camera
32

4-
# Member variables
53
var collision_exception = []
64
export var min_distance = 0.5
75
export var max_distance = 4.0
86
export var angle_v_adjust = 0.0
9-
export var autoturn_ray_aperture = 25
10-
export var autoturn_speed = 50
117
var max_height = 2.0
128
var min_height = 0
139

14-
15-
func _physics_process(dt):
10+
func _physics_process(_delta):
1611
var target = get_parent().get_global_transform().origin
1712
var pos = get_global_transform().origin
18-
var up = Vector3(0, 1, 0)
19-
20-
var delta = pos - target
2113

22-
# Regular delta follow
14+
var from_target = pos - target
2315

24-
# Check ranges
25-
if (delta.length() < min_distance):
26-
delta = delta.normalized()*min_distance
27-
elif (delta.length() > max_distance):
28-
delta = delta.normalized()*max_distance
16+
# Check ranges.
17+
if from_target.length() < min_distance:
18+
from_target = from_target.normalized() * min_distance
19+
elif from_target.length() > max_distance:
20+
from_target = from_target.normalized() * max_distance
2921

30-
# Check upper and lower height
31-
if ( delta.y > max_height):
32-
delta.y = max_height
33-
if ( delta.y < min_height):
34-
delta.y = min_height
22+
# Check upper and lower height.
23+
if from_target.y > max_height:
24+
from_target.y = max_height
25+
if from_target.y < min_height:
26+
from_target.y = min_height
3527

36-
pos = target + delta
28+
pos = target + from_target
3729

38-
look_at_from_position(pos, target, up)
30+
look_at_from_position(pos, target, Vector3.UP)
3931

4032
# Turn a little up or down
4133
var t = get_transform()
42-
t.basis = Basis(t.basis[0], deg2rad(angle_v_adjust))*t.basis
34+
t.basis = Basis(t.basis[0], deg2rad(angle_v_adjust)) * t.basis
4335
set_transform(t)
4436

4537

4638
func _ready():
47-
# Find collision exceptions for ray
39+
# Find collision exceptions for ray.
4840
var node = self
4941
while(node):
5042
if (node is RigidBody):
@@ -53,5 +45,5 @@ func _ready():
5345
else:
5446
node = node.get_parent()
5547

56-
# This detaches the camera transform from the parent spatial node
48+
# This detaches the camera transform from the parent spatial node.
5749
set_as_toplevel(true)

3d/truck_town/crane.tscn renamed to 3d/truck_town/tow_truck.tscn

Lines changed: 132 additions & 716 deletions
Large diffs are not rendered by default.

3d/truck_town/trucktown.tscn renamed to 3d/truck_town/town_mesh.tscn

Lines changed: 257 additions & 2000 deletions
Large diffs are not rendered by default.

3d/truck_town/town_scene.tscn

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,21 @@
11
[gd_scene load_steps=2 format=2]
22

3-
[ext_resource path="res://trucktown.tscn" type="PackedScene" id=1]
3+
[ext_resource path="res://town_mesh.tscn" type="PackedScene" id=1]
44

5-
[node name="town_scene" type="Spatial" index="0"]
5+
[node name="TownScene" type="Spatial"]
66

7-
[node name="Truck_Town" parent="." index="0" instance=ExtResource( 1 )]
8-
9-
[node name="instance_pos" type="Position3D" parent="." index="1"]
7+
[node name="TownMesh" parent="." instance=ExtResource( 1 )]
108

9+
[node name="instance_pos" type="Position3D" parent="."]
1110
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.2039, 6.67095, -37.6042 )
12-
_sections_unfolded = [ "Transform" ]
13-
14-
[node name="back" type="Button" parent="." index="2"]
1511

16-
anchor_left = 0.0
17-
anchor_top = 0.0
18-
anchor_right = 0.0
19-
anchor_bottom = 0.0
12+
[node name="back" type="Button" parent="."]
2013
margin_left = 17.0
2114
margin_top = 9.0
2215
margin_right = 85.0
2316
margin_bottom = 41.0
24-
rect_pivot_offset = Vector2( 0, 0 )
25-
focus_mode = 2
26-
mouse_filter = 0
27-
mouse_default_cursor_shape = 0
28-
size_flags_horizontal = 1
29-
size_flags_vertical = 1
30-
toggle_mode = false
31-
enabled_focus_mode = 2
32-
shortcut = null
33-
group = null
3417
text = "<- Back!"
35-
flat = false
36-
align = 1
37-
38-
[node name="DirectionalLight" type="DirectionalLight" parent="." index="3"]
3918

19+
[node name="DirectionalLight" type="DirectionalLight" parent="."]
4020
transform = Transform( 1, 0, 0, 0, -0.629475, 0.777021, 0, -0.777021, -0.629475, 0, 24.4076, 0 )
41-
layers = 1
42-
light_color = Color( 1, 1, 1, 1 )
43-
light_energy = 1.0
44-
light_indirect_energy = 1.0
45-
light_negative = false
46-
light_specular = 0.5
47-
light_bake_mode = 1
48-
light_cull_mask = -1
4921
shadow_enabled = true
50-
shadow_color = Color( 0, 0, 0, 1 )
51-
shadow_bias = 0.1
52-
shadow_contact = 0.0
53-
shadow_reverse_cull_face = false
54-
editor_only = false
55-
directional_shadow_mode = 2
56-
directional_shadow_split_1 = 0.1
57-
directional_shadow_split_2 = 0.2
58-
directional_shadow_split_3 = 0.5
59-
directional_shadow_blend_splits = false
60-
directional_shadow_normal_bias = 0.8
61-
directional_shadow_bias_split_scale = 0.25
62-
directional_shadow_depth_range = 0
63-
directional_shadow_max_distance = 200.0
64-
_sections_unfolded = [ "Shadow" ]
65-
66-

0 commit comments

Comments
 (0)