Update and improve Truck Town for Godot 3.1.2

Conform to style guide
This commit is contained in:
Aaron Franke
2020-01-29 17:36:31 -05:00
parent 97f9632be4
commit 9c17c25343
9 changed files with 488 additions and 3386 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,10 +1,7 @@
extends Control
# Member variables
var town = null
func _back():
town.queue_free()
show()
@@ -20,13 +17,13 @@ func _load_scene(car):
hide()
func _on_van_1_pressed():
func _on_MiniVan_pressed():
_load_scene("res://car_base.tscn")
func _on_van_2_pressed():
func _on_TrailerTruck_pressed():
_load_scene("res://trailer_truck.tscn")
func _on_van_3_pressed():
_load_scene("res://crane.tscn")
func _on_TowTruck_pressed():
_load_scene("res://tow_truck.tscn")

View File

@@ -5,7 +5,7 @@
[ext_resource path="res://Images/choose_trailer.png" type="Texture" id=3]
[ext_resource path="res://Images/choose_tow.png" type="Texture" id=4]
[node name="base" type="Control"]
[node name="CarSelect" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
@@ -22,7 +22,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="van 1" type="Button" parent="."]
[node name="MiniVan" type="Button" parent="."]
margin_left = 4.0
margin_top = 160.0
margin_right = 340.0
@@ -31,7 +31,7 @@ size_flags_horizontal = 2
size_flags_vertical = 2
icon = ExtResource( 2 )
[node name="van 2" type="Button" parent="."]
[node name="TrailerTruck" type="Button" parent="."]
margin_left = 344.0
margin_top = 160.0
margin_right = 680.0
@@ -40,7 +40,7 @@ size_flags_horizontal = 2
size_flags_vertical = 2
icon = ExtResource( 3 )
[node name="van 3" type="Button" parent="."]
[node name="TowTruck" type="Button" parent="."]
margin_left = 684.0
margin_top = 160.0
margin_right = 1020.0
@@ -48,6 +48,6 @@ margin_bottom = 400.0
size_flags_horizontal = 2
size_flags_vertical = 2
icon = ExtResource( 4 )
[connection signal="pressed" from="van 1" to="." method="_on_van_1_pressed"]
[connection signal="pressed" from="van 2" to="." method="_on_van_2_pressed"]
[connection signal="pressed" from="van 3" to="." method="_on_van_3_pressed"]
[connection signal="pressed" from="MiniVan" to="." method="_on_MiniVan_pressed"]
[connection signal="pressed" from="TrailerTruck" to="." method="_on_TrailerTruck_pressed"]
[connection signal="pressed" from="TowTruck" to="." method="_on_TowTruck_pressed"]

View File

@@ -1,50 +1,42 @@
extends Camera
# Member variables
var collision_exception = []
export var min_distance = 0.5
export var max_distance = 4.0
export var angle_v_adjust = 0.0
export var autoturn_ray_aperture = 25
export var autoturn_speed = 50
var max_height = 2.0
var min_height = 0
func _physics_process(dt):
func _physics_process(_delta):
var target = get_parent().get_global_transform().origin
var pos = get_global_transform().origin
var up = Vector3(0, 1, 0)
var delta = pos - target
var from_target = pos - target
# Regular delta follow
# Check ranges.
if from_target.length() < min_distance:
from_target = from_target.normalized() * min_distance
elif from_target.length() > max_distance:
from_target = from_target.normalized() * max_distance
# Check ranges
if (delta.length() < min_distance):
delta = delta.normalized()*min_distance
elif (delta.length() > max_distance):
delta = delta.normalized()*max_distance
# Check upper and lower height.
if from_target.y > max_height:
from_target.y = max_height
if from_target.y < min_height:
from_target.y = min_height
# Check upper and lower height
if ( delta.y > max_height):
delta.y = max_height
if ( delta.y < min_height):
delta.y = min_height
pos = target + from_target
pos = target + delta
look_at_from_position(pos, target, up)
look_at_from_position(pos, target, Vector3.UP)
# Turn a little up or down
var t = get_transform()
t.basis = Basis(t.basis[0], deg2rad(angle_v_adjust))*t.basis
t.basis = Basis(t.basis[0], deg2rad(angle_v_adjust)) * t.basis
set_transform(t)
func _ready():
# Find collision exceptions for ray
# Find collision exceptions for ray.
var node = self
while(node):
if (node is RigidBody):
@@ -53,5 +45,5 @@ func _ready():
else:
node = node.get_parent()
# This detaches the camera transform from the parent spatial node
# This detaches the camera transform from the parent spatial node.
set_as_toplevel(true)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,66 +1,21 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://trucktown.tscn" type="PackedScene" id=1]
[ext_resource path="res://town_mesh.tscn" type="PackedScene" id=1]
[node name="town_scene" type="Spatial" index="0"]
[node name="TownScene" type="Spatial"]
[node name="Truck_Town" parent="." index="0" instance=ExtResource( 1 )]
[node name="instance_pos" type="Position3D" parent="." index="1"]
[node name="TownMesh" parent="." instance=ExtResource( 1 )]
[node name="instance_pos" type="Position3D" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.2039, 6.67095, -37.6042 )
_sections_unfolded = [ "Transform" ]
[node name="back" type="Button" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="back" type="Button" parent="."]
margin_left = 17.0
margin_top = 9.0
margin_right = 85.0
margin_bottom = 41.0
rect_pivot_offset = Vector2( 0, 0 )
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "<- Back!"
flat = false
align = 1
[node name="DirectionalLight" type="DirectionalLight" parent="." index="3"]
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, -0.629475, 0.777021, 0, -0.777021, -0.629475, 0, 24.4076, 0 )
layers = 1
light_color = Color( 1, 1, 1, 1 )
light_energy = 1.0
light_indirect_energy = 1.0
light_negative = false
light_specular = 0.5
light_bake_mode = 1
light_cull_mask = -1
shadow_enabled = true
shadow_color = Color( 0, 0, 0, 1 )
shadow_bias = 0.1
shadow_contact = 0.0
shadow_reverse_cull_face = false
editor_only = false
directional_shadow_mode = 2
directional_shadow_split_1 = 0.1
directional_shadow_split_2 = 0.2
directional_shadow_split_3 = 0.5
directional_shadow_blend_splits = false
directional_shadow_normal_bias = 0.8
directional_shadow_bias_split_scale = 0.25
directional_shadow_depth_range = 0
directional_shadow_max_distance = 200.0
_sections_unfolded = [ "Shadow" ]

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,5 @@
extends VehicleBody
# Member variables
const STEER_SPEED = 1
const STEER_LIMIT = 0.4