fix chart reading, scroll chart notes!

This commit is contained in:
muskit
2023-09-16 00:40:36 -07:00
parent 6a98acce67
commit c8bd5c16c8
9 changed files with 126 additions and 29 deletions
+46 -2
View File
@@ -1,6 +1,8 @@
using System.Reflection.PortableExecutable;
using Godot;
using WacK.Data.Chart;
using WacK.Data.Mer;
using WacK.Things.TunnelObjects;
namespace WacK.Scenes
{
@@ -24,13 +26,55 @@ namespace WacK.Scenes
// initialized by another scene, BEFORE loading this one!
public static PlayParameters playParams;
// TunnelObjects we can instantiate
public static PackedScene notePlay = GD.Load<PackedScene>("res://Things/TunnelObjects/Notes/NoteTouch.tscn");
[Export]
public Control noteDisplay;
private Chart chart;
public override void _Ready()
{
// parse mer and create chart for current play
chart = new(playParams.chartPath);
}
private void OnDestroy()
RealizeChart();
}
/// <summary>
/// Instantiates necessary notes onto the 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)
{
default: // tap note
nNote = notePlay.Instantiate<THNotePlay>();
break;
}
nNote.Init(note);
var nPos = nNote.Position;
nPos.Y = msNote.Key * -1000;
nNote.Position = nPos;
noteDisplay.AddChild(nNote);
}
}
}
public override void _Process(double delta)
{
var nPos = noteDisplay.Position;
nPos.Y += (float)delta * 1000;
noteDisplay.Position = nPos;
}
private void OnDestroy()
{
playParams = null;
}