From 6f4c375465dbb9af965c27de791826167845fa70 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sun, 16 Aug 2020 10:25:32 +0200 Subject: [PATCH] Add a tiny part of the script to the campfire intro scene --- dialogues/intro_1.json | 10 +- images/herbert_Eyes.png.import | 2 +- images/herbert_FirstStep.png.import | 2 +- images/herbert_SecondStep.png.import | 2 +- images/herbert_intro.tres | 203 +++++++++++++++++++++++++++ project.godot | 20 +-- scenes/campfire.tscn | 16 ++- scenes/main_menu.tscn | 4 +- scripts/DialogueAction.gd | 2 + scripts/DialogueBox.gd | 2 - scripts/scenes/IntroScript.gd | 40 +++++- 11 files changed, 265 insertions(+), 38 deletions(-) create mode 100644 images/herbert_intro.tres diff --git a/dialogues/intro_1.json b/dialogues/intro_1.json index 713be84..9d5e7a0 100644 --- a/dialogues/intro_1.json +++ b/dialogues/intro_1.json @@ -1,8 +1,6 @@ [ - {"name": "Ely", "text": "Heyo!", "expression": "neutral"}, - {"name": "Ely", "text": "My name Ely", "expression": "neutral"}, - {"name": "Ely", "text": "I do fun stuff", "expression": "neutral"}, - {"name": "Ely", "text": "It is very fun", "expression": "neutral"}, - {"name": "Crab", "text": "Also that's a very good dialogue with a very very long text", "expression": "neutral"}, - {"name": "Crab", "text": "lorem ipsum dolor sit amet truc machin bidule lorem ipsum dolor sit amet truc machin bidule lorem ipsum dolor sit amet truc machin bidule", "expression": "neutral"} + {"name": "Ely", "text": "What a shame...", "expression": "neutral"}, + {"name": "Ely", "text": "I don't like being alone.", "expression": "neutral"}, + {"name": "Ely", "text": "I just want to go home!", "expression": "neutral"}, + {"name": "Ely", "text": "Hopefully someone will come by and rescue me...", "expression": "neutral"} ] diff --git a/images/herbert_Eyes.png.import b/images/herbert_Eyes.png.import index 78fefb8..5e1198f 100644 --- a/images/herbert_Eyes.png.import +++ b/images/herbert_Eyes.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 diff --git a/images/herbert_FirstStep.png.import b/images/herbert_FirstStep.png.import index 795ca4d..9736e6e 100644 --- a/images/herbert_FirstStep.png.import +++ b/images/herbert_FirstStep.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 diff --git a/images/herbert_SecondStep.png.import b/images/herbert_SecondStep.png.import index e6d92a8..a67206f 100644 --- a/images/herbert_SecondStep.png.import +++ b/images/herbert_SecondStep.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 diff --git a/images/herbert_intro.tres b/images/herbert_intro.tres new file mode 100644 index 0000000..4a3599e --- /dev/null +++ b/images/herbert_intro.tres @@ -0,0 +1,203 @@ +[gd_resource type="SpriteFrames" load_steps=49 format=2] + +[ext_resource path="res://images/herbert_SecondStep.png" type="Texture" id=1] +[ext_resource path="res://images/herbert_Eyes.png" type="Texture" id=2] +[ext_resource path="res://images/herbert_FirstStep.png" type="Texture" id=3] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 2 ) +region = Rect2( 0, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 2 ) +region = Rect2( 192, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 2 ) +region = Rect2( 384, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 2 ) +region = Rect2( 0, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 2 ) +region = Rect2( 192, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 2 ) +region = Rect2( 384, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 2 ) +region = Rect2( 0, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 2 ) +region = Rect2( 192, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=9] +atlas = ExtResource( 2 ) +region = Rect2( 384, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 2 ) +region = Rect2( 0, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 2 ) +region = Rect2( 192, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=12] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=13] +atlas = ExtResource( 1 ) +region = Rect2( 192, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=14] +atlas = ExtResource( 1 ) +region = Rect2( 384, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=15] +atlas = ExtResource( 1 ) +region = Rect2( 0, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=16] +atlas = ExtResource( 1 ) +region = Rect2( 192, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=17] +atlas = ExtResource( 1 ) +region = Rect2( 384, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=18] +atlas = ExtResource( 1 ) +region = Rect2( 0, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=19] +atlas = ExtResource( 1 ) +region = Rect2( 192, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=20] +atlas = ExtResource( 1 ) +region = Rect2( 384, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=21] +atlas = ExtResource( 1 ) +region = Rect2( 0, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=22] +atlas = ExtResource( 1 ) +region = Rect2( 192, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=23] +atlas = ExtResource( 1 ) +region = Rect2( 384, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=24] +atlas = ExtResource( 1 ) +region = Rect2( 0, 432, 192, 108 ) + +[sub_resource type="AtlasTexture" id=25] +atlas = ExtResource( 1 ) +region = Rect2( 192, 432, 192, 108 ) + +[sub_resource type="AtlasTexture" id=26] +atlas = ExtResource( 3 ) +region = Rect2( 0, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=27] +atlas = ExtResource( 3 ) +region = Rect2( 192, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=28] +atlas = ExtResource( 3 ) +region = Rect2( 384, 0, 192, 108 ) + +[sub_resource type="AtlasTexture" id=29] +atlas = ExtResource( 3 ) +region = Rect2( 0, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=30] +atlas = ExtResource( 3 ) +region = Rect2( 192, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=31] +atlas = ExtResource( 3 ) +region = Rect2( 384, 108, 192, 108 ) + +[sub_resource type="AtlasTexture" id=32] +atlas = ExtResource( 3 ) +region = Rect2( 0, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=33] +atlas = ExtResource( 3 ) +region = Rect2( 192, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=34] +atlas = ExtResource( 3 ) +region = Rect2( 384, 216, 192, 108 ) + +[sub_resource type="AtlasTexture" id=35] +atlas = ExtResource( 3 ) +region = Rect2( 0, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=36] +atlas = ExtResource( 3 ) +region = Rect2( 192, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=37] +atlas = ExtResource( 3 ) +region = Rect2( 384, 324, 192, 108 ) + +[sub_resource type="AtlasTexture" id=38] +atlas = ExtResource( 3 ) +region = Rect2( 0, 432, 192, 108 ) + +[sub_resource type="AtlasTexture" id=39] +atlas = ExtResource( 3 ) +region = Rect2( 192, 432, 192, 108 ) + +[sub_resource type="AtlasTexture" id=40] +atlas = ExtResource( 3 ) +region = Rect2( 384, 432, 192, 108 ) + +[sub_resource type="AtlasTexture" id=41] +atlas = ExtResource( 3 ) +region = Rect2( 0, 540, 192, 108 ) + +[sub_resource type="AtlasTexture" id=42] +atlas = ExtResource( 3 ) +region = Rect2( 192, 540, 192, 108 ) + +[sub_resource type="AtlasTexture" id=43] +atlas = ExtResource( 3 ) +region = Rect2( 384, 540, 192, 108 ) + +[sub_resource type="AtlasTexture" id=44] +atlas = ExtResource( 3 ) +region = Rect2( 0, 648, 192, 108 ) + +[sub_resource type="AtlasTexture" id=45] +atlas = ExtResource( 3 ) +region = Rect2( 192, 648, 192, 108 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ], +"loop": false, +"name": "eyes", +"speed": 10.0 +}, { +"frames": [ SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ) ], +"loop": false, +"name": "second_step", +"speed": 10.0 +}, { +"frames": [ SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ), SubResource( 33 ), SubResource( 34 ), SubResource( 35 ), SubResource( 36 ), SubResource( 37 ), SubResource( 38 ), SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ) ], +"loop": false, +"name": "first_step", +"speed": 10.0 +} ] diff --git a/project.godot b/project.godot index 954ad49..04d7f5e 100644 --- a/project.godot +++ b/project.godot @@ -10,16 +10,6 @@ config_version=4 _global_script_classes=[ { "base": "Node", -"class": "AsepriteImportData", -"language": "GDScript", -"path": "res://addons/aseprite_importer/classes/AsepriteImportData.gd" -}, { -"base": "Node", -"class": "AsepriteImporter", -"language": "GDScript", -"path": "res://addons/aseprite_importer/classes/AsepriteImporter.gd" -}, { -"base": "Node", "class": "DialogueAction", "language": "GDScript", "path": "res://scripts/DialogueAction.gd" @@ -30,21 +20,13 @@ _global_script_classes=[ { "path": "res://scripts/DialogueBox.gd" }, { "base": "Node", -"class": "EditorTheme", -"language": "GDScript", -"path": "res://addons/aseprite_importer/classes/EditorTheme.gd" -}, { -"base": "Node", "class": "IntroScript", "language": "GDScript", "path": "res://scripts/scenes/IntroScript.gd" } ] _global_script_class_icons={ -"AsepriteImportData": "", -"AsepriteImporter": "", "DialogueAction": "", "DialogueBox": "", -"EditorTheme": "", "IntroScript": "" } @@ -65,7 +47,7 @@ window/stretch/aspect="keep" [editor_plugins] -enabled=PoolStringArray( "aseprite_importer" ) +enabled=PoolStringArray( ) [input] diff --git a/scenes/campfire.tscn b/scenes/campfire.tscn index 4817b5e..9755a81 100644 --- a/scenes/campfire.tscn +++ b/scenes/campfire.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://images/campfire.tres" type="SpriteFrames" id=1] [ext_resource path="res://images/ely.tres" type="SpriteFrames" id=2] [ext_resource path="res://scenes/dialogue.tscn" type="PackedScene" id=3] [ext_resource path="res://scripts/scenes/IntroScript.gd" type="Script" id=4] +[ext_resource path="res://images/herbert_intro.tres" type="SpriteFrames" id=5] [node name="root" type="Node2D"] @@ -15,7 +16,15 @@ centered = false [node name="Ely" type="AnimatedSprite" parent="."] frames = ExtResource( 2 ) -frame = 49 +frame = 97 +playing = true +centered = false + +[node name="Herbert" type="AnimatedSprite" parent="."] +visible = false +frames = ExtResource( 5 ) +animation = "eyes" +frame = 10 playing = true centered = false @@ -32,4 +41,5 @@ visible = false [node name="IntroScript" type="Node" parent="."] script = ExtResource( 4 ) dialogue_box_path = NodePath("../UI/Dialog") -start_dialogue = "res://dialogues/intro_1.json" +herbert_sprite_path = NodePath("../Herbert") +intro_dialogue = "res://dialogues/intro_1.json" diff --git a/scenes/main_menu.tscn b/scenes/main_menu.tscn index 8cd6871..0743460 100644 --- a/scenes/main_menu.tscn +++ b/scenes/main_menu.tscn @@ -24,7 +24,7 @@ script = ExtResource( 1 ) [node name="Fire" type="AnimatedSprite" parent="."] frames = ExtResource( 6 ) animation = "start" -frame = 38 +frame = 41 playing = true centered = false script = ExtResource( 1 ) @@ -86,5 +86,3 @@ __meta__ = { } [connection signal="animation_finished" from="background" to="background" method="_on_background_animation_finished"] [connection signal="animation_finished" from="Fire" to="Fire" method="_on_background_animation_finished"] -[connection signal="pressed" from="UI/Buttons/PlayButton" to="UI/Buttons/PlayButton" method="_on_Button_pressed"] -[connection signal="pressed" from="UI/Buttons/QuitButton" to="UI/Buttons/QuitButton" method="_on_Button_pressed"] diff --git a/scripts/DialogueAction.gd b/scripts/DialogueAction.gd index 5a73a1f..63d782a 100644 --- a/scripts/DialogueAction.gd +++ b/scripts/DialogueAction.gd @@ -1,6 +1,8 @@ extends Node class_name DialogueAction +signal end + export (NodePath) var dialogue_box_path onready var dialogue_box = get_node(dialogue_box_path) diff --git a/scripts/DialogueBox.gd b/scripts/DialogueBox.gd index 9eaf28c..2b45dd3 100644 --- a/scripts/DialogueBox.gd +++ b/scripts/DialogueBox.gd @@ -41,5 +41,3 @@ func _update() -> void: text.text = _dialogue[_index].text title.text = _dialogue[_index].name #expression = _dialogue[_index].expression - if _index == _dialogue.size() - 1: - emit_signal('end') diff --git a/scripts/scenes/IntroScript.gd b/scripts/scenes/IntroScript.gd index f38bc76..2270007 100644 --- a/scripts/scenes/IntroScript.gd +++ b/scripts/scenes/IntroScript.gd @@ -4,12 +4,48 @@ class_name IntroScript export (NodePath) var dialogue_box_path onready var dialogue_box = get_node(dialogue_box_path) -export (String, FILE, '*.json') var start_dialogue : String +export (NodePath) var herbert_sprite_path +onready var herbert_sprite = get_node(herbert_sprite_path) + +export (String, FILE, '*.json') var intro_dialogue : String func _ready(): assert(dialogue_box != null) + assert(herbert_sprite != null) + yield(get_tree().create_timer(2.0), 'timeout') + yield(start_dialogue(intro_dialogue), 'end') + yield(get_tree().create_timer(2.0), 'timeout') + do_crab_step() + +func start_dialogue(dialog_path : String) -> DialogueAction: var dialogue = DialogueAction.new() - dialogue.dialogue_file_path = start_dialogue + dialogue.dialogue_file_path = dialog_path dialogue.dialogue_box = dialogue_box dialogue.start() + return dialogue + + +var crab_finished = false +var crab_step = 0 +func do_crab_step(): + crab_finished = false + herbert_sprite.frame = 0 + if crab_step == 0: + herbert_sprite.connect('animation_finished', self, 'crab_animation_finished') + herbert_sprite.play('eyes') + herbert_sprite.show() + elif crab_step == 1: + herbert_sprite.play('first_step') + elif crab_step == 2: + herbert_sprite.play('second_step') + elif crab_step == 3: + herbert_sprite.hide() + crab_step += 1 + +func crab_animation_finished(): + crab_finished = true + +func _input(event): + if crab_finished && event.is_action_pressed('ui_accept'): + do_crab_step()