Frequently asked questions
Q) 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 can see that they are numerous. Sprites have a position, color, size, rotation, and much more. 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 want to 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 could even give our Cloud class an SFML Sprite object. We could then simplify our cloud code even further. We will look at designing our own classes in the next chapter.