Skip to content

Commit bba4b9c

Browse files
committed
Finalize for Sprint 1
Added audio Made small fixes, no more beat 0 Created first chart
1 parent 27e0ffa commit bba4b9c

7 files changed

Lines changed: 62 additions & 21 deletions

File tree

2.44 MB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[remap]
2+
3+
importer="mp3"
4+
type="AudioStreamMP3"
5+
uid="uid://cv6lqjj6lu36h"
6+
path="res://.godot/imported/335571__magntron__gamemusic_120bpm.mp3-a87b357c4b3c9199709863b47f78bd2a.mp3str"
7+
8+
[deps]
9+
10+
source_file="res://Audio/335571__magntron__gamemusic_120bpm.mp3"
11+
dest_files=["res://.godot/imported/335571__magntron__gamemusic_120bpm.mp3-a87b357c4b3c9199709863b47f78bd2a.mp3str"]
12+
13+
[params]
14+
15+
loop=true
16+
loop_offset=0
17+
bpm=0
18+
beat_count=0
19+
bar_beats=4

scenes/BattleDirector/BattleDirector.cs

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ public partial class BattleDirector : Node2D
1515
private HealthBar Enemy;
1616

1717
[Export]
18-
public ChartManager CM;
18+
private ChartManager CM;
1919

2020
[Export]
21-
public InputHandler IH;
21+
private InputHandler IH;
2222

2323
[Export]
2424
private NotePlacementBar NotePlacementBar;
2525

26+
[Export]
27+
private AudioStreamPlayer Audio;
28+
2629
private double _timingInterval = .1; //secs
2730

