small racing game im working on
make finish scene better [skip ci]
bendn 2023-03-04
parent e6bbe00 · commit c30ee77
-rw-r--r--classes/car.gd3
-rw-r--r--project.godot1
-rw-r--r--race.gd7
-rw-r--r--scenes/race_highlevel.gd2
-rw-r--r--start.tscn2
-rw-r--r--ui/assets/wide_button_focus.styleboxbin465 -> 488 bytes
-rw-r--r--ui/finish.gd7
-rw-r--r--ui/finish.tscn129
-rw-r--r--ui/hud.tscn11
-rw-r--r--ui/splits/splits.tres4
-rw-r--r--ui/splits/splits.tscn2
-rw-r--r--ui/theme.tres5
-rw-r--r--ui/ubuntu.tres4
-rw-r--r--ui/ubuntu_mononf.tres5
14 files changed, 147 insertions, 35 deletions
diff --git a/classes/car.gd b/classes/car.gd
index 9a8b8c0..30fa613 100644
--- a/classes/car.gd
+++ b/classes/car.gd
@@ -46,6 +46,9 @@ func is_not_on_ground() -> bool:
return wheels.any(func(whl: VehicleWheel3D): return !whl.is_in_contact())
func reset() -> void:
+ steering = 0
+ throttle = 0
+ engine_force = 0
brake = 15
set_physics_process(false)
diff --git a/project.godot b/project.godot
index 9286dea..36788a0 100644
--- a/project.godot
+++ b/project.godot
@@ -135,6 +135,7 @@ 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
+anti_aliasing/quality/msaa_2d=2
anti_aliasing/quality/msaa_3d=2
anti_aliasing/quality/screen_space_aa=1
textures/canvas_textures/default_texture_filter=0
diff --git a/race.gd b/race.gd
index 0b9c551..a775d40 100644
--- a/race.gd
+++ b/race.gd
@@ -51,11 +51,9 @@ func reset_car() -> void:
await get_tree().physics_frame
car.rotation = track.start_rot + Vector3(0, PI, -PI/2)
car.global_position = track.start_pos + Vector3(0, 2, 0) - (car.global_transform.basis.z * 2) # bump forward a teensy bit
- car.engine_force = 0
- car.current_gear = 0
car.linear_velocity = Vector3.ZERO
car.angular_velocity = Vector3.ZERO
- car.steering = 0
+ car.current_gear = 0
for p in car.particles:
p.emitting = false
car.reset()
@@ -108,9 +106,10 @@ func passed_finish() -> void:
return
collect(-1)
if track_res.laps - 1 == current_lap:
- playing = false
print("finished")
+ playing = false
timer.stop()
+ 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)
diff --git a/scenes/race_highlevel.gd b/scenes/race_highlevel.gd
index aefead5..c9128ff 100644
--- a/scenes/race_highlevel.gd
+++ b/scenes/race_highlevel.gd
@@ -38,13 +38,13 @@ func add_player() -> void:
race.did_reset.connect(c_cam.reset)
race.did_reset.connect(hud.laps.reset)
race.finished.connect(func(t: float, p_t: float):
-# get_tree().paussed = true
var finish: FinishUI = finish_scene.instantiate()
hud.add_child(finish)
finish.set_time(t, p_t)
finish.retry.connect(func():
race.reset()
finish.queue_free()
+ get_tree().paused = false
)
)
diff --git a/start.tscn b/start.tscn
index 4452fb0..4c1fc19 100644
--- a/start.tscn
+++ b/start.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=3 uid="uid://bvfqaoqjsxj73"]
-[ext_resource type="Theme" uid="uid://ecnruuyrc8m" path="res://ui/theme.tres" id="1_gm0ws"]
+[ext_resource type="Theme" path="res://ui/theme.tres" id="1_gm0ws"]
[ext_resource type="Script" path="res://ui/tracks.gd" id="2_po2ce"]
[ext_resource type="Resource" uid="uid://crye0ijvmtsyb" path="res://tracks/multilap_test.tres" id="3_0yjp1"]
[ext_resource type="Resource" uid="uid://de46bcu1ivmtq" path="res://tracks/test.tres" id="4_3xqvr"]
diff --git a/ui/assets/wide_button_focus.stylebox b/ui/assets/wide_button_focus.stylebox
index e7200a4..e1e2dda 100644
--- a/ui/assets/wide_button_focus.stylebox
+++ b/ui/assets/wide_button_focus.stylebox
Binary files differ
diff --git a/ui/finish.gd b/ui/finish.gd
index b34ea64..dc65b6d 100644
--- a/ui/finish.gd
+++ b/ui/finish.gd
@@ -9,17 +9,18 @@ class_name FinishUI
signal retry
signal next
signal quit
-signal difference(diff: SplitsDifference.Change)
+signal difference(diff: int)
func set_time(time: float, prev_time: float):
time_.text = GameTimer.format_precise(time)
- if prev_time < 0 or SplitsDifference.diff(time, prev_time) == SplitsDifference.Change.EQUAL:
+ var d := SplitsDifference.diff(time, prev_time)
+ if prev_time < 0 or d == SplitsDifference.Change.EQUAL:
diff.hide()
flag.text = "󰈻"
flag.vertical_alignment = VERTICAL_ALIGNMENT_TOP
+ difference.emit(-1 if prev_time < 0 else d)
else:
flag.vertical_alignment = VERTICAL_ALIGNMENT_BOTTOM
- var d := SplitsDifference.diff(time, prev_time);
match d:
SplitsDifference.Change.LOSS: flag.text = "󰮙"
SplitsDifference.Change.GAIN: flag.text = "󰮚"
diff --git a/ui/finish.tscn b/ui/finish.tscn
index 0af021a..fe17bbb 100644
--- a/ui/finish.tscn
+++ b/ui/finish.tscn
@@ -1,22 +1,18 @@
-[gd_scene load_steps=12 format=3 uid="uid://cr1mgp6bgxh64"]
+[gd_scene load_steps=16 format=3 uid="uid://cr1mgp6bgxh64"]
-[ext_resource type="Theme" uid="uid://ecnruuyrc8m" path="res://ui/theme.tres" id="1_aykd4"]
+[ext_resource type="Theme" path="res://ui/theme.tres" id="1_aykd4"]
[ext_resource type="Script" path="res://ui/finish.gd" id="1_crs2w"]
[ext_resource type="Script" path="res://ui/diff.gd" id="2_gtres"]
[ext_resource type="StyleBox" uid="uid://bxi4jeh5lf468" path="res://ui/assets/wide_button_focus.stylebox" id="4_dck0l"]
+[ext_resource type="SystemFont" uid="uid://bkjqtc5i64r3j" path="res://ui/ubuntu.tres" id="5_llemr"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bgqa0"]
bg_color = Color(0.027451, 0.211765, 0.258824, 1)
-border_width_left = 10
-border_width_top = 10
-border_width_right = 10
-border_width_bottom = 10
-border_color = Color(0.513726, 0.580392, 0.588235, 1)
-corner_radius_top_left = 150
-corner_radius_top_right = 150
-corner_radius_bottom_right = 150
-corner_radius_bottom_left = 150
-corner_detail = 18
+corner_radius_top_left = 100
+corner_radius_top_right = 100
+corner_radius_bottom_right = 100
+corner_radius_bottom_left = 100
+anti_aliasing = false
anti_aliasing_size = 1.0
[sub_resource type="LabelSettings" id="LabelSettings_f3a8x"]
@@ -25,6 +21,9 @@ font_size = 200
font_color = Color(0.933333, 0.909804, 0.835294, 1)
outline_size = 25
outline_color = Color(0.25098, 0.25098, 0.25098, 1)
+shadow_size = 20
+shadow_color = Color(0, 0, 0, 0.392157)
+shadow_offset = Vector2(10, 10)
[sub_resource type="SystemFont" id="SystemFont_0mxmp"]
font_names = PackedStringArray("Cascadia Code")
@@ -35,6 +34,9 @@ oversampling = 5.0
font = SubResource("SystemFont_0mxmp")
font_size = 100
font_color = Color(0.992157, 0.964706, 0.890196, 1)
+shadow_size = 20
+shadow_color = Color(0, 0, 0, 0.27451)
+shadow_offset = Vector2(5, 10)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_22wem"]
content_margin_left = 250.0
@@ -42,7 +44,10 @@ content_margin_left = 250.0
[sub_resource type="LabelSettings" id="LabelSettings_irfee"]
font = SubResource("SystemFont_0mxmp")
font_size = 50
-font_color = Color(0.921569, 0.32549, 0.317647, 1)
+font_color = Color(0.521569, 0.6, 0, 1)
+shadow_size = 12
+shadow_color = Color(0, 0, 0, 0.27451)
+shadow_offset = Vector2(2, 5)
[sub_resource type="GDScript" id="GDScript_ihn3u"]
resource_name = "retry_button"
@@ -52,8 +57,81 @@ func _on_finish_difference(diff: SplitsDifference.Change) -> void:
match diff:
SplitsDifference.Change.GAIN: text = \"play again\"
SplitsDifference.Change.LOSS: text = \"try again\"
+ _: text = \"play again\"
"
+[sub_resource type="LabelSettings" id="LabelSettings_uqsxe"]
+font = ExtResource("5_llemr")
+font_size = 25
+font_color = Color(0.992157, 0.964706, 0.890196, 1)
+shadow_size = 4
+shadow_color = Color(0.168627, 0.168627, 0.168627, 0.568627)
+
+[sub_resource type="GDScript" id="GDScript_fnuhm"]
+resource_name = "helpfull"
+script/source = "extends Label
+
+var db := {
+ SplitsDifference.Change.GAIN: PackedStringArray([
+ \"nice time\",
+ \"great job\",
+ \"groundbreaking time\",
+ \"couldnt do better myself\",
+ \"motivational message\",
+ \"see you on the next map\",
+ \"that corner was perfect\",
+ \"such speed\"
+ ]),
+ SplitsDifference.Change.LOSS:
+ PackedStringArray([
+ \"theres always next time\",
+ \"maybe take that corner tighter\", # i love it when the game backseats me
+ \"if you take that turn wider youll get more speed\",
+ \"that corner was rough\",
+ \"too much speed, eh\",
+ \"i hate it when things go wrong for a inexplicable reason\",
+ \"better luck next time\",
+ \"the great thing about video games is you can try again\",
+ \"sad times\",
+ \"wow, thats a good ghost\"
+ ]),
+ SplitsDifference.Change.EQUAL:
+ PackedStringArray([
+ \"wow, you matched that time\",
+ \"1/100 moment\",
+ \"get the camera, the time was matched\",
+ \"its not even like theres a deterministic physics engine\"
+ ]),
+ -1:
+ PackedStringArray([
+ \"good first try\",
+ \"a decent attempt\",
+ \"wr pace next attempt\",
+ \"hard map innit\",
+ \"are you going to go again\"
+ ])
+
+}
+
+
+func _on_finish_difference(diff) -> void:
+ text = db[diff][randi() % len(db[diff])]
+"
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hc6gh"]
+bg_color = Color(0.6, 0.6, 0.6, 0)
+border_width_left = 5
+border_width_top = 5
+border_width_right = 5
+border_width_bottom = 5
+border_color = Color(0.576471, 0.631373, 0.631373, 1)
+corner_radius_top_left = 100
+corner_radius_top_right = 100
+corner_radius_bottom_right = 100
+corner_radius_bottom_left = 100
+corner_detail = 12
+anti_aliasing = false
+
[node name="finish" type="ColorRect" node_paths=PackedStringArray("diff", "time_", "flag", "focus")]
anchors_preset = 15
anchor_right = 1.0
@@ -77,7 +155,8 @@ grow_horizontal = 2
grow_vertical = 2
[node name="panel" type="PanelContainer" parent="center"]
-custom_minimum_size = Vector2(1280, 720)
+clip_children = 2
+custom_minimum_size = Vector2(1000, 0)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_bgqa0")
@@ -111,22 +190,23 @@ label_settings = SubResource("LabelSettings_m62vt")
[node name="diff" type="Label" parent="center/panel/container/splits"]
layout_mode = 2
theme_override_styles/normal = SubResource("StyleBoxEmpty_22wem")
-text = "+0:00.125"
+text = "-0:00.125"
label_settings = SubResource("LabelSettings_irfee")
script = ExtResource("2_gtres")
gain_color = Color(0.521569, 0.6, 0, 1)
loss_color = Color(0.921569, 0.32549, 0.317647, 1)
[node name="spacer" type="Control" parent="center/panel/container"]
-custom_minimum_size = Vector2(0, 70)
+custom_minimum_size = Vector2(0, 20)
layout_mode = 2
[node name="buttons" type="VBoxContainer" parent="center/panel/container"]
layout_mode = 2
-theme_override_constants/separation = 0
+theme_override_constants/separation = 5
[node name="retry" type="Button" parent="center/panel/container/buttons"]
layout_mode = 2
+tooltip_text = "go for another go?"
theme_override_styles/focus = ExtResource("4_dck0l")
text = "play again"
script = SubResource("GDScript_ihn3u")
@@ -141,7 +221,22 @@ layout_mode = 2
theme_override_styles/focus = ExtResource("4_dck0l")
text = "exit"
+[node name="helpfull" type="Label" parent="center/panel/container"]
+custom_minimum_size = Vector2(0, 40)
+layout_mode = 2
+text = "hi"
+label_settings = SubResource("LabelSettings_uqsxe")
+horizontal_alignment = 1
+vertical_alignment = 1
+script = SubResource("GDScript_fnuhm")
+
+[node name="border" type="Panel" parent="center/panel"]
+layout_mode = 2
+mouse_filter = 2
+theme_override_styles/panel = SubResource("StyleBoxFlat_hc6gh")
+
[connection signal="difference" from="." to="center/panel/container/buttons/retry" method="_on_finish_difference"]
+[connection signal="difference" from="." to="center/panel/container/helpfull" method="_on_finish_difference"]
[connection signal="pressed" from="center/panel/container/buttons/retry" to="." method="emit_signal" binds= [&"retry"]]
[connection signal="pressed" from="center/panel/container/buttons/next" to="." method="emit_signal" binds= [&"next"]]
[connection signal="pressed" from="center/panel/container/buttons/quit" to="." method="emit_signal" binds= [&"quit"]]
diff --git a/ui/hud.tscn b/ui/hud.tscn
index 5b8387c..119f8be 100644
--- a/ui/hud.tscn
+++ b/ui/hud.tscn
@@ -1,10 +1,11 @@
-[gd_scene load_steps=17 format=3 uid="uid://vok7fdcyec68"]
+[gd_scene load_steps=18 format=3 uid="uid://vok7fdcyec68"]
-[ext_resource type="Theme" uid="uid://ecnruuyrc8m" path="res://ui/theme.tres" id="1_ie2j2"]
+[ext_resource type="Theme" path="res://ui/theme.tres" id="1_ie2j2"]
[ext_resource type="Script" path="res://ui/hud.gd" id="1_sfhpc"]
[ext_resource type="Script" path="res://ui/speedometer.gd" id="2_cvi37"]
[ext_resource type="Script" path="res://ui/timer.gd" id="3_poksb"]
[ext_resource type="Texture2D" uid="uid://bfe4ytl0vjosb" path="res://ui/assets/line.png" id="4_o0swd"]
+[ext_resource type="SystemFont" uid="uid://bkjqtc5i64r3j" path="res://ui/ubuntu.tres" id="4_sh4bn"]
[ext_resource type="Script" path="res://ui/map.gd" id="5_blxcm"]
[ext_resource type="Script" path="res://ui/gears.gd" id="5_g6cg4"]
[ext_resource type="StyleBox" uid="uid://cly1aqudpku5j" path="res://ui/panel_skew_r.tres" id="6_g2n2l"]
@@ -69,6 +70,7 @@ label = NodePath("laps")
custom_minimum_size = Vector2(0, 80)
layout_mode = 2
size_flags_horizontal = 0
+theme_override_colors/font_color = Color(0.992157, 0.964706, 0.890196, 1)
theme_override_font_sizes/font_size = 40
theme_override_styles/normal = SubResource("StyleBoxFlat_5eh1e")
text = ""
@@ -77,6 +79,8 @@ vertical_alignment = 1
[node name="laps" type="Label" parent="Dashboard/laps"]
layout_mode = 2
+theme_override_colors/font_color = Color(0.992157, 0.964706, 0.890196, 1)
+theme_override_fonts/font = ExtResource("4_sh4bn")
theme_override_font_sizes/font_size = 60
text = " 1/3"
@@ -88,6 +92,7 @@ size_flags_vertical = 8
custom_minimum_size = Vector2(0, 105)
layout_mode = 2
size_flags_horizontal = 4
+theme_override_colors/font_color = Color(0.992157, 0.964706, 0.890196, 1)
text = "龍 0km/h"
horizontal_alignment = 1
vertical_alignment = 1
@@ -101,6 +106,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_nyfll")
custom_minimum_size = Vector2(0, 130)
layout_mode = 2
size_flags_horizontal = 4
+theme_override_colors/font_color = Color(0.992157, 0.964706, 0.890196, 1)
theme_override_font_sizes/font_size = 100
text = "祥 0:00:00"
horizontal_alignment = 1
@@ -116,6 +122,7 @@ theme_override_styles/panel = ExtResource("6_g2n2l")
custom_minimum_size = Vector2(200, 105)
layout_mode = 2
size_flags_horizontal = 4
+theme_override_colors/default_color = Color(0.992157, 0.964706, 0.890196, 1)
bbcode_enabled = true
text = "[center] [b][color=#4682b4]N[/color][/b][/center]"
script = ExtResource("5_g6cg4")
diff --git a/ui/splits/splits.tres b/ui/splits/splits.tres
index 3128fd6..b02bee5 100644
--- a/ui/splits/splits.tres
+++ b/ui/splits/splits.tres
@@ -1,6 +1,6 @@
-[gd_resource type="Theme" load_steps=3 format=3 uid="uid://s8odxpp6ro5s"]
+[gd_resource type="Theme" load_steps=3 format=3]
-[ext_resource type="SystemFont" uid="uid://xriuk0v4f6wj" path="res://ui/ubuntu.tres" id="1_feesq"]
+[ext_resource type="SystemFont" uid="uid://xriuk0v4f6wj" path="res://ui/ubuntu_mononf.tres" id="1_feesq"]
[ext_resource type="StyleBox" uid="uid://dddpw6gu8fex7" path="res://ui/splits/neutral.tres" id="1_fv505"]
[resource]
diff --git a/ui/splits/splits.tscn b/ui/splits/splits.tscn
index 556f230..485f033 100644
--- a/ui/splits/splits.tscn
+++ b/ui/splits/splits.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=3 uid="uid://nkh2xi7tnumc"]
-[ext_resource type="Theme" uid="uid://s8odxpp6ro5s" path="res://ui/splits/splits.tres" id="1_m5q5h"]
+[ext_resource type="Theme" path="res://ui/splits/splits.tres" id="1_m5q5h"]
[ext_resource type="Script" path="res://ui/splits/splits.gd" id="2_2frki"]
[ext_resource type="Script" path="res://ui/splits/difference.gd" id="3_4w6ms"]
[ext_resource type="StyleBox" uid="uid://dwfuwf6qbggrd" path="res://ui/splits/loss.tres" id="4_5hoie"]
diff --git a/ui/theme.tres b/ui/theme.tres
index 07f6a92..a8a24b3 100644
--- a/ui/theme.tres
+++ b/ui/theme.tres
@@ -1,6 +1,6 @@
-[gd_resource type="Theme" load_steps=5 format=3 uid="uid://ecnruuyrc8m"]
+[gd_resource type="Theme" load_steps=5 format=3]
-[ext_resource type="SystemFont" uid="uid://xriuk0v4f6wj" path="res://ui/ubuntu.tres" id="1_37cf0"]
+[ext_resource type="SystemFont" uid="uid://xriuk0v4f6wj" path="res://ui/ubuntu_mononf.tres" id="1_37cf0"]
[ext_resource type="StyleBox" uid="uid://cdth5nc7lbx1v" path="res://ui/panel_skewed.tres" id="1_g8q83"]
[ext_resource type="StyleBox" uid="uid://bkxlhm4hc5lco" path="res://ui/assets/button_focus.stylebox" id="1_t7nt0"]
[ext_resource type="FontVariation" uid="uid://ba8ab6dti2fvo" path="res://ui/boldsans.tres" id="3_fpgf0"]
@@ -14,6 +14,7 @@ Button/colors/font_hover_color = Color(0.992157, 0.964706, 0.890196, 1)
Button/colors/font_hover_pressed_color = Color(0.992157, 0.964706, 0.890196, 1)
Button/colors/font_pressed_color = Color(0.576471, 0.631373, 0.631373, 1)
Button/styles/focus = ExtResource("1_t7nt0")
+Label/colors/font_color = Color(0.933333, 0.909804, 0.835294, 1)
Label/font_sizes/font_size = 76
Label/fonts/font = ExtResource("1_37cf0")
PanelContainer/styles/panel = ExtResource("1_g8q83")
diff --git a/ui/ubuntu.tres b/ui/ubuntu.tres
index 1640c7b..3745caf 100644
--- a/ui/ubuntu.tres
+++ b/ui/ubuntu.tres
@@ -1,5 +1,5 @@
-[gd_resource type="SystemFont" format=3 uid="uid://xriuk0v4f6wj"]
+[gd_resource type="SystemFont" format=3 uid="uid://bkjqtc5i64r3j"]
[resource]
-font_names = PackedStringArray("UbuntuMono Nerd Font")
+font_names = PackedStringArray("Ubuntu")
oversampling = 3.0
diff --git a/ui/ubuntu_mononf.tres b/ui/ubuntu_mononf.tres
new file mode 100644
index 0000000..1640c7b
--- /dev/null
+++ b/ui/ubuntu_mononf.tres
@@ -0,0 +1,5 @@
+[gd_resource type="SystemFont" format=3 uid="uid://xriuk0v4f6wj"]
+
+[resource]
+font_names = PackedStringArray("UbuntuMono Nerd Font")
+oversampling = 3.0