diff --git a/README.md b/README.md index 973b1526..4888d942 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,4 @@ Current team members include: #### Attributions: First Song: gameMusic by Magntron - freesound.org -Input buttons by Nicolae (Xelu) Berbece - - +Input buttons by Nicolae (Xelu) Berbece \ No newline at end of file diff --git a/scenes/BattleDirector/NotePlacementBar.tscn b/scenes/BattleDirector/NotePlacementBar.tscn index 9e3ee4f9..008d7d01 100644 --- a/scenes/BattleDirector/NotePlacementBar.tscn +++ b/scenes/BattleDirector/NotePlacementBar.tscn @@ -23,7 +23,7 @@ width = 32 height = 98 fill_to = Vector2(0, 1) -[node name="NotePlacementBar" type="Control" node_paths=PackedStringArray("notePlacementBar", "currentComboMultText", "_currentNote", "_nextNote")] +[node name="NotePlacementBar" type="Control" node_paths=PackedStringArray("notePlacementBar", "currentComboMultText", "_currentNote", "_nextNote", "fullBarParticles")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -35,6 +35,7 @@ notePlacementBar = NodePath("ProgressBar") currentComboMultText = NodePath("TextEdit") _currentNote = NodePath("NoteQueueSprite/NextNote") _nextNote = NodePath("NoteQueueSprite/CurrentNote") +fullBarParticles = NodePath("ProgressBar/CPUParticles2D") [node name="ProgressBar" type="TextureProgressBar" parent="."] layout_mode = 0 @@ -47,6 +48,19 @@ texture_under = SubResource("GradientTexture2D_hhds4") texture_progress = SubResource("GradientTexture2D_0bqho") texture_progress_offset = Vector2(1, 1) +[node name="CPUParticles2D" type="CPUParticles2D" parent="ProgressBar"] +position = Vector2(14, 98) +emitting = false +amount = 10 +lifetime = 1.5 +direction = Vector2(0, -1) +spread = 15.0 +gravity = Vector2(0, 0) +initial_velocity_min = 25.0 +initial_velocity_max = 50.0 +scale_amount_max = 2.0 +color = Color(1, 1, 0.0745098, 1) + [node name="TextEdit" type="TextEdit" parent="."] z_as_relative = false layout_mode = 0 diff --git a/scenes/BattleDirector/scripts/BattleDirector.cs b/scenes/BattleDirector/scripts/BattleDirector.cs index bde2fff5..1d18e178 100644 --- a/scenes/BattleDirector/scripts/BattleDirector.cs +++ b/scenes/BattleDirector/scripts/BattleDirector.cs @@ -169,9 +169,11 @@ private void OnTimedInput(Note note, ArrowType arrowType, int beat, double beatD else { note.OnHit(this, timed); + NotePlacementBar.HitNote(); } - NotePlacementBar.ComboText(timed.ToString()); + //NotePlacementBar.ComboText(timed.ToString()); + CM.ComboText(timed.ToString(), arrowType, NotePlacementBar.GetCurrentCombo()); } private Timing CheckTiming(double beatDif) diff --git a/scenes/BattleDirector/scripts/NotePlacementBar.cs b/scenes/BattleDirector/scripts/NotePlacementBar.cs index 6baf765f..2d0a1f84 100644 --- a/scenes/BattleDirector/scripts/NotePlacementBar.cs +++ b/scenes/BattleDirector/scripts/NotePlacementBar.cs @@ -24,6 +24,9 @@ public partial class NotePlacementBar : Node [Export] private Sprite2D _nextNote; + [Export] + private CpuParticles2D fullBarParticles; + private Note[] _noteDeck; private Queue _noteQueue = new Queue(); @@ -105,13 +108,6 @@ private Note GetNote(bool getNextNote = false) return result; } - public void ComboText(string text) - { - TextParticle newText = new TextParticle(); - AddChild(newText); - newText.Text = text + $" {_currentCombo}"; - } - // Hitting a note increases combo, combo mult, and note placement bar public void HitNote() { @@ -120,6 +116,7 @@ public void HitNote() _currentBarValue = Math.Min(_currentBarValue + comboMult, MaxValue); UpdateNotePlacementBar(_currentBarValue); UpdateComboMultText(); + //fullBarParticles.Emitting = CanPlaceNote(); } // Missing a note resets combo @@ -136,6 +133,7 @@ public Note PlacedNote() _currentBarValue -= (int)(_currentNoteInstance.CostModifier * MaxValue); UpdateNotePlacementBar(_currentBarValue); + //fullBarParticles.Emitting = false; return GetNote(); } @@ -149,6 +147,11 @@ private void DetermineComboMult() comboMult = _currentCombo / notesToIncreaseCombo + 1; } + public int GetCurrentCombo() + { + return _currentCombo; + } + private void UpdateNotePlacementBar(int newValue) { notePlacementBar.Value = newValue; diff --git a/scenes/BattleDirector/scripts/TextParticle.cs b/scenes/BattleDirector/scripts/TextParticle.cs index 2931ae01..b582f353 100644 --- a/scenes/BattleDirector/scripts/TextParticle.cs +++ b/scenes/BattleDirector/scripts/TextParticle.cs @@ -9,12 +9,13 @@ public override void _Ready() Tween tween = GetTree().CreateTween(); ZIndex = 2; Position += Vector2.Left * (GD.Randf() * 40 - 20); - tween.SetTrans(Tween.TransitionType.Quad); + tween.SetTrans(Tween.TransitionType.Elastic); tween.SetEase(Tween.EaseType.Out); - tween.TweenProperty(this, "position", Position + Vector2.Up * 10, .5f); - tween.TweenProperty(this, "position", Position + Vector2.Down * 20, .5f); + tween.TweenProperty(this, "position", Position + Vector2.Up * 10, .25f).AsRelative(); + tween.TweenProperty(this, "position", Position + Vector2.Down * 20, .1f).AsRelative(); tween.SetParallel(); - tween.TweenProperty(this, "modulate:a", 0, 1f); + tween.SetTrans(Tween.TransitionType.Quad); + tween.TweenProperty(this, "modulate:a", 0, .15f); tween.SetParallel(false); tween.TweenCallback(Callable.From(QueueFree)); } diff --git a/scenes/ChartViewport/ChartViewport.tscn b/scenes/ChartViewport/ChartViewport.tscn index 8cfc9b5d..565a7096 100644 --- a/scenes/ChartViewport/ChartViewport.tscn +++ b/scenes/ChartViewport/ChartViewport.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://dfevfib11kou1"] -[ext_resource type="Script" path="res://scenes/ChartViewport/ChartManager.cs" id="1_ruh2l"] +[ext_resource type="Script" path="res://scenes/ChartViewport/scripts/ChartManager.cs" id="1_ruh2l"] [ext_resource type="Texture2D" uid="uid://cp78odda2doab" path="res://scenes/ChartViewport/LoopMarker.png" id="2_q5cjc"] -[ext_resource type="Script" path="res://scenes/ChartViewport/Loopable.cs" id="3_5u57h"] +[ext_resource type="Script" path="res://scenes/ChartViewport/scripts/Loopable.cs" id="3_5u57h"] [ext_resource type="PackedScene" uid="uid://bn8txx53xlguw" path="res://scenes/NoteManager/note_manager.tscn" id="4_fd5fw"] [ext_resource type="Shader" path="res://scenes/ChartViewport/StarryNight.gdshader" id="5_kqrxg"] @@ -30,6 +30,7 @@ position = Vector2(-50, 0) anchor_mode = 0 [node name="StarShader" type="ColorRect" parent="SubViewport"] +z_index = -1 material = SubResource("ShaderMaterial_5uw0y") offset_left = -60.0 offset_right = 415.0 diff --git a/scenes/ChartViewport/hit_particles.tscn b/scenes/ChartViewport/hit_particles.tscn new file mode 100644 index 00000000..30a4f3ec --- /dev/null +++ b/scenes/ChartViewport/hit_particles.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=3 uid="uid://bcf6vs4aqoxr5"] + +[ext_resource type="Script" path="res://scenes/ChartViewport/scripts/HitParticles.cs" id="1_tr2t2"] + +[node name="HitParticles" type="CPUParticles2D"] +z_index = -1 +emitting = false +amount = 1 +lifetime = 0.25 +speed_scale = 2.01 +explosiveness = 0.5 +spread = 180.0 +gravity = Vector2(0, 0) +initial_velocity_min = 50.0 +initial_velocity_max = 200.0 +scale_amount_max = 2.0 +script = ExtResource("1_tr2t2") diff --git a/scenes/ChartViewport/ChartManager.cs b/scenes/ChartViewport/scripts/ChartManager.cs similarity index 92% rename from scenes/ChartViewport/ChartManager.cs rename to scenes/ChartViewport/scripts/ChartManager.cs index 9b0baa0e..12866ea3 100644 --- a/scenes/ChartViewport/ChartManager.cs +++ b/scenes/ChartViewport/scripts/ChartManager.cs @@ -114,6 +114,15 @@ private NoteArrow CreateNote(ArrowType arrow, Note note, int beat = 0) return newArrow; } + public void ComboText(string text, ArrowType arrow, int currentCombo) + { + TextParticle newText = new TextParticle(); + AddChild(newText); + newText.Position = IH.Arrows[(int)arrow].Node.Position - newText.Size/2; + IH.FeedbackEffect(arrow, text); + newText.Text = text + $" {currentCombo}"; + } + public override void _ExitTree() { GD.Print("[DEBUG] Stopping tweens before exiting the scene..."); diff --git a/scenes/ChartViewport/scripts/HitParticles.cs b/scenes/ChartViewport/scripts/HitParticles.cs new file mode 100644 index 00000000..3f8710ee --- /dev/null +++ b/scenes/ChartViewport/scripts/HitParticles.cs @@ -0,0 +1,25 @@ +using System; +using Godot; + +public partial class HitParticles : CpuParticles2D +{ + public void Emit(int particleAmount) + { + // Apply the particle amount and start emitting + Amount = particleAmount; + Emitting = true; + + // Stop particles after a short delay using a Timer + Timer timer = new Timer(); + timer.WaitTime = 0.25f; // Stop emitting after 0.5 seconds + timer.OneShot = true; + timer.Timeout += () => + { + Emitting = false; + timer.QueueFree(); // Clean up the timer + }; + + AddChild(timer); + timer.Start(); + } +} diff --git a/scenes/ChartViewport/Loopable.cs b/scenes/ChartViewport/scripts/Loopable.cs similarity index 100% rename from scenes/ChartViewport/Loopable.cs rename to scenes/ChartViewport/scripts/Loopable.cs diff --git a/scenes/NoteManager/note_manager.tscn b/scenes/NoteManager/note_manager.tscn index a208cde1..8db5a94e 100644 --- a/scenes/NoteManager/note_manager.tscn +++ b/scenes/NoteManager/note_manager.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=6 format=3 uid="uid://bn8txx53xlguw"] +[gd_scene load_steps=7 format=3 uid="uid://bn8txx53xlguw"] [ext_resource type="Script" path="res://scenes/NoteManager/scripts/InputHandler.cs" id="1_2oeuf"] [ext_resource type="Texture2D" uid="uid://hfxynr5jdgsp" path="res://scenes/NoteManager/assets/new_arrow.png" id="2_pb1qk"] [ext_resource type="Script" path="res://scenes/NoteManager/scripts/NoteChecker.cs" id="3_0cioe"] [ext_resource type="Texture2D" uid="uid://cgq2ar3pdmkac" path="res://scenes/NoteManager/assets/arrow_outline.png" id="4_3mttx"] [ext_resource type="Texture2D" uid="uid://b0tvsewgnf2x7" path="res://icon.svg" id="4_foklt"] +[ext_resource type="PackedScene" uid="uid://bcf6vs4aqoxr5" path="res://scenes/ChartViewport/hit_particles.tscn" id="5_jv1tr"] [node name="noteManager" type="Node2D"] script = ExtResource("1_2oeuf") @@ -21,6 +22,8 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" parent="noteCheckers/arrowLeft" instance=ExtResource("5_jv1tr")] + [node name="arrowUp" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 68) rotation = -1.5708 @@ -31,6 +34,8 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" parent="noteCheckers/arrowUp" instance=ExtResource("5_jv1tr")] + [node name="arrowDown" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 112) rotation = 1.5708 @@ -41,6 +46,8 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" parent="noteCheckers/arrowDown" instance=ExtResource("5_jv1tr")] + [node name="arrowRight" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 151) texture = ExtResource("2_pb1qk") @@ -50,6 +57,8 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" parent="noteCheckers/arrowRight" instance=ExtResource("5_jv1tr")] + [node name="ui" type="Node2D" parent="."] [node name="dividers" type="Node2D" parent="ui"] diff --git a/scenes/NoteManager/scripts/InputHandler.cs b/scenes/NoteManager/scripts/InputHandler.cs index 7ca5a689..4bc8f85c 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -53,6 +53,31 @@ private void InitializeArrowCheckers() } } + public void FeedbackEffect(ArrowType arrow, string text) + { + // Get the particle node for this arrow + var particles = Arrows[(int)arrow].Node.Particles; + + // Set the particle amount based on timing + int particleAmount; + switch (text) + { + case "Perfect": + particleAmount = 10; // A lot of particles for Perfect + break; + case "Great": + particleAmount = 7; // Moderate amount for Great + break; + case "Good": + particleAmount = 4; // Few particles for Good + break; + default: + return; // No particles for a miss + } + + particles.Emit(particleAmount); + } + public override void _Ready() { InitializeArrowCheckers(); diff --git a/scenes/NoteManager/scripts/NoteChecker.cs b/scenes/NoteManager/scripts/NoteChecker.cs index 8a32a5dc..c650a07d 100644 --- a/scenes/NoteManager/scripts/NoteChecker.cs +++ b/scenes/NoteManager/scripts/NoteChecker.cs @@ -6,6 +6,7 @@ public partial class NoteChecker : Sprite2D private bool _isPressed; private Color _color; private float _fadeTime = 2.0f; + public HitParticles Particles; public override void _Process(double delta) { @@ -25,7 +26,8 @@ public void SetPressed(bool pressed) public void SetColor(Color color) { _color = color; - + Particles = GetNode("HitParticles"); + Particles.Modulate = color; SelfModulate = new Color(_color.R * 0.5f, _color.G * 0.5f, _color.B * 0.5f, 1); } }