In my version, the player is using some software to copy folders from the computer to their own floppy disk. I made an animated progress bar for the win screen, which is the same for all difficulty levels.
Very imaginative. Nice work!
That’s really cool ! I suppose you used the Update() function ?
Yes, only because I glanced at its entry in the Unity API that was linked in one of the previous videos.
Here’s a class that I made, whose GetUpdatedProgressBar method I call inside Update.
class DownloadGraphic
{
private static string[] wheel = {"-", "\\", "|", "/"};
private int wheelState;
private int wheelIndex;
private StringBuilder progressBar;
private int sectionsRemaining;
private int currSectionIndex;
public DownloadGraphic(int totalDownloadSections)
{
progressBar = new StringBuilder();
this.sectionsRemaining = totalDownloadSections;
progressBar.Append('_', totalDownloadSections);
progressBar.AppendLine();
currSectionIndex = progressBar.Length;
// Progress bar is empty (blank spaces) initially
progressBar.Append(' ', totalDownloadSections + 1);
wheelIndex = progressBar.Length;
progressBar.AppendLine(wheel[wheelState]);
progressBar.Append('=', totalDownloadSections);
}
public string GetUpdatedProgressBar()
{
if (!IsProgressComplete())
{
progressBar.Replace(' ', '#', currSectionIndex, 1);
currSectionIndex += 1;
int nextWheelState = (wheelState + 1) % wheel.Length;
progressBar.Replace(wheel[wheelState], wheel[nextWheelState], wheelIndex, 1);
wheelState = nextWheelState;
sectionsRemaining -= 1;
}
return progressBar.ToString();
}
public bool IsProgressComplete()
{
return sectionsRemaining == 0;
}
}
loving the old school vibes this gives me.
A bit curious about your code though. How come wheelState throwing up an error about being used without first being initialised?
I guess it isn’t being default initialized to 0. Might have to put wheelState = 0;
in the constructor before it is used.
Really cool! I’m working on a project where I could use this type of animation. Do you have the Hacker class file I could take a look at?
Nice job!
Code is also very easy to follow.