Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Added a visualizer for sections (kinda works)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed Jan 27, 2021
1 parent f2f24dc commit 525e778
Show file tree
Hide file tree
Showing 44 changed files with 109,679 additions and 12 deletions.
2 changes: 1 addition & 1 deletion FNFBot/FNFBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FNFDataAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\FNFDataAPI\FNFDataAPI\bin\Debug\FNFDataAPI.dll</HintPath>
<HintPath>..\..\..\FNFDataAPI\FNFDataAPI\bin\Debug\FNFDataAPI.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
78 changes: 67 additions & 11 deletions FNFBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ public static void Main(string[] args)
{
while (true)
{
Console.Title = "FNFBot 1.1";
Console.Title = "FNFBot 1.2 - hi :)";
if (playing)
{
section = 0;
foreach (FNFSong.FNFSection sect in song.Sections)
{
section++;
List<FNFSong.FNFNote> notesToPlay = new List<FNFSong.FNFNote>();
if (sect.Notes.Count == 0)
continue;
Expand All @@ -85,7 +87,7 @@ public static void Main(string[] args)
{
if ((int)n.Type >= 4)
continue;
notesToPlay.Add(n);
notesToPlay.Add(n);
}
}
else
Expand All @@ -98,7 +100,7 @@ public static void Main(string[] args)
}

notesPlayed = 0;

foreach (FNFSong.FNFNote not in notesToPlay)
{
new Thread(() =>
Expand All @@ -107,9 +109,7 @@ public static void Main(string[] args)

if (!playing)
Thread.CurrentThread.Abort();

Console.WriteLine("Queing " + not.Type + " at " + not.Time);


while ((decimal) watch.Elapsed.TotalMilliseconds < not.Time)
{
Thread.Sleep(1);
Expand All @@ -132,7 +132,7 @@ public static void Main(string[] args)

}
else
KeyPress(0x41, 0x1e);
KeyPress(0x44, 0x1e);

break;
case FNFSong.NoteType.Down:
Expand All @@ -144,7 +144,7 @@ public static void Main(string[] args)
Thread.Sleep(Convert.ToInt32(not.Length));
simulator.Keyboard.KeyUp(VirtualKeyCode.DOWN);
}
else KeyPress(0x53, 0x1f);
else KeyPress(0x46, 0x1f);

break;
case FNFSong.NoteType.Up:
Expand All @@ -158,7 +158,7 @@ public static void Main(string[] args)

}
else
KeyPress(0x57, 0x11);
KeyPress(0x4A, 0x11);


break;
Expand All @@ -173,15 +173,68 @@ public static void Main(string[] args)

}
else
KeyPress(0x44, 0x20);
KeyPress(0x4B, 0x20);

break;
}

notesPlayed++;
}).Start();
}

Console.Clear();
if (notesToPlay.Count == 0)
continue;
Console.WriteLine("Section: " + section + " | Notes: " + notesToPlay.Count + " | Crochet: " + crochet.ToString() + " | Step Crochet: " + stepCrochet.ToString() + " | Sect Started at: " + watch.Elapsed.TotalMilliseconds);
StringBuilder toWrite = new StringBuilder(" ");
float currentNoteTime = float.Parse(notesToPlay.First().Time.ToString());
float currentY = 0;
foreach(FNFSong.FNFNote note in notesToPlay)
{
if (!playing)
break;
float time = float.Parse(note.Time.ToString());
float newcurrentY = remapToRange((float) currentNoteTime, (float) 0,
(float) 16 * stepCrochet, (float) 0, (float) 0 + 3);
if (currentY < newcurrentY)
{
currentNoteTime = time;
toWrite = new StringBuilder(" ");
}

switch (note.Type)
{
case FNFSong.NoteType.Left:
case FNFSong.NoteType.RLeft:
if (note.Length == 0)
toWrite[0] = '←';
else
toWrite[0] = 'H';
break;
case FNFSong.NoteType.Down:
case FNFSong.NoteType.RDown:
if (note.Length == 0)
toWrite[1] = '↓';
else
toWrite[1] = 'H';
break;
case FNFSong.NoteType.Up:
case FNFSong.NoteType.RUp:
if (note.Length == 0)
toWrite[2] = '↑';
else
toWrite[2] = 'H';
break;
case FNFSong.NoteType.Right:
case FNFSong.NoteType.RRight:
if (note.Length == 0)
toWrite[3] = '→';
else
toWrite[3] = 'H';
break;
}
Console.WriteLine(toWrite.ToString());
}

while (notesPlayed != notesToPlay.Count)
{
Thread.Sleep(1);
Expand Down Expand Up @@ -214,6 +267,9 @@ public static void Main(string[] args)

Console.WriteLine("Loaded " + song.SongName + " with " + song.Sections.Count + " sections.");

crochet = (int)((60 / song.Bpm) * 1000);
stepCrochet = crochet / 4;

Console.WriteLine("Press F1 to start");
waitingStart = true;
}
Expand Down
Binary file added FNFBot/bin/Debug/FNFBot.exe
Binary file not shown.
Binary file added FNFBot/bin/Debug/FNFBot.pdb
Binary file not shown.
Binary file added FNFBot/bin/Debug/FNFDataAPI.dll
Binary file not shown.
Binary file added FNFBot/bin/Debug/FNFDataAPI.pdb
Binary file not shown.
Binary file added FNFBot/bin/Debug/Newtonsoft.Json.dll
Binary file not shown.
Loading

0 comments on commit 525e778

Please sign in to comment.