From e383446249f0f6dc537efc6c6f0715a01c7b7827 Mon Sep 17 00:00:00 2001 From: Rmojarro1 <48000819+Rmojarro1@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:12:19 -0800 Subject: [PATCH 1/5] WIP changes, needs lots of improvement Moved comboText function to chartmanger, adjusted call in BD accordingly, combotext calls a feedback color function in input handler, still needs lots of work to produce the desirted colors/effects --- .../BattleDirector/scripts/BattleDirector.cs | 4 +- .../scripts/NotePlacementBar.cs | 12 ++--- scenes/ChartViewport/ChartManager.cs | 9 ++++ scenes/NoteManager/scripts/InputHandler.cs | 49 +++++++++++++++++++ 4 files changed, 66 insertions(+), 8 deletions(-) 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..b17bb7d2 100644 --- a/scenes/BattleDirector/scripts/NotePlacementBar.cs +++ b/scenes/BattleDirector/scripts/NotePlacementBar.cs @@ -105,13 +105,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() { @@ -149,6 +142,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/ChartViewport/ChartManager.cs b/scenes/ChartViewport/ChartManager.cs index 9b0baa0e..e2f30cb8 100644 --- a/scenes/ChartViewport/ChartManager.cs +++ b/scenes/ChartViewport/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); + //IH.Arrows[(int)arrow].Node.AddChild(newText); + IH.FeedbackColor(arrow, text); + newText.Text = text + $" {currentCombo}"; + } + public override void _ExitTree() { GD.Print("[DEBUG] Stopping tweens before exiting the scene..."); diff --git a/scenes/NoteManager/scripts/InputHandler.cs b/scenes/NoteManager/scripts/InputHandler.cs index b1961d4d..a4be1e51 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -15,6 +15,9 @@ public partial class InputHandler : Node2D [Signal] public delegate void NoteReleasedEventHandler(ArrowType arrowType); + private Dictionary originalColors = new Dictionary(); + private Dictionary colorTweens = new Dictionary(); + public ArrowData[] Arrows = new ArrowData[] { new ArrowData() @@ -50,6 +53,52 @@ private void InitializeArrowCheckers() { Arrows[i].Node = GetNode("noteCheckers/" + Arrows[i].Key); Arrows[i].Node.SetColor(Arrows[i].Color); + + originalColors[Arrows[i].Type] = Arrows[i].Color; + GD.Print($"Initialized Arrow: {Arrows[i].Type}, Node: {Arrows[i].Node.Name}"); + } + } + + public void FeedbackColor(ArrowType arrow, string text) + { + GD.Print($"FeedbackColor called for {arrow} with timing: {text}"); + + foreach (var arrowData in Arrows) + { + if (arrow == arrowData.Type) + { + Color feedbackColor; + float duration = 0.25f; // Short, snappy feedback duration + + // Determine vibrant feedback color based on timing + if (text == "Perfect") + { + feedbackColor = new Color(1.0f, 0.85f, 0.2f, 1.0f); // Vibrant Gold/Yellow + } + else if (text == "Good") + { + feedbackColor = new Color(0.0f, 1.0f, 1.0f, 1.0f); // Bright Cyan + } + else if (text == "Okay") + { + feedbackColor = new Color(1.0f, 0.0f, 1.0f, 0.9f); // Vibrant Magenta + } + else + { + feedbackColor = arrowData.Color; // Default to original color if no match + } + + // Apply the feedback color instantly + arrowData.Node.SetColor(feedbackColor); + GD.Print($"Setting {arrowData.Type} to {feedbackColor}"); + + // Create a Tween and reset to original color smoothly + var tween = CreateTween(); + tween.SetTrans(Tween.TransitionType.Sine); + tween.SetEase(Tween.EaseType.Out); + + tween.TweenProperty(arrowData.Node, "modulate", originalColors[arrow], duration); + } } } From 6a310795cd833472f734e7a2eab3c7f363fb2f45 Mon Sep 17 00:00:00 2001 From: Rmojarro1 <48000819+Rmojarro1@users.noreply.github.com> Date: Wed, 26 Feb 2025 11:12:29 -0800 Subject: [PATCH 2/5] Added particles that emit on hits Color approach wasn't working, so I switched to particles, seems to be more effective. On hit, yellow particles will briefly emit from the note, the amount will change depending on quality of hit. Added CpuParticle2D nodes to each note in NoteChart. Still tweaking size/amount/speed of particles, will change name of the function from FeedbackColor to something more appropaite. Should also try to add something similar for when the combo bar is full too --- scenes/NoteManager/note_manager.tscn | 48 +++++++++++++ scenes/NoteManager/scripts/InputHandler.cs | 80 ++++++++++++---------- 2 files changed, 91 insertions(+), 37 deletions(-) diff --git a/scenes/NoteManager/note_manager.tscn b/scenes/NoteManager/note_manager.tscn index a208cde1..1014af2f 100644 --- a/scenes/NoteManager/note_manager.tscn +++ b/scenes/NoteManager/note_manager.tscn @@ -21,6 +21,18 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowLeft"] +emitting = false +amount = 1 +lifetime = 0.25 +speed_scale = 2.01 +spread = 180.0 +gravity = Vector2(0, 0) +initial_velocity_min = 50.0 +initial_velocity_max = 200.0 +scale_amount_max = 2.0 +color = Color(0.975142, 0.975142, 7.70092e-06, 1) + [node name="arrowUp" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 68) rotation = -1.5708 @@ -31,6 +43,18 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowUp"] +emitting = false +amount = 1 +lifetime = 0.25 +speed_scale = 2.01 +spread = 180.0 +gravity = Vector2(0, 0) +initial_velocity_min = 50.0 +initial_velocity_max = 200.0 +scale_amount_max = 2.0 +color = Color(0.975142, 0.975142, 7.70092e-06, 1) + [node name="arrowDown" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 112) rotation = 1.5708 @@ -41,6 +65,18 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowDown"] +emitting = false +amount = 1 +lifetime = 0.25 +speed_scale = 2.01 +spread = 180.0 +gravity = Vector2(0, 0) +initial_velocity_min = 50.0 +initial_velocity_max = 200.0 +scale_amount_max = 2.0 +color = Color(0.975142, 0.975142, 7.70092e-06, 1) + [node name="arrowRight" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 151) texture = ExtResource("2_pb1qk") @@ -50,6 +86,18 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") +[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowRight"] +emitting = false +amount = 1 +lifetime = 0.25 +speed_scale = 2.01 +spread = 180.0 +gravity = Vector2(0, 0) +initial_velocity_min = 50.0 +initial_velocity_max = 200.0 +scale_amount_max = 2.0 +color = Color(0.975142, 0.975142, 7.70092e-06, 1) + [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 a4be1e51..9727ffbf 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -15,8 +15,9 @@ public partial class InputHandler : Node2D [Signal] public delegate void NoteReleasedEventHandler(ArrowType arrowType); - private Dictionary originalColors = new Dictionary(); - private Dictionary colorTweens = new Dictionary(); + // Dictionary to store Particles2D nodes for each arrow + private Dictionary hitParticles = + new Dictionary(); public ArrowData[] Arrows = new ArrowData[] { @@ -54,51 +55,56 @@ private void InitializeArrowCheckers() Arrows[i].Node = GetNode("noteCheckers/" + Arrows[i].Key); Arrows[i].Node.SetColor(Arrows[i].Color); - originalColors[Arrows[i].Type] = Arrows[i].Color; - GD.Print($"Initialized Arrow: {Arrows[i].Type}, Node: {Arrows[i].Node.Name}"); + var particles = Arrows[i].Node.GetNode("HitParticles"); + particles.Emitting = false; + hitParticles[Arrows[i].Type] = particles; } } public void FeedbackColor(ArrowType arrow, string text) { - GD.Print($"FeedbackColor called for {arrow} with timing: {text}"); - - foreach (var arrowData in Arrows) + if (hitParticles.ContainsKey(arrow)) { - if (arrow == arrowData.Type) - { - Color feedbackColor; - float duration = 0.25f; // Short, snappy feedback duration + // Get the particle node for this arrow + var particles = hitParticles[arrow]; - // Determine vibrant feedback color based on timing - if (text == "Perfect") - { - feedbackColor = new Color(1.0f, 0.85f, 0.2f, 1.0f); // Vibrant Gold/Yellow - } - else if (text == "Good") - { - feedbackColor = new Color(0.0f, 1.0f, 1.0f, 1.0f); // Bright Cyan - } - else if (text == "Okay") - { - feedbackColor = new Color(1.0f, 0.0f, 1.0f, 0.9f); // Vibrant Magenta - } - else - { - feedbackColor = arrowData.Color; // Default to original color if no match - } + // Set the particle amount based on timing + int particleAmount; - // Apply the feedback color instantly - arrowData.Node.SetColor(feedbackColor); - GD.Print($"Setting {arrowData.Type} to {feedbackColor}"); + if (text == "Perfect") + { + particleAmount = 15; // A lot of particles for Perfect + } + else if (text == "Great") + { + particleAmount = 10; // Moderate amount for Great + } + else if (text == "Good") + { + particleAmount = 5; // Few particles for Good + } + else + { + return; // No particles for a miss + } - // Create a Tween and reset to original color smoothly - var tween = CreateTween(); - tween.SetTrans(Tween.TransitionType.Sine); - tween.SetEase(Tween.EaseType.Out); + // Apply the particle amount and start emitting + particles.Amount = particleAmount; + particles.Emitting = true; + GD.Print($"Emitting {particleAmount} particles for {arrow} with timing {text}"); - tween.TweenProperty(arrowData.Node, "modulate", originalColors[arrow], duration); - } + // Stop particles after a short delay using a Timer + Timer timer = new Timer(); + timer.WaitTime = 0.5f; // Stop emitting after 0.5 seconds + timer.OneShot = true; + timer.Timeout += () => + { + particles.Emitting = false; + timer.QueueFree(); // Clean up the timer + }; + + AddChild(timer); + timer.Start(); } } From 9748ae94e3446b981c493ca1ebec0c0c4c55eac4 Mon Sep 17 00:00:00 2001 From: Rmojarro1 <48000819+Rmojarro1@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:25:36 -0800 Subject: [PATCH 3/5] Particles for full bar Set up for particles on full combo bar, but it won't let me use override for process. not sure if my machine is just being dumb --- scenes/BattleDirector/NotePlacementBar.tscn | 13 +++++++++++++ .../scripts/NotePlacementBar.cs | 19 ++++++++++++++++++- scenes/ChartViewport/ChartManager.cs | 2 +- scenes/NoteManager/scripts/InputHandler.cs | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/scenes/BattleDirector/NotePlacementBar.tscn b/scenes/BattleDirector/NotePlacementBar.tscn index 9e3ee4f9..3e683436 100644 --- a/scenes/BattleDirector/NotePlacementBar.tscn +++ b/scenes/BattleDirector/NotePlacementBar.tscn @@ -47,6 +47,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/NotePlacementBar.cs b/scenes/BattleDirector/scripts/NotePlacementBar.cs index b17bb7d2..86825da1 100644 --- a/scenes/BattleDirector/scripts/NotePlacementBar.cs +++ b/scenes/BattleDirector/scripts/NotePlacementBar.cs @@ -1,9 +1,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using Godot; -public partial class NotePlacementBar : Node +public partial class NotePlacementBar : Node2D { const int MaxValue = 80; private int _currentBarValue; @@ -24,6 +25,9 @@ public partial class NotePlacementBar : Node [Export] private Sprite2D _nextNote; + [Export] + private CpuParticles2D fullBarParticles; + private Note[] _noteDeck; private Queue _noteQueue = new Queue(); @@ -129,6 +133,7 @@ public Note PlacedNote() _currentBarValue -= (int)(_currentNoteInstance.CostModifier * MaxValue); UpdateNotePlacementBar(_currentBarValue); + fullBarParticles.Emitting = false; return GetNote(); } @@ -137,6 +142,18 @@ public bool CanPlaceNote() return _currentBarValue >= MaxValue; } + //editor gets mad and won't let me change this to override for some reason v + public void _Process(float delta) + { + if (CanPlaceNote()) + { + if (!fullBarParticles.Emitting) + { + fullBarParticles.Emitting = true; + } + } + } + private void DetermineComboMult() { comboMult = _currentCombo / notesToIncreaseCombo + 1; diff --git a/scenes/ChartViewport/ChartManager.cs b/scenes/ChartViewport/ChartManager.cs index e2f30cb8..9581843c 100644 --- a/scenes/ChartViewport/ChartManager.cs +++ b/scenes/ChartViewport/ChartManager.cs @@ -119,7 +119,7 @@ public void ComboText(string text, ArrowType arrow, int currentCombo) TextParticle newText = new TextParticle(); AddChild(newText); //IH.Arrows[(int)arrow].Node.AddChild(newText); - IH.FeedbackColor(arrow, text); + IH.FeedbackEffect(arrow, text); newText.Text = text + $" {currentCombo}"; } diff --git a/scenes/NoteManager/scripts/InputHandler.cs b/scenes/NoteManager/scripts/InputHandler.cs index 9727ffbf..046ee879 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -61,7 +61,7 @@ private void InitializeArrowCheckers() } } - public void FeedbackColor(ArrowType arrow, string text) + public void FeedbackEffect(ArrowType arrow, string text) { if (hitParticles.ContainsKey(arrow)) { From 848bca8c7130b00e1850b06cb535c6e73f497872 Mon Sep 17 00:00:00 2001 From: Rmojarro1 <48000819+Rmojarro1@users.noreply.github.com> Date: Thu, 27 Feb 2025 13:50:59 -0800 Subject: [PATCH 4/5] Added particle effects for bar Finally realized that I didn't need process, added the effect in NotePlcementBar. Basic effect, but it's something we can tweak easily --- scenes/BattleDirector/NotePlacementBar.tscn | 3 ++- .../scripts/NotePlacementBar.cs | 21 +++++++------------ scenes/NoteManager/scripts/InputHandler.cs | 1 - 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/scenes/BattleDirector/NotePlacementBar.tscn b/scenes/BattleDirector/NotePlacementBar.tscn index 3e683436..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 diff --git a/scenes/BattleDirector/scripts/NotePlacementBar.cs b/scenes/BattleDirector/scripts/NotePlacementBar.cs index 86825da1..6a0ea2e0 100644 --- a/scenes/BattleDirector/scripts/NotePlacementBar.cs +++ b/scenes/BattleDirector/scripts/NotePlacementBar.cs @@ -4,7 +4,7 @@ using System.Linq; using Godot; -public partial class NotePlacementBar : Node2D +public partial class NotePlacementBar : Node { const int MaxValue = 80; private int _currentBarValue; @@ -117,6 +117,13 @@ public void HitNote() _currentBarValue = Math.Min(_currentBarValue + comboMult, MaxValue); UpdateNotePlacementBar(_currentBarValue); UpdateComboMultText(); + if (CanPlaceNote()) + { + if (!fullBarParticles.Emitting) + { + fullBarParticles.Emitting = true; + } + } } // Missing a note resets combo @@ -142,18 +149,6 @@ public bool CanPlaceNote() return _currentBarValue >= MaxValue; } - //editor gets mad and won't let me change this to override for some reason v - public void _Process(float delta) - { - if (CanPlaceNote()) - { - if (!fullBarParticles.Emitting) - { - fullBarParticles.Emitting = true; - } - } - } - private void DetermineComboMult() { comboMult = _currentCombo / notesToIncreaseCombo + 1; diff --git a/scenes/NoteManager/scripts/InputHandler.cs b/scenes/NoteManager/scripts/InputHandler.cs index 046ee879..1d33bcee 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -91,7 +91,6 @@ public void FeedbackEffect(ArrowType arrow, string text) // Apply the particle amount and start emitting particles.Amount = particleAmount; particles.Emitting = true; - GD.Print($"Emitting {particleAmount} particles for {arrow} with timing {text}"); // Stop particles after a short delay using a Timer Timer timer = new Timer(); From 988fd97d9c075f16ea7cddd08417724369ecbd68 Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Thu, 27 Feb 2025 14:14:11 -0800 Subject: [PATCH 5/5] Tweaks and refactoring Made hit particles separate class and scene, and inherit parent color Simplified particle emitting Tweaked textparticle to be more explosive --- README.md | 2 - .../scripts/NotePlacementBar.cs | 11 +--- scenes/BattleDirector/scripts/TextParticle.cs | 9 +-- scenes/ChartViewport/ChartViewport.tscn | 5 +- scenes/ChartViewport/hit_particles.tscn | 17 +++++ .../{ => scripts}/ChartManager.cs | 2 +- scenes/ChartViewport/scripts/HitParticles.cs | 25 +++++++ .../ChartViewport/{ => scripts}/Loopable.cs | 0 scenes/NoteManager/note_manager.tscn | 51 ++------------- scenes/NoteManager/scripts/InputHandler.cs | 65 +++++-------------- scenes/NoteManager/scripts/NoteChecker.cs | 4 +- 11 files changed, 80 insertions(+), 111 deletions(-) create mode 100644 scenes/ChartViewport/hit_particles.tscn rename scenes/ChartViewport/{ => scripts}/ChartManager.cs (98%) create mode 100644 scenes/ChartViewport/scripts/HitParticles.cs rename scenes/ChartViewport/{ => scripts}/Loopable.cs (100%) diff --git a/README.md b/README.md index 65055df1..83794fb7 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,3 @@ Current team members include: #### Attributions: First Song: gameMusic by Magntron - freesound.org - - diff --git a/scenes/BattleDirector/scripts/NotePlacementBar.cs b/scenes/BattleDirector/scripts/NotePlacementBar.cs index 6a0ea2e0..2d0a1f84 100644 --- a/scenes/BattleDirector/scripts/NotePlacementBar.cs +++ b/scenes/BattleDirector/scripts/NotePlacementBar.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using Godot; @@ -117,13 +116,7 @@ public void HitNote() _currentBarValue = Math.Min(_currentBarValue + comboMult, MaxValue); UpdateNotePlacementBar(_currentBarValue); UpdateComboMultText(); - if (CanPlaceNote()) - { - if (!fullBarParticles.Emitting) - { - fullBarParticles.Emitting = true; - } - } + //fullBarParticles.Emitting = CanPlaceNote(); } // Missing a note resets combo @@ -140,7 +133,7 @@ public Note PlacedNote() _currentBarValue -= (int)(_currentNoteInstance.CostModifier * MaxValue); UpdateNotePlacementBar(_currentBarValue); - fullBarParticles.Emitting = false; + //fullBarParticles.Emitting = false; return GetNote(); } 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 98% rename from scenes/ChartViewport/ChartManager.cs rename to scenes/ChartViewport/scripts/ChartManager.cs index 9581843c..12866ea3 100644 --- a/scenes/ChartViewport/ChartManager.cs +++ b/scenes/ChartViewport/scripts/ChartManager.cs @@ -118,7 +118,7 @@ public void ComboText(string text, ArrowType arrow, int currentCombo) { TextParticle newText = new TextParticle(); AddChild(newText); - //IH.Arrows[(int)arrow].Node.AddChild(newText); + newText.Position = IH.Arrows[(int)arrow].Node.Position - newText.Size/2; IH.FeedbackEffect(arrow, text); newText.Text = text + $" {currentCombo}"; } 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 1014af2f..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,17 +22,7 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") -[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowLeft"] -emitting = false -amount = 1 -lifetime = 0.25 -speed_scale = 2.01 -spread = 180.0 -gravity = Vector2(0, 0) -initial_velocity_min = 50.0 -initial_velocity_max = 200.0 -scale_amount_max = 2.0 -color = Color(0.975142, 0.975142, 7.70092e-06, 1) +[node name="HitParticles" parent="noteCheckers/arrowLeft" instance=ExtResource("5_jv1tr")] [node name="arrowUp" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 68) @@ -43,17 +34,7 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") -[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowUp"] -emitting = false -amount = 1 -lifetime = 0.25 -speed_scale = 2.01 -spread = 180.0 -gravity = Vector2(0, 0) -initial_velocity_min = 50.0 -initial_velocity_max = 200.0 -scale_amount_max = 2.0 -color = Color(0.975142, 0.975142, 7.70092e-06, 1) +[node name="HitParticles" parent="noteCheckers/arrowUp" instance=ExtResource("5_jv1tr")] [node name="arrowDown" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 112) @@ -65,17 +46,7 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") -[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowDown"] -emitting = false -amount = 1 -lifetime = 0.25 -speed_scale = 2.01 -spread = 180.0 -gravity = Vector2(0, 0) -initial_velocity_min = 50.0 -initial_velocity_max = 200.0 -scale_amount_max = 2.0 -color = Color(0.975142, 0.975142, 7.70092e-06, 1) +[node name="HitParticles" parent="noteCheckers/arrowDown" instance=ExtResource("5_jv1tr")] [node name="arrowRight" type="Sprite2D" parent="noteCheckers"] position = Vector2(0, 151) @@ -86,17 +57,7 @@ script = ExtResource("3_0cioe") modulate = Color(0, 0, 0, 1) texture = ExtResource("4_3mttx") -[node name="HitParticles" type="CPUParticles2D" parent="noteCheckers/arrowRight"] -emitting = false -amount = 1 -lifetime = 0.25 -speed_scale = 2.01 -spread = 180.0 -gravity = Vector2(0, 0) -initial_velocity_min = 50.0 -initial_velocity_max = 200.0 -scale_amount_max = 2.0 -color = Color(0.975142, 0.975142, 7.70092e-06, 1) +[node name="HitParticles" parent="noteCheckers/arrowRight" instance=ExtResource("5_jv1tr")] [node name="ui" type="Node2D" parent="."] diff --git a/scenes/NoteManager/scripts/InputHandler.cs b/scenes/NoteManager/scripts/InputHandler.cs index 1d33bcee..a40b863b 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -15,10 +15,6 @@ public partial class InputHandler : Node2D [Signal] public delegate void NoteReleasedEventHandler(ArrowType arrowType); - // Dictionary to store Particles2D nodes for each arrow - private Dictionary hitParticles = - new Dictionary(); - public ArrowData[] Arrows = new ArrowData[] { new ArrowData() @@ -54,57 +50,32 @@ private void InitializeArrowCheckers() { Arrows[i].Node = GetNode("noteCheckers/" + Arrows[i].Key); Arrows[i].Node.SetColor(Arrows[i].Color); - - var particles = Arrows[i].Node.GetNode("HitParticles"); - particles.Emitting = false; - hitParticles[Arrows[i].Type] = particles; } } public void FeedbackEffect(ArrowType arrow, string text) { - if (hitParticles.ContainsKey(arrow)) - { - // Get the particle node for this arrow - var particles = hitParticles[arrow]; + // Get the particle node for this arrow + var particles = Arrows[(int)arrow].Node.Particles; - // Set the particle amount based on timing - int particleAmount; - - if (text == "Perfect") - { - particleAmount = 15; // A lot of particles for Perfect - } - else if (text == "Great") - { - particleAmount = 10; // Moderate amount for Great - } - else if (text == "Good") - { - particleAmount = 5; // Few particles for Good - } - else - { + // 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 - } - - // Apply the particle amount and start emitting - particles.Amount = particleAmount; - particles.Emitting = true; - - // Stop particles after a short delay using a Timer - Timer timer = new Timer(); - timer.WaitTime = 0.5f; // Stop emitting after 0.5 seconds - timer.OneShot = true; - timer.Timeout += () => - { - particles.Emitting = false; - timer.QueueFree(); // Clean up the timer - }; - - AddChild(timer); - timer.Start(); } + + particles.Emit(particleAmount); } public override void _Ready() 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); } }