2831
[Signal]
@@ -44,7 +47,7 @@ public struct SongData
4447
#region Note Handling
4548
//Assume queue structure for notes in each lane.
4649
//Can eventually make this its own structure
47-
private NoteArrow[][] _laneData;
50+
private NoteArrow[][] _laneData = Array.Empty<NoteArrow[]>();
4851
private int[] _laneLastBeat = new int[]
4952
{ //Temporary (hopefully) measure to bridge from note queue structure to ordered array
5053
0,
@@ -70,9 +73,9 @@ private bool AddNoteToLane(Note note, bool isActive = true)
7073
{
7174
note.Beat %= CM.BeatsPerLoop;
7275
//Don't add dupe notes
73-
if (_notes.Any(nt => nt.Type == note.Type && nt.Beat == note.Beat))
76+
if (note.Beat == 0 || _notes.Any(nt => nt.Type == note.Type && nt.Beat == note.Beat))
7477
{
75-
return false;
78+
return false; //Beat at 0 is too messy.
7679
}
7780
_notes = _notes.Append(note).ToArray();
7881
//Get noteArrow from CM
@@ -87,19 +90,24 @@ private bool AddNoteToLane(Note note, bool isActive = true)
8790
private void AddExampleNotes()
8891
{
8992
GD.Print(CM.BeatsPerLoop);
90-
for (int i = 0; i < 1; i++)
93+
for (int i = 1; i < 15; i++)
94+
{
95+
Note exampleNote = new Note(NoteArrow.ArrowType.Up, i * 4);
96+
AddNoteToLane(exampleNote);
97+
}
98+
for (int i = 1; i < 15; i++)
9199
{
92-
Note exampleNote = new Note(NoteArrow.ArrowType.Down, i);
100+
Note exampleNote = new Note(NoteArrow.ArrowType.Left, 4 * i + 1);
93101
AddNoteToLane(exampleNote);
94102
}
95-
for (int i = 0; i < 4; i++)
103+
for (int i = 0; i < 10; i++)
96104
{
97-
Note exampleNote = new Note(NoteArrow.ArrowType.Up, i + 20);
105+
Note exampleNote = new Note(NoteArrow.ArrowType.Right, 3 * i + 32);
98106
AddNoteToLane(exampleNote);
99107
}
100-
for (int i = 0; i < 1; i++)
108+
for (int i = 0; i < 3; i++)
101109
{
102-
Note exampleNote = new Note(NoteArrow.ArrowType.Left, CM.BeatsPerLoop);
110+
Note exampleNote = new Note(NoteArrow.ArrowType.Down, 8 * i + 16);
103111
AddNoteToLane(exampleNote);
104112
}
105113
}
@@ -109,9 +117,16 @@ public override void _Ready()
109117
_curSong = new SongData
110118
{
111119
Bpm = 120,
112-
SongLength = 100,
120+
SongLength = Audio.Stream.GetLength(),
113121
NumLoops = 5,
114122
};
123+
124+
var timer = GetTree().CreateTimer(AudioServer.GetTimeToNextMix());
125+
timer.Timeout += Begin;
126+
}
127+
128+
private void Begin()
129+
{
115130
CM.PrepChart(_curSong);
116131
_laneData = new NoteArrow[][]
117132
{
@@ -142,11 +157,13 @@ public override void _Ready()
142157

143158
CM.Connect(nameof(InputHandler.NotePressed), new Callable(this, nameof(OnNotePressed)));
144159
CM.Connect(nameof(InputHandler.NoteReleased), new Callable(this, nameof(OnNoteReleased)));
160+
161+
Audio.Play();
145162
}
146163

147164
public override void _Process(double delta)
148165
{
149-
TimeKeeper.CurrentTime += delta;
166+
TimeKeeper.CurrentTime = Audio.GetPlaybackPosition();
150167
CheckMiss();
151168
}
152169

@@ -212,14 +229,14 @@ private void HandleTiming(NoteArrow.ArrowType type, double beatDif)
212229
if (beatDif < _timingInterval * 1)
213230
{
214231
GD.Print("Perfect");
215-
Enemy.TakeDamage(1);
232+
Enemy.TakeDamage(3);
216233
NotePlacementBar.HitNote();
217234
NotePlacementBar.ComboText("Perfect!");
218235
}
219236
else if (beatDif < _timingInterval * 2)
220237
{
221238
GD.Print("Good");
222-
Enemy.TakeDamage(0);
239+
Enemy.TakeDamage(1);
223240
NotePlacementBar.HitNote();
224241
NotePlacementBar.ComboText("Good");
225242
}

scenes/BattleDirector/NotePlacementBar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
public partial class NotePlacementBar : Node
55
{
6-
const int MaxValue = 5;
6+
const int MaxValue = 80;
77
int currentBarValue;
88
int currentCombo;
99
int comboMult;

scenes/BattleDirector/TextParticle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public partial class TextParticle : Label
77
public override void _Ready()
88
{
99
Tween tween = GetTree().CreateTween();
10+
Position += Vector2.Left * (GD.Randf() * 40 - 20);
1011
tween.SetTrans(Tween.TransitionType.Quad);
1112
tween.SetEase(Tween.EaseType.Out);
1213
tween.TweenProperty(this, "position", Position + Vector2.Up * 10, .5f);

scenes/BattleDirector/test_battle_scene.tscn

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=9 format=3 uid="uid://b0mrgr7h0ty1y"]
1+
[gd_scene load_steps=10 format=3 uid="uid://b0mrgr7h0ty1y"]
22

33
[ext_resource type="Script" path="res://scenes/BattleDirector/BattleDirector.cs" id="1_cwqqr"]
44
[ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://scenes/ChartViewport/ChartViewport.tscn" id="2_cupb3"]
@@ -7,6 +7,7 @@
77
[ext_resource type="Texture2D" uid="uid://b6fkei0i83vte" path="res://scenes/BattleDirector/assets/Character1.png" id="5_elveq"]
88
[ext_resource type="Texture2D" uid="uid://veedngaorx3l" path="res://scenes/BattleDirector/assets/Enemy1.png" id="6_0k4pw"]
99
[ext_resource type="PackedScene" uid="uid://duhiilcv4tat3" path="res://scenes/BattleDirector/NotePlacementBar.tscn" id="7_3ko4g"]
10+
[ext_resource type="AudioStream" uid="uid://cv6lqjj6lu36h" path="res://Audio/335571__magntron__gamemusic_120bpm.mp3" id="8_caqms"]
1011

1112
[sub_resource type="ShaderMaterial" id="ShaderMaterial_v58v7"]
1213
shader = ExtResource("3_h0nj6")
@@ -22,11 +23,15 @@ shader_parameter/spin_amount = 0.1
2223
shader_parameter/pixel_filter = 200.0
2324
shader_parameter/is_rotating = false
2425

25-
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "IH", "NotePlacementBar")]
26+
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "IH", "NotePlacementBar", "Audio")]
2627
script = ExtResource("1_cwqqr")
2728
CM = NodePath("SubViewport")
2829
IH = NodePath("SubViewport/SubViewport/noteManager")
2930
NotePlacementBar = NodePath("NotePlacementBar")
31+
Audio = NodePath("AudioStreamPlayer")
32+
33+
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
34+
stream = ExtResource("8_caqms")
3035

3136
[node name="SubViewport" parent="." instance=ExtResource("2_cupb3")]
3237
offset_left = 80.0
@@ -67,5 +72,3 @@ offset_left = 12.0
6772
offset_top = 145.0
6873
offset_right = 12.0
6974
offset_bottom = 145.0
70-
71-
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]

scenes/ChartViewport/ChartManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ private void InitBackgrounds()
8282
if (child is not Loopable)
8383
continue;
8484
Loopable loopable = (Loopable)child;
85+
loopable.Position = Vector2.Zero;
8586
loopable.SetSize(new Vector2((float)ChartLength / 2 + 1, Size.Y));
8687
loopable.Bounds = (float)ChartLength / 2 * i;
8788
i++;
@@ -113,7 +114,7 @@ private NoteArrow CreateNote(ArrowType arrow, int beat = 0)
113114

114115
_arrowGroup.AddChild(newArrow);
115116
newArrow.Bounds = (float)((double)beat / BeatsPerLoop * (ChartLength / 2));
116-
newArrow.Position += Vector2.Right * newArrow.Bounds; //temporary fix for notes spawning and instantly calling loop from originating at 0,0
117+
newArrow.Position += Vector2.Right * newArrow.Bounds * 10; //temporary fix for notes spawning and instantly calling loop from originating at 0,0
117118
return newArrow;
118119
}
119120
}

0 commit comments

Comments
 (0)