Issues when i try to remove an i-th element from a vector

Hello guysi’m relatively new with this library, and i have problems to remove elements from a vector type who contains multiple objects of the same class.

Here is my project:

I’m testing with FlappyBird Game Clone

This is what happens when I try to use vect.erase(vect.begin()) type function;

Can anyone help me?

It’s a bit hard figuring out the issue in your code since it’s (sorry to say it) is kind of a mess at the moment.
My guess is that the issue is related to your spawn timer code.

What you should do, in my opinion, is stop push_back() and erase() a pipe each time it reach the left side of the window. Instead of erasing the pipe from the list, just move it to the other side of the window. So when the pipe goes out the left side of the window, move the pipe to the right side of the window and continue with the pipe movement. Do this with all the scrolling pipes and you’ll get an endless level.
By doing this, you only need to create some pipes at the startup of the game and then destroy them at the shutdown of the game.

Also, the game’s speed differs from time to time (slow movement at startup sometimes and really fast movement at startup sometimes) which means you also have some issues with your deltatime code.


Link Updated:

If someone find a bug please let me know.