From 114e09172f40cb9d0239ac28cdab5590b5239283 Mon Sep 17 00:00:00 2001 From: Dukantic Date: Sat, 18 Jan 2025 15:45:09 +0100 Subject: [PATCH] benitier --- project.godot | 2 +- scene/display_song.tscn | 71 +++++++++++++++++++++++++++++++++++++++++ scene/player.tscn | 8 +++-- script/benitier.gd | 3 +- script/display_song.gd | 9 ++++++ script/player.gd | 8 +++-- 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 scene/display_song.tscn create mode 100644 script/display_song.gd diff --git a/project.godot b/project.godot index ca765b2..e0111df 100644 --- a/project.godot +++ b/project.godot @@ -45,7 +45,7 @@ right={ } doigt={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) ] } enter={ diff --git a/scene/display_song.tscn b/scene/display_song.tscn new file mode 100644 index 0000000..6427c48 --- /dev/null +++ b/scene/display_song.tscn @@ -0,0 +1,71 @@ +[gd_scene load_steps=6 format=3 uid="uid://bi1sl1tcpssyd"] + +[ext_resource type="Script" path="res://script/display_song.gd" id="1_el3j1"] +[ext_resource type="Theme" uid="uid://dwtios6w33wxq" path="res://theme/label_theme.tres" id="2_p16cs"] + +[sub_resource type="Animation" id="Animation_2j0q6"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Control:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 0)] +} + +[sub_resource type="Animation" id="Animation_a1cki"] +resource_name = "alphapasla" +length = 6.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Control:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.966667, 5, 6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_86fsc"] +_data = { +"RESET": SubResource("Animation_2j0q6"), +"alphapasla": SubResource("Animation_a1cki") +} + +[node name="display_song" type="CanvasLayer" node_paths=PackedStringArray("label", "anim")] +script = ExtResource("1_el3j1") +label = NodePath("Control/Label") +anim = NodePath("AnimationPlayer") + +[node name="Control" type="Control" parent="."] +modulate = Color(1, 1, 1, 0) +layout_mode = 3 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +grow_vertical = 0 + +[node name="Label" type="Label" parent="Control"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -23.0 +offset_right = 80.0 +grow_vertical = 0 +theme = ExtResource("2_p16cs") +theme_override_font_sizes/font_size = 90 +text = "qwrertuiioyo" + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_86fsc") +} diff --git a/scene/player.tscn b/scene/player.tscn index 93d4b56..5259c0c 100644 --- a/scene/player.tscn +++ b/scene/player.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=10 format=3 uid="uid://c74354tlmcg6h"] +[gd_scene load_steps=11 format=3 uid="uid://c74354tlmcg6h"] [ext_resource type="Script" path="res://script/player.gd" id="1_kjuyr"] +[ext_resource type="PackedScene" uid="uid://bi1sl1tcpssyd" path="res://scene/display_song.tscn" id="2_0o8k8"] [ext_resource type="PackedScene" uid="uid://b5rkwb64wgdwf" path="res://scene/gpu_particles_3d.tscn" id="2_ctykj"] [ext_resource type="PackedScene" uid="uid://cqla6v58rvrqd" path="res://scene/main.tscn" id="3_wfafm"] @@ -121,7 +122,7 @@ _data = { "finger": SubResource("Animation_njhrs") } -[node name="CharacterBody3D" type="CharacterBody3D" node_paths=PackedStringArray("head", "anim", "particules")] +[node name="CharacterBody3D" type="CharacterBody3D" node_paths=PackedStringArray("head", "anim", "particules", "canvas")] script = ExtResource("1_kjuyr") SENSI = 0.002 SPEED_PARTICULES = 25.0 @@ -130,6 +131,9 @@ MIN_PARTICULES = 10 head = NodePath("head") anim = NodePath("AnimationPlayer") particules = NodePath("MainHugues/GPUParticles3D") +canvas = NodePath("display_song") + +[node name="display_song" parent="." instance=ExtResource("2_0o8k8")] [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(0.999917, 0, 0.0128802, 0, 1, 0, -0.0128802, 0, 0.999917, 0, 0, 0) diff --git a/script/benitier.gd b/script/benitier.gd index bc04c7a..520f677 100644 --- a/script/benitier.gd +++ b/script/benitier.gd @@ -9,7 +9,7 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: +func _process(_delta: float)-> void: if (in_player and Input.is_action_just_pressed("interact")): player.call("drink") @@ -18,6 +18,7 @@ func _on_area_3d_body_entered(body: Node3D) -> void: if (body is CharacterBody3D): in_player = true player = body + player.call("display_drink") func _on_area_3d_body_exited(body: Node3D) -> void: diff --git a/script/display_song.gd b/script/display_song.gd new file mode 100644 index 0000000..7cd46de --- /dev/null +++ b/script/display_song.gd @@ -0,0 +1,9 @@ +extends CanvasLayer + +@export var label:Label = null +@export var anim: AnimationPlayer = null + +func display_song_name(text: String) -> void: + anim.play("RESET") + label.text = text + anim.play("alphapasla") diff --git a/script/player.gd b/script/player.gd index 1966bf0..c59e120 100644 --- a/script/player.gd +++ b/script/player.gd @@ -13,6 +13,7 @@ extends CharacterBody3D @export var head: Node3D @export var anim: AnimationPlayer @export var particules: GPUParticles3D +@export var canvas: CanvasLayer var time_hand: float= 0 var nbr_particules = 1000 @@ -21,12 +22,11 @@ func _ready() -> void: time_hand = cooldown Input.mouse_mode = Input.MOUSE_MODE_CAPTURED add_to_group("player") + canvas.call("display_song_name", "Clic gauche pour se repérer.") func _input(event: InputEvent) -> void: if event is InputEventMouseMotion: - #head.rotate_x(-event.relative.y * SENSI) rotate_y(-event.relative.x * SENSI) - #head.rotation.x = clamp(head.rotation.x, -PI/2, PI/2) func _physics_process(delta: float) -> void: time_hand += delta @@ -47,7 +47,7 @@ func _physics_process(delta: float) -> void: particules.amount = nbr_particules nbr_particules /= 2 nbr_particules = clamp(nbr_particules, MIN_PARTICULES, MAX_PARTICULES) - print(nbr_particules) + particules.process_material.set("gravity", vect) anim.play("finger") @@ -64,3 +64,5 @@ func _physics_process(delta: float) -> void: func drink() -> void: nbr_particules = MAX_PARTICULES +func display_drink()->void: + canvas.call("display_song_name", "E pour boire.")