note instantiating fixes, hold note rendering experimentation

This commit is contained in:
msk
2023-09-16 18:54:35 -07:00
parent c8bd5c16c8
commit 02aa6f3e8b
6 changed files with 198 additions and 87 deletions
+8 -6
View File
@@ -13,7 +13,7 @@ namespace WacK.Data.Chart
/// </summary>
public class Chart
{
// Key of dictionaries are in milliseconds
// Key of dictionaries are in seconds
// List is for chords
public SortedList<float, List<NotePlay>> playNotes { get; private set; }
public SortedList<float, NoteEvent<(int, int)>> timeSigChgs { get; private set; }
@@ -241,13 +241,15 @@ namespace WacK.Data.Chart
{
curHoldNote[np.holdIdx].points[curTime] = np;
}
// add note
if (!playNotes.ContainsKey(curTime))
else
{
playNotes[curTime] = new List<NotePlay>();
// only add notes that aren't part of the hold
if (!playNotes.ContainsKey(curTime))
{
playNotes[curTime] = new List<NotePlay>();
}
playNotes[curTime].Add(np);
}
playNotes[curTime].Add(np);
}
// NoteEvent<float> -- tempo changes
+18 -8
View File
@@ -27,13 +27,19 @@ namespace WacK.Scenes
public static PlayParameters playParams;
// TunnelObjects we can instantiate
public static PackedScene notePlay = GD.Load<PackedScene>("res://Things/TunnelObjects/Notes/NoteTouch.tscn");
public static PackedScene noteTouch = GD.Load<PackedScene>("res://Things/TunnelObjects/Notes/NoteTouch.tscn");
public static PackedScene noteHold = GD.Load<PackedScene>("res://Things/TunnelObjects/Notes/NoteHold.tscn");
[Export]
public Control noteDisplay;
[Export]
public Control scrollDisplay;
private Chart chart;
// scroll speed
private const float PIXELS_PER_SECOND = 2000;
public override void _Ready()
{
// parse mer and create chart for current play
@@ -42,25 +48,29 @@ namespace WacK.Scenes
}
/// <summary>
/// Instantiates necessary notes onto the noteDisplay for the player to see.
/// Instantiates necessary notes onto noteDisplay for the player to see.
/// </summary>
private void RealizeChart()
{
foreach (var msNote in chart.playNotes)
{
GD.Print(msNote.Key);
foreach (var note in msNote.Value)
{
THNotePlay nNote;
switch (note)
switch (note.type)
{
default: // tap note
nNote = notePlay.Instantiate<THNotePlay>();
case NotePlayType.HoldStart:
nNote = noteHold.Instantiate<THNoteHold>();
break;
case NotePlayType.Touch:
nNote = noteTouch.Instantiate<THNotePlay>();
break;
default:
continue;
}
nNote.Init(note);
var nPos = nNote.Position;
nPos.Y = msNote.Key * -1000;
nPos.Y = msNote.Key * -PIXELS_PER_SECOND;
nNote.Position = nPos;
noteDisplay.AddChild(nNote);
}
@@ -70,7 +80,7 @@ namespace WacK.Scenes
public override void _Process(double delta)
{
var nPos = noteDisplay.Position;
nPos.Y += (float)delta * 1000;
nPos.Y += (float)delta * PIXELS_PER_SECOND;
noteDisplay.Position = nPos;
}
@@ -11,6 +11,8 @@ namespace WacK.Things.TunnelObjects
{
base.Init(noteData);
this.noteData = noteData;
// TODO: setup other Nodes to render hold note properly
}
}
}