Timing
Before we can move the bee and the clouds, we need to consider timing. As we already know, the main game loop executes repeatedly until the player presses the Escape key.
We have also learned that C++ and SFML are exceptionally fast. In fact, my aging laptop executes a simple game loop (like the current one) at around five thousand times per second.
The frame rate problem
Let's consider the speed of the bee. For the purpose of discussion, we could pretend that we are going to move it at 200 pixels per second. On a screen that is 1,920 pixels wide, it would take, very approximately, 10 seconds to cross the entire width, because 10 x 200 is 2,000 (near enough to 1,920).
Furthermore, we know that we can position any of our sprites with setPosition(...,...)
. We just need to put the x and the y coordinates in the parentheses.
In addition to setting the position of a sprite, we can also get the current position of a sprite. To get the horizontal x coordinate of...