small racing game im working on
texture skids [skip ci]
bendn 2023-03-04
parent c30ee77 · commit 883c5d2
-rw-r--r--assets/mats/outline.tres2
-rw-r--r--assets/textures/road.pngbin549 -> 122 bytes
-rw-r--r--assets/textures/slide.pngbin0 -> 96 bytes
-rw-r--r--assets/textures/slide.png.import34
-rw-r--r--classes/car.gd9
-rw-r--r--project.godot2
-rw-r--r--race.gd2
-rw-r--r--scenes/track.tscn5
-rw-r--r--scenes/trail.tscn9
9 files changed, 53 insertions, 10 deletions
diff --git a/assets/mats/outline.tres b/assets/mats/outline.tres
index 6181d52..e516864 100644
--- a/assets/mats/outline.tres
+++ b/assets/mats/outline.tres
@@ -4,6 +4,6 @@
cull_mode = 1
shading_mode = 0
albedo_color = Color(0, 0, 0, 1)
-texture_filter = 0
+disable_receive_shadows = true
grow = true
grow_amount = 2.0
diff --git a/assets/textures/road.png b/assets/textures/road.png
index 72c4efd..c8c80df 100644
--- a/assets/textures/road.png
+++ b/assets/textures/road.png
Binary files differ
diff --git a/assets/textures/slide.png b/assets/textures/slide.png
new file mode 100644
index 0000000..116adf4
--- /dev/null
+++ b/assets/textures/slide.png
Binary files differ
diff --git a/assets/textures/slide.png.import b/assets/textures/slide.png.import
new file mode 100644
index 0000000..9e6686a
--- /dev/null
+++ b/assets/textures/slide.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://b5uvv50vmoxiu"
+path="res://.godot/imported/slide.png-0689bccce15322ea50215856956f0314.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://assets/textures/slide.png"
+dest_files=["res://.godot/imported/slide.png-0689bccce15322ea50215856956f0314.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=0
diff --git a/classes/car.gd b/classes/car.gd
index 30fa613..d094976 100644
--- a/classes/car.gd
+++ b/classes/car.gd
@@ -29,7 +29,6 @@ var gear_timer := 0.0
var throttle := 0.0
var skids: Array[Array]
-
func ratio() -> float:
match current_gear:
0: return 0
@@ -124,17 +123,15 @@ func _physics_process(delta: float):
limit(delta)
for i in 4:
- particles[i].emitting = wheels[i].get_skidinfo() < (.2 if i > 2 else .8) and wheels[i].is_in_contact() and kph() > 30
+ particles[i].emitting = wheels[i].get_skidinfo() < (.2 if i > 2 else .99) and wheels[i].is_in_contact() and kph() > 30
if particles[i].emitting:
- particles[i].amount = ceil(100 * (1 - wheels[i].get_skidinfo()))
+ particles[i].amount = clampf(ceil(150 * (1 - wheels[i].get_skidinfo())) * 1 if i > 2 else 8, 0, 150)
var init := false
if !skids[i][-1].active:
init = true
skids[i].append(trail_scene.instantiate() as Trail3D)
get_parent().add_child(skids[i][-1])
- (skids[i][-1] as Trail3D).add(wheels[i].global_position - Vector3(0, .661, 0))
- if not init and Engine.get_physics_frames() % 4 == 0:
- (skids[i][-1] as Trail3D).add(wheels[i].global_position - Vector3(0, .661, 0))
+ (skids[i][-1] as Trail3D).add(wheels[i].global_position - Vector3(0, .661, 0))
elif skids[i][-1].active:
skids[i][-1].active = false
diff --git a/project.godot b/project.godot
index 36788a0..2f0a20d 100644
--- a/project.godot
+++ b/project.godot
@@ -135,6 +135,8 @@ renderer/rendering_method="gl_compatibility"
lights_and_shadows/directional_shadow/size=2048
lights_and_shadows/directional_shadow/size.mobile=1024
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=1
+reflections/sky_reflections/ggx_samples=16
+reflections/sky_reflections/ggx_samples.mobile=8
anti_aliasing/quality/msaa_2d=2
anti_aliasing/quality/msaa_3d=2
anti_aliasing/quality/screen_space_aa=1
diff --git a/race.gd b/race.gd
index a775d40..a3ecf55 100644
--- a/race.gd
+++ b/race.gd
@@ -112,7 +112,7 @@ func passed_finish() -> void:
car.reset()
if not best_time_data or data.time < best_time_data.time:
print("new pb!")
- finished.emit(data.time, best_time_data.time if best_time_data else -1)
+ finished.emit(data.time, best_time_data.time if best_time_data else -1.0)
data.save(saves % track_res.name)
best_time_data = data
else:
diff --git a/scenes/track.tscn b/scenes/track.tscn
index db51c13..4fc2fd6 100644
--- a/scenes/track.tscn
+++ b/scenes/track.tscn
@@ -17,6 +17,7 @@ track = ExtResource("3_cdqtb")
metadata/_edit_group_ = true
[node name="Road" type="CSGPolygon3D" parent="."]
+calculate_tangents = false
polygon = PackedVector2Array(-20, 0, -20, -0.1, 20, -0.1, 20, 0)
mode = 2
path_node = NodePath("..")
@@ -31,6 +32,7 @@ path_joined = true
material = ExtResource("2_2nntu")
[node name="Rail-L" type="CSGPolygon3D" parent="."]
+calculate_tangents = false
polygon = PackedVector2Array(23, 0.5, 22.95, 0.47, 22.95, 0.43, 23, 0.4, 23, 0.55, 22.95, 0.32, 22.95, 0.28, 23, 0.25, 23.05, 0.25, 23.05, 0.5)
mode = 2
path_node = NodePath("..")
@@ -45,6 +47,7 @@ path_joined = true
material = ExtResource("2_3pcob")
[node name="Rail-R" type="CSGPolygon3D" parent="."]
+calculate_tangents = false
polygon = PackedVector2Array(-23, 0.5, -22.95, 0.47, -22.95, 0.43, -23, 0.4, -23, 0.55, -22.95, 0.32, -22.95, 0.28, -23, 0.25, -23.05, 0.25, -23.05, 0.5)
mode = 2
path_node = NodePath("..")
@@ -87,7 +90,9 @@ camera_attributes = ExtResource("9_6ooo5")
[node name="CollisionShape" type="CSGPolygon3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.165113, 0)
visible = false
+calculate_tangents = false
use_collision = true
+collision_mask = 0
polygon = PackedVector2Array(-23, 0, 23, 0, 23, 5, 26, 5, 26, -1, -26, -1, -26, 5, -23, 5)
mode = 2
path_node = NodePath("..")
diff --git a/scenes/trail.tscn b/scenes/trail.tscn
index 90f225e..a7fc4af 100644
--- a/scenes/trail.tscn
+++ b/scenes/trail.tscn
@@ -1,12 +1,16 @@
-[gd_scene load_steps=3 format=3 uid="uid://1ubjbdg0envl"]
+[gd_scene load_steps=4 format=3 uid="uid://1ubjbdg0envl"]
[ext_resource type="Script" path="res://scenes/trail.gd" id="1_xpxgt"]
+[ext_resource type="Texture2D" uid="uid://b5uvv50vmoxiu" path="res://assets/textures/slide.png" id="2_cw5i2"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qgr6r"]
transparency = 1
cull_mode = 1
shading_mode = 0
-albedo_color = Color(0.188235, 0.188235, 0.188235, 0.517647)
+albedo_color = Color(1, 1, 1, 0.737255)
+albedo_texture = ExtResource("2_cw5i2")
+uv1_scale = Vector3(8, 8, 8)
+texture_filter = 0
disable_receive_shadows = true
[node name="trail" type="Path3D"]
@@ -15,6 +19,7 @@ script = ExtResource("1_xpxgt")
[node name="trail" type="CSGPolygon3D" parent="."]
cast_shadow = 0
+calculate_tangents = false
polygon = PackedVector2Array(0, 0, 0, 0, 0.5, 0, 0.5, 0)
mode = 2
path_node = NodePath("..")