DEV Community

TMcSquared
TMcSquared

Posted on

Crazy Developer Stories/Bugs

Hello all, I'd like to see some of the game developers of this community tell some of their craziest stories/bug fixes.

I'll start the list off, I was creating a GameState management structure within my project and wanted to see if I could create nested GameState managers(not the best idea in the world). The application would launch into the MainMenu, go to SinglePlayer, which would then go into the PlayingScreen. Now, PlayingScreen had another GameState manager inside of it and worked exactly like the main application's manager. On entry it would show the Loading screen which had an ImGui progress bar that was updated like this:

static float fraction = 0.0f;

ImGui::ProgressBar(fraction, ImVec2(100, 20));

fraction += 0.001f;

if(fraction > 1.0f )
{
    // This sets Playing as the current state
    g_Client->getPlayingScreen()->setState("playing")
}
Enter fullscreen mode Exit fullscreen mode

Some of you might already see the problem that I would have in changing the state of the PlayingScreen in this fashion. Playing had a button that told g_Client to go exit PlayingScreen and go directly back to SinglePlayer. When I did this and went back into PlayingScreen something was wrong...The Loading didn't show!

I thought that the std::vector that held the states wasn't clearing and was messing with the re-entry of PlayingScreen. That proved to be a long day of frustration and disappointment as I poured over std::vector docs online trying to get it to clear properly.

Finally, I was screen-sharing with one of my friends using Discord and he noticed a stutter going from SinglePlayer to the Playing state inside of PlayingScreen. So I investigated a little further and realized to my relief and now apparent idiocy that I never reset fraction when switching to Playing!!!

Here was the final code that fixed the entire problem in less than 30 seconds:

static float fraction = 0.0f;

ImGui::ProgressBar(fraction, ImVec2(100, 20));

fraction += 0.001f;

if(fraction > 1.0f )
{
    // This sets Playing as the current state
    g_Client->getPlayingScreen()->setState("playing")
    fraction = 0.0f; // <-- Note this part
}
Enter fullscreen mode Exit fullscreen mode

I hope you have a similar story, and if not, please comment on someone else's. Have a great day/night, everyone!

Top comments (2)

Collapse
 
zeddotes profile image
zeddotes

So, last night, I was stuck on writing a test for a function no bigger than 15-20 lines. Stuck for close to an hour when I realized the 2 strings (URIs) I was testing were different; was expecting a $ instead of &.

Rest assured I made it through the nightmare.

Collapse
 
tmcsquared profile image
TMcSquared

Lol, I don't know how many times I've switched $ for & while coding in C++.