FAQ
Q) I admit that the array solution for the clouds was more efficient. But do we really need three separate arrays, one for active, one for speed, and one for the sprite itself?
A) If we look at the properties/variables that various objects have, for example Sprite objects, we will see they are numerous. Sprites have position, color, size, rotation, and many more as well. But it would be just perfect if they had active, speed, and perhaps more as well. The problem is that the coders at SFML can't possibly predict all the ways that we will use their Sprite class. Fortunately, we can make our own classes. We could make a class called Cloud that has a Boolean for active and an int for speed. We can even give our Cloud class an SFML Sprite object. ...
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