diff --git a/prefabs/SceneManager.tscn b/prefabs/SceneManager.tscn index 56b3c47..f907212 100644 --- a/prefabs/SceneManager.tscn +++ b/prefabs/SceneManager.tscn @@ -10,5 +10,6 @@ Scenes = { "Day3": "res://scenes/Day3.tscn", "Day4": "res://scenes/Day4.tscn", "Day5": "res://scenes/Day5.tscn", +"End": "res://scenes/TheEnd.tscn", "Menu": "res://scenes/Startup.tscn" } diff --git a/resources/sprites/ui/theend.png b/resources/sprites/ui/theend.png new file mode 100644 index 0000000..924c097 Binary files /dev/null and b/resources/sprites/ui/theend.png differ diff --git a/resources/sprites/ui/theend.png.import b/resources/sprites/ui/theend.png.import new file mode 100644 index 0000000..1f1159e --- /dev/null +++ b/resources/sprites/ui/theend.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://df3sxyo0xp880" +path="res://.godot/imported/theend.png-c5d8845d007addc993cbab5011215ccd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/sprites/ui/theend.png" +dest_files=["res://.godot/imported/theend.png-c5d8845d007addc993cbab5011215ccd.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 diff --git a/scenes/Day5.tscn b/scenes/Day5.tscn index 6a8f8f5..f3bf03e 100644 --- a/scenes/Day5.tscn +++ b/scenes/Day5.tscn @@ -55,7 +55,7 @@ stream_0 = ExtResource("10_bwdem") [node name="Test" type="Node2D"] script = ExtResource("1_ii8yu") -NextScene = "Menu" +NextScene = "End" IsEngineDisabled = false [node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/scenes/Startup.tscn b/scenes/Startup.tscn index cf18a3a..e96cb9a 100644 --- a/scenes/Startup.tscn +++ b/scenes/Startup.tscn @@ -39,9 +39,10 @@ offset_left = -160.0 offset_top = -120.0 offset_right = 160.0 offset_bottom = 120.0 -color = Color(0, 0, 0, 0) +color = Color(0, 0, 0, 1) [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = SubResource("AudioStreamPlaylist_5mfcs") +volume_db = -40.0 autoplay = true bus = &"Music" diff --git a/scenes/TheEnd.tscn b/scenes/TheEnd.tscn new file mode 100644 index 0000000..50e0ae0 --- /dev/null +++ b/scenes/TheEnd.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=6 format=3 uid="uid://1cbr4hkp06gi"] + +[ext_resource type="Script" path="res://scripts/TheEnd.cs" id="1_e2ali"] +[ext_resource type="Texture2D" uid="uid://df3sxyo0xp880" path="res://resources/sprites/ui/theend.png" id="2_io7t6"] +[ext_resource type="FontFile" uid="uid://dwn20pw40jpxm" path="res://fonts/ZxSpectrum7-nROZ0.ttf" id="3_m0xo0"] +[ext_resource type="AudioStream" uid="uid://be35iuapayv0u" path="res://resources/music/Day1.wav" id="4_4fjbh"] + +[sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_5mfcs"] +stream_count = 1 +stream_0 = ExtResource("4_4fjbh") + +[node name="TheEnd" type="Node2D"] +script = ExtResource("1_e2ali") + +[node name="Camera2D" type="Camera2D" parent="."] +zoom = Vector2(2, 2) + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_io7t6") + +[node name="Label" type="Label" parent="."] +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -56.0 +offset_top = 24.0 +offset_right = 56.0 +offset_bottom = 44.0 +grow_horizontal = 2 +theme_override_fonts/font = ExtResource("3_m0xo0") +theme_override_font_sizes/font_size = 25 +text = "THE END" + +[node name="Label2" type="Label" parent="."] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -136.0 +offset_top = -101.5 +offset_right = 136.0 +offset_bottom = -26.5 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_fonts/font = ExtResource("3_m0xo0") +theme_override_font_sizes/font_size = 10 +text = "The submarine went radio +silent for six days. The last +signal received by HQ contained nothing +but the mumblings of the captain. + +Operation \"The Unnameable\" +was canned until better times." +horizontal_alignment = 1 + +[node name="ColorRect" type="ColorRect" parent="."] +visible = false +offset_left = -160.0 +offset_top = -120.0 +offset_right = 160.0 +offset_bottom = 120.0 +color = Color(0, 0, 0, 1) + +[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] +stream = SubResource("AudioStreamPlaylist_5mfcs") +volume_db = -40.0 +autoplay = true +bus = &"Music" diff --git a/scripts/Startup.cs b/scripts/Startup.cs index d64d0fd..dda4de2 100644 --- a/scripts/Startup.cs +++ b/scripts/Startup.cs @@ -6,7 +6,8 @@ public partial class Startup : Node2D private enum State { Default, - Transition + TransitionIn, + TransitionOut } private State _state = State.Default; @@ -22,12 +23,13 @@ public partial class Startup : Node2D { _colorRect = (ColorRect)FindChild("ColorRect"); _music = (AudioStreamPlayer)FindChild("AudioStreamPlayer"); + _state = State.TransitionIn; } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _PhysicsProcess(double delta) { - if (_state == State.Transition) + if (_state == State.TransitionOut) { _transitionTimeout += delta; // _colorRect.Color = _colorRect.Color.Lerp(new Color(0, 0, 0, 255), (float)_transitionTimeout/2); @@ -38,13 +40,32 @@ public partial class Startup : Node2D GetNode("/root/SceneManager").SwitchScene("Day1"); } } + if (_state == State.TransitionIn) + { + if (_transitionTimeout < 2) + { + _transitionTimeout += delta; + // _colorRect.Color = _colorRect.Color.Lerp(new Color(0, 0, 0, 255), (float)_transitionTimeout/2); + _colorRect.Color = new Color(0, 0, 0, Mathf.Lerp(1, 0, (float)_transitionTimeout/2)); + _music.VolumeDb = Mathf.Lerp(-40, 0, (float)_transitionTimeout/2); + } + else + { + _state = State.Default; + _transitionTimeout = 0; + } + } } public override void _Input(InputEvent @event) { if (@event.IsActionPressed("Interact")) { - _state = State.Transition; + _state = State.TransitionOut; + } + if (@event.IsActionPressed("ui_cancel")) + { + GetTree().Quit(); } } } diff --git a/scripts/TheEnd.cs b/scripts/TheEnd.cs new file mode 100644 index 0000000..5628fcf --- /dev/null +++ b/scripts/TheEnd.cs @@ -0,0 +1,73 @@ +using Godot; +using System; + +public partial class TheEnd : Node2D +{ + private enum State + { + Default, + TransitionIn, + TransitionOut + } + + private State _state = State.Default; + + private ColorRect _colorRect; + + private AudioStreamPlayer _music; + + private double _transitionTimeout = 0; + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + _colorRect = (ColorRect)FindChild("ColorRect"); + _music = (AudioStreamPlayer)FindChild("AudioStreamPlayer"); + _state = State.TransitionIn; + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _PhysicsProcess(double delta) + { + if (_state == State.TransitionOut) + { + _transitionTimeout += delta; + // _colorRect.Color = _colorRect.Color.Lerp(new Color(0, 0, 0, 255), (float)_transitionTimeout/2); + _colorRect.Color = new Color(0, 0, 0, Mathf.Lerp(0, 1, (float)_transitionTimeout/2)); + _music.VolumeDb = Mathf.Lerp(0, -41, (float)_transitionTimeout/2); + if (_music.VolumeDb < -40) + { + GetNode("/root/SceneManager").SwitchScene("Menu"); + } + } + if (_state == State.TransitionIn) + { + if (_transitionTimeout < 2) + { + _transitionTimeout += delta; + // _colorRect.Color = _colorRect.Color.Lerp(new Color(0, 0, 0, 255), (float)_transitionTimeout/2); + _colorRect.Color = new Color(0, 0, 0, Mathf.Lerp(1, 0, (float)_transitionTimeout/2)); + _music.VolumeDb = Mathf.Lerp(-40, 0, (float)_transitionTimeout/2); + } + else + { + _state = State.Default; + _transitionTimeout = 0; + } + } + } + + public override void _Input(InputEvent @event) + { + if (@event.IsActionPressed("Interact")) + { + _transitionTimeout = 0; + _state = State.TransitionOut; + } + + if (@event.IsActionPressed("ui_cancel")) + { + GetTree().Quit(); + } + } +}