Relative Content

Tag Archive for c++sfmlstdvector

std::vector problem: Debug assertion failed! Expression: Vector subscript out of range

Could somebody explain what is happening here?
I’m not super deep into programming so explain in a monkey language please.
I’m making a std::vector container and i add a sf::RectangleShape object to the vector after clicking a button, then im running through all the elements in a for loop and setting the position for my rectangle and normalizing it, so it travels through the screen instead of just teleporting.
After that im drawing each rectangle in the for loop.
The code looks like it should work to me.
PS. I’m using Visual Studio