Skip to content

Commit 01c5c87

Browse files
committed
Added note placement effect
Small particle effects spawn on note queue and placed note Fixed some spaghetti with initial noteArrow position
1 parent 9f6de6a commit 01c5c87

6 files changed

Lines changed: 80 additions & 12 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[gd_scene load_steps=5 format=3 uid="uid://k21psn7b5sxf"]
2+
3+
[ext_resource type="Texture2D" uid="uid://cdf3g3174du4r" path="res://Classes/Notes/assets/heal_note.png" id="1_hjrch"]
4+
5+
[sub_resource type="Curve" id="Curve_xix4e"]
6+
_data = [Vector2(0, 1), 0.0, 1.4, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
7+
point_count = 2
8+
9+
[sub_resource type="CurveTexture" id="CurveTexture_h7u0t"]
10+
curve = SubResource("Curve_xix4e")
11+
12+
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_k0qar"]
13+
lifetime_randomness = 0.25
14+
particle_flag_disable_z = true
15+
emission_shape = 2
16+
emission_sphere_radius = 3.0
17+
spread = 180.0
18+
initial_velocity_min = 30.77
19+
initial_velocity_max = 61.55
20+
gravity = Vector3(0, 0, 0)
21+
tangential_accel_min = -100.0
22+
tangential_accel_max = 85.12
23+
scale_curve = SubResource("CurveTexture_h7u0t")
24+
25+
[node name="NotePoof" type="GPUParticles2D"]
26+
emitting = false
27+
amount = 10
28+
process_material = SubResource("ParticleProcessMaterial_k0qar")
29+
texture = ExtResource("1_hjrch")
30+
lifetime = 0.75
31+
one_shot = true
32+
preprocess = 0.1
33+
explosiveness = 1.0

scenes/BattleDirector/scripts/Conductor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public bool AddNoteToLane(ArrowType type, int beat, Note note, bool isActive = t
5656
else
5757
{
5858
arrow = CM.AddArrowToLane(type, beat, newNote, new Color(1, 0.43f, 0.26f));
59+
NoteQueueParticlesFactory.NoteParticles(arrow, note.Texture, .5f);
5960
}
6061

6162
if (!isActive)

scenes/BattleDirector/scripts/NotePlacementBar.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,19 @@ private void UpdateNoteQueue()
135135
private Note GetNote(bool getNextNote = false)
136136
{
137137
Note result;
138+
Sprite2D selectedNote;
138139
if (!getNextNote)
139140
{
141+
selectedNote = _currentNote;
140142
result = _currentNoteInstance;
141143
_currentNoteInstance = null;
142144
}
143145
else
144146
{
147+
selectedNote = _nextNote;
145148
result = _noteQueue.Dequeue();
146149
}
150+
NoteQueueParticlesFactory.NoteParticles(selectedNote, selectedNote.Texture);
147151
ProgressQueue();
148152
return result;
149153
}
@@ -156,7 +160,6 @@ public void HitNote()
156160
_currentBarValue = Math.Min(_currentBarValue + comboMult, MaxValue);
157161
UpdateNotePlacementBar(_currentBarValue);
158162
UpdateComboMultText();
159-
//fullBarParticles.Emitting = CanPlaceNote();
160163
}
161164

162165
// Missing a note resets combo
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using Godot;
3+
4+
public static class NoteQueueParticlesFactory
5+
{
6+
private static PackedScene particlesScene = null;
7+
8+
public static GpuParticles2D NoteParticles(
9+
Node parent,
10+
Texture2D texture,
11+
float amountModifier = 1
12+
)
13+
{
14+
particlesScene ??= GD.Load<PackedScene>(
15+
"res://scenes/BattleDirector/notePoofParticles.tscn"
16+
);
17+
18+
GpuParticles2D particles = particlesScene.Instantiate<GpuParticles2D>();
19+
20+
parent.AddChild(particles);
21+
particles.Amount = (int)(particles.Amount * amountModifier);
22+
particles.Texture = texture;
23+
particles.Emitting = true;
24+
particles.Finished += () => particles.QueueFree();
25+
26+
return particles;
27+
}
28+
}

scenes/ChartViewport/scripts/ChartManager.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,13 @@ private NoteArrow CreateNote(ArrowType arrow, Note note, int beat = 0, int loopO
110110
{
111111
var noteScene = ResourceLoader.Load<PackedScene>("res://scenes/NoteManager/note.tscn");
112112
NoteArrow newArrow = noteScene.Instantiate<NoteArrow>();
113+
newArrow.Bounds = (float)(
114+
beat / TrueBeatsPerLoop * (ChartLength / 2) + loopOffset * (ChartLength / 2)
115+
);
113116
newArrow.Init(IH.Arrows[(int)arrow], beat, note);
114117
newArrow.OutlineSprite.Modulate = IH.Arrows[(int)arrow].Color;
115118

116119
_arrowGroup.AddChild(newArrow);
117-
newArrow.Bounds = (float)(
118-
beat / TrueBeatsPerLoop * (ChartLength / 2) + loopOffset * (ChartLength / 2)
119-
);
120-
newArrow.Position += Vector2.Right * newArrow.Bounds * 10; //temporary fix for notes spawning and instantly calling loop from originating at 0,0
121120
return newArrow;
122121
}
123122

scenes/NoteManager/scripts/NoteArrow.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Init(ArrowData parentArrowData, int beat, Note note)
2626
Type = parentArrowData.Type;
2727
Beat = beat;
2828

29-
Position += Vector2.Down * (parentArrowData.Node.GlobalPosition.Y);
29+
Position = new Vector2(GetNewPos(), parentArrowData.Node.GlobalPosition.Y);
3030
RotationDegrees = parentArrowData.Node.RotationDegrees;
3131
IconSprite.Texture = note.Texture;
3232
IconSprite.Rotation = -Rotation;
@@ -35,19 +35,23 @@ public void Init(ArrowData parentArrowData, int beat, Note note)
3535
public override void _Process(double delta)
3636
{
3737
Vector2 newPos = Position;
38-
newPos.X =
39-
(float)(
40-
(-TimeKeeper.CurrentTime / TimeKeeper.LoopLength * TimeKeeper.ChartLength)
41-
% TimeKeeper.ChartLength
42-
/ 2
43-
) + Bounds;
38+
newPos.X = GetNewPos();
4439
if (newPos.X > Position.X)
4540
{
4641
OnLoop();
4742
}
4843
Position = newPos;
4944
}
5045

46+
private float GetNewPos()
47+
{
48+
return (float)(
49+
(-TimeKeeper.CurrentTime / TimeKeeper.LoopLength * TimeKeeper.ChartLength)
50+
% TimeKeeper.ChartLength
51+
/ 2
52+
) + Bounds;
53+
}
54+
5155
private void OnLoop()
5256
{
5357
if (!IsActive)

0 commit comments

Comments
 (0)