testing code

This commit is contained in:
kevadesu 2025-05-15 13:57:49 +02:00
parent 22c3d58957
commit cbc400e629
4 changed files with 133 additions and 3 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=31 format=3 uid="uid://bn20cqfwvm2oe"]
[gd_scene load_steps=32 format=3 uid="uid://bn20cqfwvm2oe"]
[ext_resource type="Script" uid="uid://wr38f8q1w7yq" path="res://main.gd" id="1_fwt2i"]
[ext_resource type="PackedScene" uid="uid://bs6yq6gy7k2sb" path="res://player.tscn" id="1_lsi31"]
@ -82,6 +82,12 @@ font_size = 22
outline_size = 4
outline_color = Color(0, 0, 0, 1)
[sub_resource type="LabelSettings" id="LabelSettings_2uy0w"]
font = ExtResource("12_2uy0w")
font_size = 38
outline_size = 4
outline_color = Color(0, 0, 0, 1)
[node name="LevelCore" type="Node3D"]
script = ExtResource("1_fwt2i")
@ -328,6 +334,57 @@ skeleton = NodePath("../MeshInstance3D")
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D58/StaticBody3D"]
shape = ExtResource("2_7sds5")
[node name="MeshInstance3D61" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 20, -10)
mesh = SubResource("PlaneMesh_rv2mx")
skeleton = NodePath("../MeshInstance3D")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D61"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D61/StaticBody3D"]
shape = ExtResource("2_7sds5")
[node name="MeshInstance3D65" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 20, 0)
mesh = SubResource("PlaneMesh_rv2mx")
skeleton = NodePath("../MeshInstance3D")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D65"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D65/StaticBody3D"]
shape = ExtResource("2_7sds5")
disabled = true
[node name="MeshInstance3D62" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -20, 25, -5)
mesh = SubResource("PlaneMesh_rv2mx")
skeleton = NodePath("../MeshInstance3D")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D62"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D62/StaticBody3D"]
shape = ExtResource("3_n0qnv")
[node name="MeshInstance3D64" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -20, 25, 5)
mesh = SubResource("PlaneMesh_rv2mx")
skeleton = NodePath("../MeshInstance3D")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D64"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D64/StaticBody3D"]
shape = ExtResource("2_7sds5")
[node name="MeshInstance3D63" type="MeshInstance3D" parent="."]
transform = Transform3D(-1, -8.74228e-08, -3.82137e-15, 0, -4.37114e-08, 1, -8.74228e-08, 1, 4.37114e-08, -20, 25, -15)
mesh = SubResource("PlaneMesh_rv2mx")
skeleton = NodePath("../MeshInstance3D")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D63"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D63/StaticBody3D"]
shape = ExtResource("2_7sds5")
[node name="MeshInstance3D6" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 0, -10)
material_override = SubResource("StandardMaterial3D_2uy0w")
@ -902,6 +959,26 @@ font = ExtResource("2_fq2vn")
font_size = 128
outline_size = 48
[node name="Label3D24" type="Label3D" parent="."]
transform = Transform3D(-4.37113e-08, 0, 1, 0, 1, 0, -0.999999, 0, -4.37114e-08, -14.9565, 25.0789, -0.0186324)
offset = Vector2(1, 0)
modulate = Color(0.943031, 0.787658, 0.994854, 1)
outline_modulate = Color(0.00803253, 9.36218e-06, 0.0382829, 1)
text = "Donut"
font = ExtResource("2_fq2vn")
font_size = 128
outline_size = 48
[node name="Label3D25" type="Label3D" parent="."]
transform = Transform3D(-4.37113e-08, 0, 1, 0, 1, 0, -0.999999, 0, -4.37114e-08, -14.9565, 25.11, -10.0375)
offset = Vector2(1, 0)
modulate = Color(0.943031, 0.787658, 0.994854, 1)
outline_modulate = Color(0.00803253, 9.36218e-06, 0.0382829, 1)
text = "Telefon/Telephone"
font = ExtResource("2_fq2vn")
font_size = 128
outline_size = 48
[node name="Label3D10" type="Label3D" parent="."]
transform = Transform3D(-0.111676, -0.112887, 0.987312, 0.0138923, 0.993252, 0.115138, -0.993647, 0.0265751, -0.109355, 5.67565, 2.01538, -0.103783)
offset = Vector2(1, 0)
@ -1010,6 +1087,15 @@ offset_bottom = 318.0
text = "time/zeit: "
label_settings = SubResource("LabelSettings_27422")
[node name="Label_Health" type="Label" parent="."]
offset_left = 100.0
offset_top = 980.0
offset_right = 625.0
offset_bottom = 1008.0
text = "[||||||||||]"
label_settings = SubResource("LabelSettings_2uy0w")
vertical_alignment = 2
[node name="Label_Controls3" type="Label" parent="."]
visible = false
offset_left = 100.0

