Creating enemy sprites procedurally

Having the ability to render to sf::RenderTexture and store the results opens up a world of possibilities. One of these is combining multiple sprites to create new, more versatile ones. We can draw to an sf::RenderTexture class multiple times, and the sprites will overlap. This is an incredibly useful technique that can be used to generate a vast amount of sprite variations without all the work. This is shown in the following screenshot:

Creating enemy sprites procedurally

Using this approach, we'll create random armor for our enemies. We'll have three pieces of armor; head, torso, and legs. For each of these, we'll also have three variations; bronze, ...

Get Procedural Content Generation for C++ Game Development 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.