Hello,
I am currently reading Procedural Generation Content with C++. They start you off with a basic template using SFML, and it slowly builds off it. I have noticed a bug that is really bothering me now. I thought it might have been an error on my part. Unfortunately, it seems to be the source code in general. I did a google for the source code on github to see if someone fixed the problem. I only found some people who literally copied the final example's source code, which isn't helpful because I own it already.
What is happening is when I am stationary and press either down or right, there is a quick red flicker. If I am already moving and press down or right, there is no problem. I've tried messing around with the texture manager and they have done in a way I have not come across yet and I'm wondering if this is the issue or if I'm wasting my time. I would like to keep the book's code, but I might just replace the whole thing.
// Gets a texture from the texture manager from an ID.
sf::Texture& TextureManager::GetTexture(const int textureID)
{
auto it = m_textures.begin();
auto found = false;
while (it != m_textures.end())
{
if (it->second.first == textureID)
{
return *it->second.second;
}
else
{
++it;
}
}
}
I can't recall exactly what I did. But messing around with a modern for loop and the traditional way gave me different results. With one of the for loops, I got a "white" flicker when I went left now. I changed it back and the white is now gone. So I believe it has something to do with this. The original code from the book did this
for (auto it = m_textures.begin(); it != m_textures.end(); ++it)
{
if (it->second.first == textureID)
{
return *it->second.second;
}
}
When I changed the for loop to the modern iteration, the white flicker appears. So I have no idea what that means since I thought it was the same thing.
I hope this is enough information for an idea of the problem. Down below I posted a link of the source code from someone's Github that is basically the exact same from the basic template standpoint. If anyone can get me through this, I would greatly appreciate it.
https://github.com/utilForever/ProceduralContentGeneration
Thanks, have a great day!