Before we can move the bee and the clouds, we need to consider timing. As we already know, the main game loop executes over and over again, until the player presses the Esc key.
We have also learnt that C++ and SFML are exceptionally fast. In fact, my ageing laptop executes a simple game loop (such as the current one) at around five thousand times per second.
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 1920 pixels wide, it would take, very approximately, 10 seconds to cross the entire width, because 10 x 200 is 2000 (near enough to 1920).
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 position of a sprite. To get the horizontal x coordinate of the bee, for example, we would...