Flappy Bird crash StateMachine

  • Sander172
    Likes 0

    Problem Description

    Hello, 

    My application is crashing in the StateMachine. I'm following Flappy Bird tutorial and I’m at tutorial 5 – SplashScreen. 

     

    Error: Expression: deque iterator not dereferencable

     

    Can you help me with this?

     


  • Sonar Systems admin
    Likes 0

    Did I run the project and the point you ran it?

  • Sander172
    Likes 0

    What do you mean exactly? I’m making the game 4 months later.

  • Sonar Systems admin
    Likes 0

    I mean in the video you followed, when you ran the project, did I also run it or not?

  • Sander172
    Likes 0

    I checked it and the next video you’re going to run it. I will follow the next video and if it doesn’t work, I will ask you again.

  • Sander172
    Likes 0

    I still get the same error. The image is loading, but after that it crash. What does states.pop? If I remove it, it doesn't crash.


  • Sander172
    Likes 0

    I added ‘-d’ (SFML libraries) in the release and went back to debug, and now it works.


  • Sander172
    Likes 0

    So I didn't fix the problem. I forgot to turn on ‘pop’. Could you help me? What does this do? And how can I fix it?

     

    Edit:

    Should ‘_isRemoving’ be true when the main menu is loaded? It’s already true in the beginning...


  • Sonar Systems admin
    Likes 0

    Pop?           


    This reply has been verified.
  • Sander172
    Likes 0

    In the StateMachine class there is some code:

    • this->_states.pop();

    This clears the state and after clearing the state: the application crash, because there is no state. Do I need to clear the state after the splashscreen is done? At the moment it automatically pops it on startup.

  • Sonar Systems admin
    Likes 0

    Only pop it if there are other states it can fall back to. Have you tryied the code from the GitHub page to see if that works as intended?

  • Sander172
    Likes 0

    I got the code from GitHub. Boolean ‘_isRemoving’ is in the beginning always true, but this should be false right? I fixed it by setting it default to false and to true when the main menu is open. Is this the right way?


  • Sonar Systems admin
    Likes 0

    Yes .      

  • Sander172
    Likes 0

    Ah nice, thanks for your response.

  • Sonar Systems admin
    Likes 0

    No problem, if you have anymore questions do not hesitate to post them.

Login to reply