Timing
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.
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 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access