O'Reilly logo

Procedural Content Generation for C++ Game Development by Dale Green

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required