1
General / Re: A noob can't handle lists
« on: November 30, 2017, 02:27:17 pm »
Hello, I think I can help (if you haven't figured it out yet).
It looks like you made some basic mistakes. Have you read the tutorials and stuff? You really shouldn't spend 6 days on such a problem, it's usually just a small mistake
First, understand how sf::Texture works. You are loading a texture and then copying it into each object. I don't think you should ever copy a texture like that.
A sf::Texture lives in the GPU memory and there it only ever needs one copy that it can draw in different places. I don't know why copying only doesn't work for the walls (shouldn't it? Still kind of a noob myself... It might be your drawing code), but even if it did, it wouldn't make sense.
I compiled your code and for me all 7 rectangles are white, so it even depends on the system/compiler, which is weird. But saving the texture as a reference in the Wall class (I added 3 '&'s) and making a second sf::Texture for the other wall in main() fixes it.
I really don't know why your version didn't work, though.
Also, if I replace the std::list of walls with a std::vector it works exactly the same. I don't think you should use lists if you can replace it that easily with a vector. But maybe you have some bigger plans where a list makes sense.
It looks like you made some basic mistakes. Have you read the tutorials and stuff? You really shouldn't spend 6 days on such a problem, it's usually just a small mistake
First, understand how sf::Texture works. You are loading a texture and then copying it into each object. I don't think you should ever copy a texture like that.
A sf::Texture lives in the GPU memory and there it only ever needs one copy that it can draw in different places. I don't know why copying only doesn't work for the walls (shouldn't it? Still kind of a noob myself... It might be your drawing code), but even if it did, it wouldn't make sense.
I compiled your code and for me all 7 rectangles are white, so it even depends on the system/compiler, which is weird. But saving the texture as a reference in the Wall class (I added 3 '&'s) and making a second sf::Texture for the other wall in main() fixes it.
I really don't know why your version didn't work, though.
Also, if I replace the std::list of walls with a std::vector it works exactly the same. I don't think you should use lists if you can replace it that easily with a vector. But maybe you have some bigger plans where a list makes sense.