Flappy Bird Clone - Create Moving Ground

  • wutzination
    Likes 0

    Problem Description

    Hello,

    I have been trying to complete the Flappy Bird Clone Tutorial and everything worked fine until the “create moving ground” video.

    My problem is, that i can build the program without errors and start it, but the ground will not load/is not visible. To be sure that the method “DrawLand” is used, i write out std::cout << "DrawLand" << std::endl; with every call and the message shows up in the console.

    I even compared my files with your examples from git, but could not find a mistake.

    What could be the reason for not loading/showing the land.png?

    Sadly my programming skills are not good enought for finding an error without error-message.

    with best regards,

    Laurenz

  • Sonar Systems admin
    Likes 0

    Ehst was the last step that worked?


    This reply has been verified.
  • wutzination
    Likes 0

    The last step that worked without problems was automatically spawning pipes.

    They are properly generated and deleted.

  • Sonar Systems admin
    Likes 0

    Have you tried the source code from the GitHub page?

  • wutzination
    Likes 0

    Thank you for your patience!
     

    I could find my mistake and now the land gets drawn properly.

     

    I accidentally placed a “;” after

    if (_landSprites.at(i).getPosition().x < (0 -_landSprites.at(i).getGlobalBounds().width))

                       

    in my move land method, which led to the land not moving.

    In the git examples  getLocalBounds is used instead of getGlobalBounds. What is the reason for this?

     

    With best regards,

    Laurenz

  • Sonar Systems admin
    Likes 0

    Which one was you using?

  • wutzination
    Likes 0

    getGlobalBounds is used in the videos,

    getLocalBounds is used in the git files.


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    For which aspect?

  • wutzination
    Likes 0

    when getting the size of some sprite or the window itselfe

  • Sonar Systems admin
    Likes 0

    This will help explain the difference https://www.sfml-dev.org/faq.php#graphics-bounds 

Login to reply