From 8967f6bb6e8ecb3b5b4073424692ce0ddfec61cb Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 5 Feb 2026 22:02:42 +0200 Subject: Rework cinematics --- cinematic.gd | 48 ++++++++++++++++++++++++++++++++++++++ cinematic.gd.uid | 1 + cinematics/intro.gd | 49 +++++++++++++++++++++++++++++++++++++++ cinematics/intro.gd.uid | 1 + cinematics/relic_get.gd | 26 +++++++++++++++++++++ cinematics/relic_get.gd.uid | 1 + cinematics/test1.gd | 15 ++++++++++++ cinematics/test1.gd.uid | 1 + dialogue.gd | 47 ------------------------------------- dialogue.gd.uid | 1 - dialogues/cine_intro_ship1.gd | 27 --------------------- dialogues/cine_intro_ship1.gd.uid | 1 - dialogues/relic_get.gd | 25 -------------------- dialogues/relic_get.gd.uid | 1 - dialogues/test1.gd | 16 ------------- dialogues/test1.gd.uid | 1 - relic.gd | 4 ++-- rooms/cine_intro.gd | 21 +++++------------ rooms/cine_intro.gd.uid | 2 +- rooms/cine_intro.tscn | 8 ++++--- rooms/ship1.gd | 8 ------- rooms/ship1.gd.uid | 2 +- rooms/ship1.tscn | 2 +- rooms/test2.tscn | 4 ++-- rooms/test3.tscn | 10 ++++---- top.gd | 3 +++ transition_player.gd | 8 +++++++ 27 files changed, 176 insertions(+), 157 deletions(-) create mode 100644 cinematic.gd create mode 100644 cinematic.gd.uid create mode 100644 cinematics/intro.gd create mode 100644 cinematics/intro.gd.uid create mode 100644 cinematics/relic_get.gd create mode 100644 cinematics/relic_get.gd.uid create mode 100644 cinematics/test1.gd create mode 100644 cinematics/test1.gd.uid delete mode 100644 dialogue.gd delete mode 100644 dialogue.gd.uid delete mode 100644 dialogues/cine_intro_ship1.gd delete mode 100644 dialogues/cine_intro_ship1.gd.uid delete mode 100644 dialogues/relic_get.gd delete mode 100644 dialogues/relic_get.gd.uid delete mode 100644 dialogues/test1.gd delete mode 100644 dialogues/test1.gd.uid diff --git a/cinematic.gd b/cinematic.gd new file mode 100644 index 0000000..dbc29ea --- /dev/null +++ b/cinematic.gd @@ -0,0 +1,48 @@ +class_name Cinematic +extends Node + +signal next(arg: Variant) + +@onready var top: Top = get_tree().root.get_node("Top") + +enum Type { SAY, ASK } +var type: Type + +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: + var room = top.get_active_room() + tb.global_position = room.get_node("GameCamera").global_position + + tb.add_to_group("text_bubbles") + top.add_child(tb) + type = Type.SAY + await next + +func ask(who: Object, text: String, options: Array[String]) -> String: + var tb: TextBubble = preload("res://text_bubble.tscn").instantiate() + tb.text = text + tb.options = options + tb.connect("answered", _on_answered) + if who is Node2D: + tb.global_position = who.global_position + Vector2(0, -20) + else: + var room = top.get_active_room() + tb.global_position = room.get_node("GameCamera").global_position + + tb.add_to_group("text_bubbles") + top.add_child(tb) + type = Type.ASK + return await next + +func _process(_delta: float): + if type == Type.SAY and (Input.is_action_just_pressed("action") or Input.is_action_just_pressed("jump")): + get_tree().call_group("text_bubbles", "queue_free") + next.emit() + +func _on_answered(answer: String): + get_tree().call_group("text_bubbles", "queue_free") + next.emit(answer) diff --git a/cinematic.gd.uid b/cinematic.gd.uid new file mode 100644 index 0000000..f06507a --- /dev/null +++ b/cinematic.gd.uid @@ -0,0 +1 @@ +uid://djbahr0s3jkpe diff --git a/cinematics/intro.gd b/cinematics/intro.gd new file mode 100644 index 0000000..2549088 --- /dev/null +++ b/cinematics/intro.gd @@ -0,0 +1,49 @@ +class_name CineIntro +extends Cinematic + +func _ready(): + await top.get_transition_player().transition_finished + + var ap: AnimationPlayer = top.get_active_room().get_node("AnimationPlayer") + + ap.play("cine_intro") + top.play_cine_bars() + + await ap.animation_finished + + top.get_transition_player().room_transition( + null, "res://rooms/ship1.tscn", null, + func (_player): pass) + + await ship1() + + queue_free() + +func ship1(): + await top.get_transition_player().room_changed + var room = top.get_active_room() + + var player: Player = room.get_node("Player") + var captain: Node2D = room.get_node("Captain") + var crew1: Node2D = room.get_node("Crew1") + var crew2: Node2D = room.get_node("Crew2") + + player.remove_from_group("camera_target") + + await top.get_transition_player().transition_finished + + await say(captain, "Crew!") + + player.velocity.x = -1 # flip + crew1.flip_h = true + crew2.flip_h = true + + await get_tree().create_timer(1.0).timeout + + await say(captain, "The Frogcorp Scientific Excursion commences today!") + await say(captain, "TODO") + + await top.clear_cine_bars() + + player.request_state_normal() + player.add_to_group("camera_target") diff --git a/cinematics/intro.gd.uid b/cinematics/intro.gd.uid new file mode 100644 index 0000000..a39d2f1 --- /dev/null +++ b/cinematics/intro.gd.uid @@ -0,0 +1 @@ +uid://c1brkwqi07uem diff --git a/cinematics/relic_get.gd b/cinematics/relic_get.gd new file mode 100644 index 0000000..40d3b9f --- /dev/null +++ b/cinematics/relic_get.gd @@ -0,0 +1,26 @@ +class_name CineRelicGet +extends Cinematic + +var r: Node2D + +func _init(relic: Node2D): + r = relic + +func _ready(): + var player: Player = get_room_node("Player") + var mp: AudioStreamPlayer = top.get_node("MusicPlayer") + mp.stream_paused = true + player.request_play_fanfare_sfx() + + get_tree().paused = true + + await top.play_cine_bars() + await say(r, "You found a mysterious relic!") + await top.clear_cine_bars() + + r.queue_free() + get_tree().paused = false + + mp.stream_paused = false + + queue_free() diff --git a/cinematics/relic_get.gd.uid b/cinematics/relic_get.gd.uid new file mode 100644 index 0000000..c5ed07a --- /dev/null +++ b/cinematics/relic_get.gd.uid @@ -0,0 +1 @@ +uid://j0vbra41omei diff --git a/cinematics/test1.gd b/cinematics/test1.gd new file mode 100644 index 0000000..9ef48b7 --- /dev/null +++ b/cinematics/test1.gd @@ -0,0 +1,15 @@ +class_name CinematicTest1 +extends Cinematic + +func _ready(): + var player: Player = get_room_node("Player") + var npc: Node2D = get_room_node("CinematicTestNPC") + player.request_state_forced("DROP") + + await say(player, "hello") + await say(npc, "well hi") + var answer = await ask(npc, "buy or sell?", ["buy", "sell"]) + await say(npc, "it's %s time" % answer) + + player.request_state_normal() + print("dialogue done, answer %s" % answer) diff --git a/cinematics/test1.gd.uid b/cinematics/test1.gd.uid new file mode 100644 index 0000000..57573c2 --- /dev/null +++ b/cinematics/test1.gd.uid @@ -0,0 +1 @@ +uid://23xqfts2fuwx diff --git a/dialogue.gd b/dialogue.gd deleted file mode 100644 index 311d5e2..0000000 --- a/dialogue.gd +++ /dev/null @@ -1,47 +0,0 @@ -class_name Dialogue -extends Node - -signal next(arg: Variant) - -@onready var parent: Node2D = get_parent() -@onready var cam: GameCamera = parent.get_node("GameCamera") - -enum Type { SAY, ASK } -var type: Type - -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) - type = Type.SAY - await next - -func ask(who: Object, text: String, options: Array[String]) -> String: - var tb: TextBubble = preload("res://text_bubble.tscn").instantiate() - tb.text = text - tb.options = options - tb.connect("answered", _on_answered) - 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) - type = Type.ASK - return await next - -func _process(_delta: float): - if type == Type.SAY and (Input.is_action_just_pressed("action") or Input.is_action_just_pressed("jump")): - get_tree().call_group("text_bubbles", "queue_free") - next.emit() - -func _on_answered(answer: String): - get_tree().call_group("text_bubbles", "queue_free") - next.emit(answer) diff --git a/dialogue.gd.uid b/dialogue.gd.uid deleted file mode 100644 index f06507a..0000000 --- a/dialogue.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://djbahr0s3jkpe diff --git a/dialogues/cine_intro_ship1.gd b/dialogues/cine_intro_ship1.gd deleted file mode 100644 index fb9a5e4..0000000 --- a/dialogues/cine_intro_ship1.gd +++ /dev/null @@ -1,27 +0,0 @@ -class_name DialogueCineIntroShip1 -extends Dialogue - -@onready var top: Top = get_tree().root.get_node("Top") -@onready var player: Player = parent.get_node("Player") -@onready var captain: Node2D = parent.get_node("Captain") -@onready var crew1: Node2D = parent.get_node("Crew1") -@onready var crew2: Node2D = parent.get_node("Crew2") - -func _ready(): - player.remove_from_group("camera_target") - - await say(captain, "Crew!") - - player.velocity.x = -1 # flip - crew1.flip_h = true - crew2.flip_h = true - - await get_tree().create_timer(1.0).timeout - - await say(captain, "The Frogcorp Scientific Excursion commences today!") - await say(captain, "TODO") - - await top.clear_cine_bars() - - player.request_state_normal() - player.add_to_group("camera_target") diff --git a/dialogues/cine_intro_ship1.gd.uid b/dialogues/cine_intro_ship1.gd.uid deleted file mode 100644 index 50d36eb..0000000 --- a/dialogues/cine_intro_ship1.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bgtapiu3u8vre diff --git a/dialogues/relic_get.gd b/dialogues/relic_get.gd deleted file mode 100644 index a086c36..0000000 --- a/dialogues/relic_get.gd +++ /dev/null @@ -1,25 +0,0 @@ -class_name DialogueRelicGet -extends Dialogue - -@onready var top: Top = get_tree().root.get_node("Top") -@onready var player: Player = parent.get_node("Player") -var r: Node2D - -func _init(relic: Node2D): - r = relic - -func _ready(): - var mp: AudioStreamPlayer = top.get_node("MusicPlayer") - mp.stream_paused = true - player.request_play_fanfare_sfx() - - get_tree().paused = true - - await top.play_cine_bars() - await say(r, "You found a mysterious relic!") - await top.clear_cine_bars() - - r.queue_free() - get_tree().paused = false - - mp.stream_paused = false diff --git a/dialogues/relic_get.gd.uid b/dialogues/relic_get.gd.uid deleted file mode 100644 index c5ed07a..0000000 --- a/dialogues/relic_get.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://j0vbra41omei diff --git a/dialogues/test1.gd b/dialogues/test1.gd deleted file mode 100644 index d411484..0000000 --- a/dialogues/test1.gd +++ /dev/null @@ -1,16 +0,0 @@ -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_forced("DROP") - - await say(player, "hello") - await say(npc, "well hi") - var answer = await ask(npc, "buy or sell?", ["buy", "sell"]) - await say(npc, "it's %s time" % answer) - - player.request_state_normal() - print("dialogue done, answer %s" % answer) diff --git a/dialogues/test1.gd.uid b/dialogues/test1.gd.uid deleted file mode 100644 index 57573c2..0000000 --- a/dialogues/test1.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://23xqfts2fuwx diff --git a/relic.gd b/relic.gd index 6af3405..ea7c47c 100644 --- a/relic.gd +++ b/relic.gd @@ -31,6 +31,6 @@ func _on_area_2d_body_entered(player: Player) -> void: if already_got: queue_free() else: - var dia = DialogueRelicGet.new(self) + var dia = CineRelicGet.new(self) dia.process_mode = Node.PROCESS_MODE_ALWAYS - get_parent().add_child(dia) + top.add_child(dia) diff --git a/rooms/cine_intro.gd b/rooms/cine_intro.gd index fc6c881..5c08744 100644 --- a/rooms/cine_intro.gd +++ b/rooms/cine_intro.gd @@ -1,18 +1,9 @@ -class_name CineIntro -extends Node2D +class_name RoomCineIntro +extends Room +@onready var top: Top = get_tree().root.get_node("Top") +# Called when the node enters the scene tree for the first time. func _ready() -> void: - run() - -func run(): - var top: Top = get_tree().root.get_node("Top") - - $AnimationPlayer.play("cine_intro") - await get_tree().create_timer(0.5).timeout - top.play_cine_bars() - - await $AnimationPlayer.animation_finished - - top.get_transition_player().room_transition(null, "res://rooms/ship1.tscn", null, - func (_player): pass) + var cine = CineIntro.new() + top.add_child(cine) diff --git a/rooms/cine_intro.gd.uid b/rooms/cine_intro.gd.uid index a39d2f1..28f4a85 100644 --- a/rooms/cine_intro.gd.uid +++ b/rooms/cine_intro.gd.uid @@ -1 +1 @@ -uid://c1brkwqi07uem +uid://smifdf5yqj8r diff --git a/rooms/cine_intro.tscn b/rooms/cine_intro.tscn index f35adb5..5874c20 100644 --- a/rooms/cine_intro.tscn +++ b/rooms/cine_intro.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=13 format=4 uid="uid://b0ovj5ki7tg3s"] [ext_resource type="PackedScene" uid="uid://dfyvkc2qlcdac" path="res://game_camera.tscn" id="1_1pf6u"] -[ext_resource type="Script" uid="uid://c1brkwqi07uem" path="res://rooms/cine_intro.gd" id="1_678l5"] +[ext_resource type="Script" uid="uid://smifdf5yqj8r" path="res://rooms/cine_intro.gd" id="1_678l5"] [ext_resource type="Texture2D" uid="uid://dngaqobccmxtx" path="res://assets/redshipr.png" id="2_678l5"] [ext_resource type="Texture2D" uid="uid://dyg22seb4ktom" path="res://assets.untracked/kenney_1-bit-platformer-pack/Tiles/Transparent/tile_0296.png" id="3_ig0ct"] [ext_resource type="TileSet" uid="uid://0cd30n67d6k5" path="res://tileset_kenney_platformer.tres" id="4_bawvl"] @@ -42,7 +42,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Color(1, 1, 1, 1)] +"values": [Color(1, 1, 1, 0)] } tracks/1/type = "value" tracks/1/imported = false @@ -54,7 +54,7 @@ tracks/1/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Color(1, 1, 1, 1)] +"values": [Color(1, 1, 1, 0)] } tracks/2/type = "value" tracks/2/imported = false @@ -159,10 +159,12 @@ texture = ExtResource("3_ig0ct") process_material = SubResource("ParticleProcessMaterial_dfwsi") [node name="TileMapLayer" type="TileMapLayer" parent="."] +modulate = Color(1, 1, 1, 0) tile_map_data = PackedByteArray("AAD//wYAAwANAAAAAAAAAAYAAwANAAAAAAABAAYAAwANAAAAAAADAAQAAwANAAAAAAAFAAUAAwANAAAAAAAGAAUAAwANAAAAAAAJAAMAAwANAAAAAAAKAAMAAwANAAAAAAALAAMAAwANAAAAAAAKAAQAAwANAAAAAAAKAAYAAwANAAAAAAALAAYAAwANAAAAAAAMAAYAAwANAAAAAAABAAMAAwANAAAAAAAAAAAAAwAAAAEAAAAGAP//AwAAAAEAAAAJAAAAAwAAAAEAAAAEAAAAAwAAAAEAAAABAAEAAwAAAAEAAAAMAP//AwAAAAEAAAABAP3/AwAAAAEAAAAEAP7/AwAAAAEAAAAIAPv/AwAAAAEAAAALAPz/AwAAAAEAAAALAPj/AwAAAAEAAAAHAPf/AwAAAAEAAAAGAPr/AwAAAAEAAAADAPz/AwAAAAEAAAD///n/AwAAAAEAAAD+//3/AwAAAAEAAAACAPf/AwAAAAEAAAAHAPX/AwAAAAEAAAAJAPb/AwAAAAEAAAADAPT/AwAAAAEAAAAAAPT/AwAAAAEAAAD///b/AwAAAAEAAAAMAPT/AwAAAAEAAAAMAPn/AwAAAAEAAAA=") tile_set = ExtResource("4_bawvl") [node name="InLowOrbit" type="Label" parent="."] +modulate = Color(1, 1, 1, 0) offset_left = -24.0 offset_top = -121.0 offset_right = 456.0 diff --git a/rooms/ship1.gd b/rooms/ship1.gd index ce25a30..93f3ddd 100644 --- a/rooms/ship1.gd +++ b/rooms/ship1.gd @@ -1,10 +1,2 @@ class_name RoomShip1 extends Room - -@onready var top: Top = get_tree().root.get_node("Top") -@onready var player: Player = $Player - -func _ready() -> void: - if not top.inventory.cine_intro_done: - var dia = DialogueCineIntroShip1.new() - add_child(dia) diff --git a/rooms/ship1.gd.uid b/rooms/ship1.gd.uid index e99461f..4440676 100644 --- a/rooms/ship1.gd.uid +++ b/rooms/ship1.gd.uid @@ -1 +1 @@ -uid://u860i6080apx +uid://cxclie8hu2iei diff --git a/rooms/ship1.tscn b/rooms/ship1.tscn index b91d846..6af7ecb 100644 --- a/rooms/ship1.tscn +++ b/rooms/ship1.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=8 format=4 uid="uid://d1cs3f3is4ueq"] -[ext_resource type="Script" uid="uid://u860i6080apx" path="res://rooms/ship1.gd" id="1_b0bog"] +[ext_resource type="Script" uid="uid://cxclie8hu2iei" path="res://rooms/ship1.gd" id="1_b0bog"] [ext_resource type="Texture2D" uid="uid://7hiwc37lcc7e" path="res://assets.untracked/kenney_1-bit-platformer-pack/Tiles/Default/tile_0011.png" id="2_b0bog"] [ext_resource type="TileSet" uid="uid://0cd30n67d6k5" path="res://tileset_kenney_platformer.tres" id="3_vy3ys"] [ext_resource type="PackedScene" uid="uid://dfyvkc2qlcdac" path="res://game_camera.tscn" id="4_k7i86"] diff --git a/rooms/test2.tscn b/rooms/test2.tscn index 2facbd8..c62b602 100644 --- a/rooms/test2.tscn +++ b/rooms/test2.tscn @@ -103,10 +103,10 @@ func _physics_process(delta: float) -> void: func _on_player_entered(_player: Player) -> void: oscing = false - var dia = DialogueGotAbilities.new(self) + var dia = CinematicGotAbilities.new(self) get_parent().add_child(dia) -class DialogueGotAbilities extends Dialogue: +class CinematicGotAbilities extends Cinematic: @onready var player: Player = parent.get_node(\"Player\") @onready var top: Top = get_tree().root.get_node(\"Top\") diff --git a/rooms/test3.tscn b/rooms/test3.tscn index d8857d4..185907a 100644 --- a/rooms/test3.tscn +++ b/rooms/test3.tscn @@ -23,7 +23,7 @@ point_count = 6 script/source = "extends Sprite2D func _on_player_entered(_p: Player) -> void: - var d = DialogueTest1.new() + var d = CinematicTest1.new() get_parent().add_child(d) " @@ -105,20 +105,20 @@ target_door = "DoorLeft" [node name="ComputerPath" type="Path2D" parent="."] curve = SubResource("Curve2D_bml3v") -[node name="DialogueTestNPC" type="Sprite2D" parent="."] +[node name="CinematicTestNPC" type="Sprite2D" parent="."] modulate = Color(0.30980393, 1, 1, 1) position = Vector2(-104, -56) texture = ExtResource("9_i0ft4") script = SubResource("GDScript_bplq6") -[node name="Area2D" type="Area2D" parent="DialogueTestNPC"] +[node name="Area2D" type="Area2D" parent="CinematicTestNPC"] collision_layer = 32 collision_mask = 2 -[node name="CollisionShape2D" type="CollisionShape2D" parent="DialogueTestNPC/Area2D"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="CinematicTestNPC/Area2D"] position = Vector2(1, 1.75) shape = SubResource("RectangleShape2D_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"] +[connection signal="body_entered" from="CinematicTestNPC/Area2D" to="CinematicTestNPC" method="_on_player_entered"] diff --git a/top.gd b/top.gd index 49d4303..14c274d 100644 --- a/top.gd +++ b/top.gd @@ -52,6 +52,9 @@ func replace_active_room(new_room: Node, on_changed: Callable): new_room.process_mode = Node.PROCESS_MODE_PAUSABLE add_child(new_room) +func get_active_room() -> Room: + return get_node("ActiveRoom") + func get_transition_player() -> TransitionPlayer: return $TransitionPlayer diff --git a/transition_player.gd b/transition_player.gd index ba719eb..080d3ef 100644 --- a/transition_player.gd +++ b/transition_player.gd @@ -1,6 +1,9 @@ class_name TransitionPlayer extends AnimationPlayer +signal transition_finished +signal room_changed + var _transition_room: Node var _transition_door_name: Variant # String or null var _override_player_fn: Variant # Callable or null @@ -33,6 +36,8 @@ func room_transition(from_door: Door, top.game_set(Top.SAVE_ACTIVE_ROOM_PATH, to_room_path) top.game_set(Top.SAVE_LAST_DOOR_NAME, door_name) + await transition_finished + func _transition_start(): var top: Top = get_tree().root.get_node("Top") @@ -55,6 +60,7 @@ func _on_room_changed(): top.game_save() play("room_trans_end") + room_changed.emit() func _transition_end(): var top: Top = get_tree().root.get_node("Top") @@ -69,3 +75,5 @@ func _transition_end(): player.request_state_normal() _override_player_fn = null + + transition_finished.emit() -- cgit v1.3