diff options
| -rw-r--r-- | dialogue.gd | 24 | ||||
| -rw-r--r-- | dialogue.gd.uid | 1 | ||||
| -rw-r--r-- | dialogues/test1.gd | 14 | ||||
| -rw-r--r-- | dialogues/test1.gd.uid | 1 | ||||
| -rw-r--r-- | docs/index.html | 2 | ||||
| -rw-r--r-- | docs/index.pck | bin | 3892536 -> 4604796 bytes | |||
| -rw-r--r-- | docs/index.service.worker.js | 2 | ||||
| -rw-r--r-- | room_test3.tscn | 47 | ||||
| -rw-r--r-- | text_bubble.gd | 10 | ||||
| -rw-r--r-- | text_bubble.gd.uid | 1 | ||||
| -rw-r--r-- | text_bubble.tscn | 27 |
11 files changed, 84 insertions, 45 deletions
diff --git a/dialogue.gd b/dialogue.gd new file mode 100644 index 0000000..f085ed8 --- /dev/null +++ b/dialogue.gd @@ -0,0 +1,24 @@ +class_name Dialogue +extends Node + +signal next + +@onready var parent: Node2D = get_parent() +@onready var cam: GameCamera = parent.get_node("GameCamera") + +func say(who: Object, text: String): + var tb: TextBubble = preload("res://text_bubble.tscn").instantiate() + tb.text = text + if who is Node2D: + tb.global_position = who.global_position + Vector2(0, -20) + else: + tb.global_position = cam.global_position + + tb.add_to_group("text_bubbles") + parent.add_child(tb) + await next + +func _process(_delta: float): + if Input.is_action_just_pressed("action") or Input.is_action_just_pressed("jump"): + get_tree().call_group("text_bubbles", "queue_free") + next.emit() diff --git a/dialogue.gd.uid b/dialogue.gd.uid new file mode 100644 index 0000000..f06507a --- /dev/null +++ b/dialogue.gd.uid @@ -0,0 +1 @@ +uid://djbahr0s3jkpe diff --git a/dialogues/test1.gd b/dialogues/test1.gd new file mode 100644 index 0000000..e7752b3 --- /dev/null +++ b/dialogues/test1.gd @@ -0,0 +1,14 @@ +class_name DialogueTest1 +extends Dialogue + +@onready var player: Player = parent.get_node("Player") +@onready var npc: Node2D = parent.get_node("DialogueTestNPC") + +func _ready(): + player.request_state_init() + + await say(player, "hello") + await say(npc, "well hi") + + player.request_state_normal() + print("dialogue done") diff --git a/dialogues/test1.gd.uid b/dialogues/test1.gd.uid new file mode 100644 index 0000000..57573c2 --- /dev/null +++ b/dialogues/test1.gd.uid @@ -0,0 +1 @@ +uid://23xqfts2fuwx diff --git a/docs/index.html b/docs/index.html index c80f7dd..d691280 100644 --- a/docs/index.html +++ b/docs/index.html @@ -112,7 +112,7 @@ body { <script src="index.js"></script> <script> -const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":3892536,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; +const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":4604796,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; const GODOT_THREADS_ENABLED = false; const engine = new Engine(GODOT_CONFIG); diff --git a/docs/index.pck b/docs/index.pck Binary files differindex 0c62ce4..f2465a4 100644 --- a/docs/index.pck +++ b/docs/index.pck diff --git a/docs/index.service.worker.js b/docs/index.service.worker.js index 8c9f420..5cd4eb6 100644 --- a/docs/index.service.worker.js +++ b/docs/index.service.worker.js @@ -4,7 +4,7 @@ // Incrementing CACHE_VERSION will kick off the install event and force // previously cached resources to be updated from the network. /** @type {string} */ -const CACHE_VERSION = '1764793251|2830025164'; +const CACHE_VERSION = '1764878547|12827344433'; /** @type {string} */ const CACHE_PREFIX = 'MobileMetroidvan-sw-cache-'; const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION; diff --git a/room_test3.tscn b/room_test3.tscn index f0573fb..3b29e47 100644 --- a/room_test3.tscn +++ b/room_test3.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=4 uid="uid://3o7g1rxy06sb"] +[gd_scene load_steps=14 format=4 uid="uid://3o7g1rxy06sb"] [ext_resource type="Texture2D" uid="uid://dkek11j5dh6as" path="res://assets.untracked/kenney_1-bit-platformer-pack/Tiles/Default/tile_0338.png" id="1_pwspw"] [ext_resource type="Script" uid="uid://cbhily4o7e2r3" path="res://room.gd" id="1_w1h0g"] @@ -9,7 +9,6 @@ [ext_resource type="PackedScene" uid="uid://dfyvkc2qlcdac" path="res://game_camera.tscn" id="3_w1h0g"] [ext_resource type="PackedScene" uid="uid://df0loiahar23o" path="res://door.tscn" id="6_i21us"] [ext_resource type="Texture2D" uid="uid://dwfeqystr0js4" path="res://assets.untracked/kenney_1-bit-platformer-pack/Tiles/Transparent/tile_0285.png" id="9_bplq6"] -[ext_resource type="Texture2D" uid="uid://oiqxoxuexmgu" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (Black)/tile_0000.png" id="10_rlnij"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_bml3v"] size = Vector2(7, 7) @@ -23,23 +22,9 @@ point_count = 6 [sub_resource type="GDScript" id="GDScript_bplq6"] script/source = "extends Sprite2D -var player: Player -var tb - -func _on_player_entered(p: Player) -> void: - player = p - player.request_state_init() - tb = get_parent().get_node(\"TextBubble\") - tb.visible = true - tb.add_to_group(\"camera_target\") - -func _process(_delta: float) -> void: - if player and tb and tb.visible and Input.is_action_just_pressed(\"action\"): - tb.visible = false - tb.remove_from_group(\"camera_target\") - player.request_state_normal() - player = null - tb = null +func _on_player_entered(_p: Player) -> void: + var d = DialogueTest1.new() + get_parent().add_child(d) " [sub_resource type="RectangleShape2D" id="RectangleShape2D_rlnij"] @@ -134,30 +119,6 @@ collision_mask = 2 position = Vector2(1, 1.75) shape = SubResource("RectangleShape2D_rlnij") -[node name="TextBubble" type="Node2D" parent="."] -visible = false -position = Vector2(-155, -116) - -[node name="ColorRect" type="ColorRect" parent="TextBubble"] -offset_right = 40.0 -offset_bottom = 40.0 -scale = Vector2(1.3009955, 0.30328855) -color = Color(1, 0.8980392, 0.7490196, 1) - -[node name="Label" type="Label" parent="TextBubble"] -offset_left = 4.0 -offset_top = 3.0 -offset_right = 44.0 -offset_bottom = 26.0 -scale = Vector2(0.25, 0.25) -theme_override_colors/font_color = Color(0, 0, 0, 1) -text = "yo" - -[node name="Tile0000" type="Sprite2D" parent="TextBubble"] -position = Vector2(45, 6) -scale = Vector2(0.5, 0.5) -texture = ExtResource("10_rlnij") - [connection signal="body_entered" from="Computer1/Area2D" to="Computer1" method="_on_area_2d_body_entered"] [connection signal="body_entered" from="Computer2/Area2D" to="Computer2" method="_on_area_2d_body_entered"] [connection signal="body_entered" from="DialogueTestNPC/Area2D" to="DialogueTestNPC" method="_on_player_entered"] diff --git a/text_bubble.gd b/text_bubble.gd new file mode 100644 index 0000000..545f469 --- /dev/null +++ b/text_bubble.gd @@ -0,0 +1,10 @@ +class_name TextBubble +extends Node2D + +@export var text: String + +func _ready() -> void: + $Label.text = text + +func size() -> Vector2: + return $ColorRect.size diff --git a/text_bubble.gd.uid b/text_bubble.gd.uid new file mode 100644 index 0000000..635f912 --- /dev/null +++ b/text_bubble.gd.uid @@ -0,0 +1 @@ +uid://dubgnmdd6p1rs diff --git a/text_bubble.tscn b/text_bubble.tscn new file mode 100644 index 0000000..42ead69 --- /dev/null +++ b/text_bubble.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=2 format=3 uid="uid://dglar4tto3f1s"] + +[ext_resource type="Script" uid="uid://dubgnmdd6p1rs" path="res://text_bubble.gd" id="1_bo3s3"] + +[node name="TextBubble" type="Node2D"] +script = ExtResource("1_bo3s3") + +[node name="ColorRect" type="ColorRect" parent="."] +offset_left = -26.0 +offset_top = -6.0 +offset_right = 14.0 +offset_bottom = 34.0 +scale = Vector2(1.3009955, 0.30328855) +color = Color(1, 0.8980392, 0.7490196, 1) +metadata/_edit_use_anchors_ = true + +[node name="Label" type="Label" parent="."] +offset_left = -25.0 +offset_top = -3.0 +offset_right = 174.0 +offset_bottom = 20.0 +scale = Vector2(0.25, 0.25) +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "foo" +horizontal_alignment = 1 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true |
