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. ...

Get Beginning C++ Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.