From c1a1f9d1fb4797e781c9c3d4b2170954bb4264e7 Mon Sep 17 00:00:00 2001 From: pytunia Date: Sat, 27 Jan 2024 19:24:15 +0100 Subject: [PATCH 1/4] Tim talks. --- godot/sprites/tim_side.svg | 135 +++++++++++++++++++++++++++++ godot/sprites/tim_side.svg.import | 37 ++++++++ godot/sprites/tim_talk.svg | 136 ++++++++++++++++++++++++++++++ godot/sprites/tim_talk.svg.import | 37 ++++++++ 4 files changed, 345 insertions(+) create mode 100644 godot/sprites/tim_side.svg create mode 100644 godot/sprites/tim_side.svg.import create mode 100644 godot/sprites/tim_talk.svg create mode 100644 godot/sprites/tim_talk.svg.import diff --git a/godot/sprites/tim_side.svg b/godot/sprites/tim_side.svg new file mode 100644 index 0000000..16d5361 --- /dev/null +++ b/godot/sprites/tim_side.svg @@ -0,0 +1,135 @@ + + + + diff --git a/godot/sprites/tim_side.svg.import b/godot/sprites/tim_side.svg.import new file mode 100644 index 0000000..e2e41cf --- /dev/null +++ b/godot/sprites/tim_side.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d2264dy2o4q6d" +path="res://.godot/imported/tim_side.svg-e21ef55d796afaf54c86d6a3abe989e5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/tim_side.svg" +dest_files=["res://.godot/imported/tim_side.svg-e21ef55d796afaf54c86d6a3abe989e5.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=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/godot/sprites/tim_talk.svg b/godot/sprites/tim_talk.svg new file mode 100644 index 0000000..87ec8d2 --- /dev/null +++ b/godot/sprites/tim_talk.svg @@ -0,0 +1,136 @@ + + + + diff --git a/godot/sprites/tim_talk.svg.import b/godot/sprites/tim_talk.svg.import new file mode 100644 index 0000000..16d21aa --- /dev/null +++ b/godot/sprites/tim_talk.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8tb4o75kjffn" +path="res://.godot/imported/tim_talk.svg-0c82c9a95046071242d6f5927c9a9d8e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/tim_talk.svg" +dest_files=["res://.godot/imported/tim_talk.svg-0c82c9a95046071242d6f5927c9a9d8e.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=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false From 86dec7501fc9449b6837f7e17969af601909c828 Mon Sep 17 00:00:00 2001 From: pytunia Date: Sat, 27 Jan 2024 19:34:08 +0100 Subject: [PATCH 2/4] Walking and talking. --- godot/sprites/01_tim_cycle_silent.svg | 138 +++++++++++++++++++++++++ godot/sprites/01_tim_cycle_talk.svg | 138 +++++++++++++++++++++++++ godot/sprites/02_tim_cycle_silent.svg | 140 +++++++++++++++++++++++++ godot/sprites/02_tim_cycle_talk.svg | 138 +++++++++++++++++++++++++ godot/sprites/03_tim_cycle_silent.svg | 140 +++++++++++++++++++++++++ godot/sprites/03_tim_cycle_talk.svg | 141 ++++++++++++++++++++++++++ godot/sprites/04_tim_cycle_silent.svg | 139 +++++++++++++++++++++++++ godot/sprites/04_tim_cycle_talk.svg | 138 +++++++++++++++++++++++++ 8 files changed, 1112 insertions(+) create mode 100644 godot/sprites/01_tim_cycle_silent.svg create mode 100644 godot/sprites/01_tim_cycle_talk.svg create mode 100644 godot/sprites/02_tim_cycle_silent.svg create mode 100644 godot/sprites/02_tim_cycle_talk.svg create mode 100644 godot/sprites/03_tim_cycle_silent.svg create mode 100644 godot/sprites/03_tim_cycle_talk.svg create mode 100644 godot/sprites/04_tim_cycle_silent.svg create mode 100644 godot/sprites/04_tim_cycle_talk.svg diff --git a/godot/sprites/01_tim_cycle_silent.svg b/godot/sprites/01_tim_cycle_silent.svg new file mode 100644 index 0000000..9ace5cf --- /dev/null +++ b/godot/sprites/01_tim_cycle_silent.svg @@ -0,0 +1,138 @@ + + + + diff --git a/godot/sprites/01_tim_cycle_talk.svg b/godot/sprites/01_tim_cycle_talk.svg new file mode 100644 index 0000000..f53e612 --- /dev/null +++ b/godot/sprites/01_tim_cycle_talk.svg @@ -0,0 +1,138 @@ + + + + diff --git a/godot/sprites/02_tim_cycle_silent.svg b/godot/sprites/02_tim_cycle_silent.svg new file mode 100644 index 0000000..5388daf --- /dev/null +++ b/godot/sprites/02_tim_cycle_silent.svg @@ -0,0 +1,140 @@ + + + + diff --git a/godot/sprites/02_tim_cycle_talk.svg b/godot/sprites/02_tim_cycle_talk.svg new file mode 100644 index 0000000..ae395a8 --- /dev/null +++ b/godot/sprites/02_tim_cycle_talk.svg @@ -0,0 +1,138 @@ + + + + diff --git a/godot/sprites/03_tim_cycle_silent.svg b/godot/sprites/03_tim_cycle_silent.svg new file mode 100644 index 0000000..3273437 --- /dev/null +++ b/godot/sprites/03_tim_cycle_silent.svg @@ -0,0 +1,140 @@ + + + + diff --git a/godot/sprites/03_tim_cycle_talk.svg b/godot/sprites/03_tim_cycle_talk.svg new file mode 100644 index 0000000..75a5dc1 --- /dev/null +++ b/godot/sprites/03_tim_cycle_talk.svg @@ -0,0 +1,141 @@ + + + + diff --git a/godot/sprites/04_tim_cycle_silent.svg b/godot/sprites/04_tim_cycle_silent.svg new file mode 100644 index 0000000..90fb067 --- /dev/null +++ b/godot/sprites/04_tim_cycle_silent.svg @@ -0,0 +1,139 @@ + + + + diff --git a/godot/sprites/04_tim_cycle_talk.svg b/godot/sprites/04_tim_cycle_talk.svg new file mode 100644 index 0000000..6c338d3 --- /dev/null +++ b/godot/sprites/04_tim_cycle_talk.svg @@ -0,0 +1,138 @@ + + + + From 2c7128aafd047f9d7c323bba1ab1940d69d26bd9 Mon Sep 17 00:00:00 2001 From: Marvin Dalheimer Date: Sat, 27 Jan 2024 20:34:39 +0100 Subject: [PATCH 3/4] Add animations to Tim --- godot/project.godot | 1 + godot/scenes/Tim.gd | 46 ++++++++++++++---------- godot/scenes/objects/bottle.gd | 27 +++++++------- godot/scenes/signals.gd | 3 ++ godot/scenes/stage.tscn | 65 ++++++++++++++++++++++++++++++++-- 5 files changed, 110 insertions(+), 32 deletions(-) create mode 100644 godot/scenes/signals.gd diff --git a/godot/project.godot b/godot/project.godot index 37ee600..8bf8e4e 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -18,6 +18,7 @@ config/icon="res://icon.svg" [autoload] UserSettings="*res://settings/user_settings.gd" +Signals="*res://scenes/signals.gd" [display] diff --git a/godot/scenes/Tim.gd b/godot/scenes/Tim.gd index 9ce62f1..78fce87 100644 --- a/godot/scenes/Tim.gd +++ b/godot/scenes/Tim.gd @@ -5,29 +5,39 @@ extends Node2D @export var tim_sprite : Sprite2D @export var transmitter_area: Area2D +var default_texture: Texture2D = load("res://sprites/tim_side.png") +var ducking_texture: Texture2D = load("res://sprites/tim_ducking.svg") + # Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + Signals.hit_tim.connect(ouch) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - if Input.is_action_pressed("move_right"): - tim_sprite.flip_h = true - global_position += Vector2.RIGHT * delta * move_speed - if global_position.x > boundary.get_most_right_position(): - global_position = Vector2(boundary.get_most_right_position(), global_position.y) - - if Input.is_action_pressed("move_left"): - tim_sprite.flip_h = false - global_position += Vector2.LEFT * delta * move_speed - if global_position.x < boundary.get_most_left_position(): - global_position = Vector2(boundary.get_most_left_position(), global_position.y) + if Input.is_action_pressed("move_right"): + tim_sprite.flip_h = true + global_position += Vector2.RIGHT * delta * move_speed + if global_position.x > boundary.get_most_right_position(): + global_position = Vector2(boundary.get_most_right_position(), global_position.y) + + if Input.is_action_pressed("move_left"): + tim_sprite.flip_h = false + global_position += Vector2.LEFT * delta * move_speed + if global_position.x < boundary.get_most_left_position(): + global_position = Vector2(boundary.get_most_left_position(), global_position.y) func _on_joke_button_button_pressed(joke): - for body in transmitter_area.get_overlapping_bodies(): - var person = body.find_parent("Person") - if not (person is AudienceMember): - continue - - person.on_joke(joke) + $AnimationPlayer.play("talking") + + for body in transmitter_area.get_overlapping_bodies(): + var person = body.find_parent("Person") + if not (person is AudienceMember): + continue + + person.on_joke(joke) + +func ouch(): + $Sprite2D.texture = ducking_texture + await get_tree().create_timer(1).timeout + $Sprite2D.texture = default_texture diff --git a/godot/scenes/objects/bottle.gd b/godot/scenes/objects/bottle.gd index 6b7061f..d68b6e8 100644 --- a/godot/scenes/objects/bottle.gd +++ b/godot/scenes/objects/bottle.gd @@ -1,5 +1,7 @@ extends Sprite2D +signal hit_tim + @export var bottle_speed: float = 120; var tim_global_position: Vector2 @@ -7,26 +9,27 @@ var is_hidding: bool # Called when the node enters the scene tree for the first time. func _ready(): - tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position + tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - var t = create_tween().set_parallel() - t.tween_property(self, "global_position", tim_global_position, 3.0) - t.tween_property(self, "rotation_degrees", rotation_degrees + 270, 3.0) - t.tween_callback(remove_bottle).set_delay(3.05) + var t = create_tween().set_parallel() + t.tween_property(self, "global_position", tim_global_position, 3.0) + t.tween_property(self, "rotation_degrees", rotation_degrees + 270, 3.0) + t.tween_callback(remove_bottle).set_delay(3.05) func _on_bottle_area_entered(area): - is_hidding = true + is_hidding = true func _on_bottle_area_exited(area): - is_hidding = false + is_hidding = false func _on_growth_timer_timeout(): - var t = create_tween() - t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02) + var t = create_tween() + t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02) func remove_bottle(): - if is_hidding: - print("Ouch") - queue_free() + if is_hidding: + print("Ouch") + Signals.hit_tim.emit() + queue_free() diff --git a/godot/scenes/signals.gd b/godot/scenes/signals.gd new file mode 100644 index 0000000..45b76e2 --- /dev/null +++ b/godot/scenes/signals.gd @@ -0,0 +1,3 @@ +extends Node + +signal hit_tim diff --git a/godot/scenes/stage.tscn b/godot/scenes/stage.tscn index a31e8e9..271c058 100644 --- a/godot/scenes/stage.tscn +++ b/godot/scenes/stage.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=8 format=3 uid="uid://cicyfp5xjvvu4"] +[gd_scene load_steps=14 format=3 uid="uid://cicyfp5xjvvu4"] [ext_resource type="Texture2D" uid="uid://bg85if5rrrdmm" path="res://sprites/room/buehne.svg" id="1_32lst"] [ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"] [ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"] [ext_resource type="Script" path="res://scenes/Boundary.gd" id="2_8p6ir"] [ext_resource type="PackedScene" uid="uid://r1i7ln2hpwq5" path="res://scenes/joke_button.tscn" id="3_0t41i"] +[ext_resource type="Texture2D" uid="uid://b8tb4o75kjffn" path="res://sprites/tim_talk.svg" id="3_e1fvx"] +[ext_resource type="Texture2D" uid="uid://d2264dy2o4q6d" path="res://sprites/tim_side.svg" id="6_qpa7m"] [sub_resource type="CircleShape2D" id="CircleShape2D_jfw8v"] radius = 23.0217 @@ -12,6 +14,59 @@ radius = 23.0217 [sub_resource type="RectangleShape2D" id="RectangleShape2D_wmfel"] size = Vector2(250, 10000) +[sub_resource type="Animation" id="Animation_kkrfv"] +resource_name = "talking" +length = 4.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 3.95), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [ExtResource("1_saxit"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("1_saxit"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("1_saxit")] +} + +[sub_resource type="Animation" id="Animation_n0bwh"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("3_e1fvx")] +} + +[sub_resource type="Animation" id="Animation_5tnw3"] +resource_name = "idle" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [ExtResource("6_qpa7m"), ExtResource("6_qpa7m")] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_xvfym"] +_data = { +"RESET": SubResource("Animation_n0bwh"), +"idle": SubResource("Animation_5tnw3"), +"talking": SubResource("Animation_kkrfv") +} + [node name="Stage" type="Node2D"] z_index = 100 @@ -39,10 +94,11 @@ shape = SubResource("CircleShape2D_jfw8v") z_index = 110 position = Vector2(-12, -142) scale = Vector2(0.4, 0.4) -texture = ExtResource("1_saxit") +texture = ExtResource("3_e1fvx") offset = Vector2(0, 50) [node name="Joke Buttons" type="Node2D" parent="Tim"] +visible = false z_index = 120 position = Vector2(0, -25) @@ -64,6 +120,11 @@ action = "joke_button_3" [node name="CollisionShape2D" type="CollisionShape2D" parent="Tim/Joke Transmitter/Area2D"] shape = SubResource("RectangleShape2D_wmfel") +[node name="AnimationPlayer" type="AnimationPlayer" parent="Tim"] +libraries = { +"": SubResource("AnimationLibrary_xvfym") +} + [node name="Boundary" type="Node2D" parent="."] script = ExtResource("2_8p6ir") From a6494a92898e8b6ac11215344d97a7d51c8ec1d1 Mon Sep 17 00:00:00 2001 From: Marvin Dalheimer Date: Sat, 27 Jan 2024 20:53:30 +0100 Subject: [PATCH 4/4] Make buttons visible again --- godot/scenes/stage.tscn | 1 - 1 file changed, 1 deletion(-) diff --git a/godot/scenes/stage.tscn b/godot/scenes/stage.tscn index 0720b44..dd74276 100644 --- a/godot/scenes/stage.tscn +++ b/godot/scenes/stage.tscn @@ -103,7 +103,6 @@ texture = ExtResource("3_e1fvx") offset = Vector2(0, 50) [node name="Joke Buttons" type="Node2D" parent="Tim"] -visible = false z_index = 120 position = Vector2(0, -25)