42
main.gd
View file

@ -11,6 +11,7 @@ var checkpoint = checkpoint0
var time_accum = 0.0 # Timer accumulator
@onready var player = get_node("Player")
var elapsed_time := 0.0
var restart_count = 0
func _ready() -> void:
var player = get_node("Player")
@ -39,10 +40,51 @@ func _process(delta: float):
elif Input.is_action_just_pressed("proluz_ui_respawn"):
var player = get_node("Player")
player.teleport_to_checkpoint()
player.health = 100
Engine.time_scale = 1
elif Input.is_action_just_pressed("proluz_ui_reset"):
get_tree().reload_current_scene()
var player = get_node("Player")
$Label_Controls2.text = get_formatted_time()
# Health bar
if player.health == 100:
$Label_Health.text = "[//////////]"
$Label_Health.add_theme_color_override("font_color", Color.GREEN)
elif player.health >= 90:
$Label_Health.text = "[/////////·]"
$Label_Health.add_theme_color_override("font_color", Color.GREEN)
elif player.health >= 80:
$Label_Health.text = "[////////··]"
$Label_Health.add_theme_color_override("font_color", Color.GREEN)
elif player.health >= 70:
$Label_Health.text = "[///////···]"
$Label_Health.add_theme_color_override("font_color", Color.GREEN)
elif player.health >= 60:
$Label_Health.text = "[//////····]"
$Label_Health.add_theme_color_override("font_color", Color.GREEN_YELLOW)
elif player.health >= 50:
$Label_Health.text = "[/////·····]"
$Label_Health.add_theme_color_override("font_color", Color.GREEN_YELLOW)
elif player.health >= 40:
$Label_Health.text = "[////······]"
$Label_Health.add_theme_color_override("font_color", Color.YELLOW)
elif player.health >= 30:
$Label_Health.text = "[///·······]"
$Label_Health.add_theme_color_override("font_color", Color.YELLOW)
elif player.health >= 20:
$Label_Health.text = "[//········]"
$Label_Health.add_theme_color_override("font_color", Color.YELLOW)
elif player.health >= 10:
$Label_Health.text = "[/·········]"
$Label_Health.add_theme_color_override("font_color", Color.INDIAN_RED)
elif player.health >= 1:
$Label_Health.text = "[|·········][CRITICAL]"
$Label_Health.add_theme_color_override("font_color", Color.RED)
elif player.health == 0:
$Label_Health.text = "[··········][DEAD/Shift+R to revive]"
$Label_Health.add_theme_color_override("font_color", Color.MEDIUM_PURPLE)
Engine.time_scale = 0.001
func get_formatted_time() -> String:
var total_milliseconds = int(elapsed_time * 1000)

View file

@ -92,6 +92,6 @@ label_settings = SubResource("LabelSettings_d3xb4")
horizontal_alignment = 1
vertical_alignment = 1
[connection signal="pressed" from="MarginContainer/VBoxContainer/ResumeButton" to="." method="_on_resume_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/ResumeButton" to="." method="_on_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/ResumeButton" to="." method="_on_resume_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]

View file

@ -23,6 +23,8 @@ func _ready() -> void:
# If touches object
var touched = false
var health = 100
func teleport_to_checkpoint():
levelcore = get_node("/root/LevelCore")
var target_position = levelcore.checkpoint
@ -43,7 +45,7 @@ func _integrate_forces(state):
levelcore.checkpoint = levelcore.checkpoint1
levelcore.checkpointtext.text = "station 1"
elif collider is StaticBody3D and collider.name == "StaticBody3D_S2":
print("chat we hit the checkpoint one")
print("chat we hit the checkpoint two")
levelcore = get_node("/root/LevelCore")
levelcore.checkpoint = levelcore.checkpoint2
levelcore.checkpointtext.text = "station 2"