Need guidance on generating components for a composite image

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alwaysusa

I am trying to generate an image made of several components, each selected randomly from a pool of assets. A JSON file will eventually define the image composition ruleset.

Imagine a picture of a lake is the base image. I then need to layer on top an image of a boat (and there are 4 to choose from), and then an image of a bird (there are 5 to choose from). Once the script has completed the generation, a final composite image is presented to the player.

My question is - what approach would you use for this? I am thinking the best way achieve this is to preload all of the component assets (in the above example, there only 9) then simply randomly choose one of each type as needed. My concern is that in my game, there are a lot more types and choices, resulting in possibly 30 or 40 assets that would need to be preloaded, only for most of them to be ignored each time the script is run. The selected assets would also need to be positioned, so in the above example the “lake” would be a scene that includes relevant position2D information for the child scenes to locate.

For context, the game loop is as follows:

Script constructs image #1
Player is presented with success conditions to evaluate the image
Player chooses if it’s a match or not
Score is tallied
Script constructs image #2

So there’s no fast paced game play, though excessive stuttering would cause an issue as the round is timed.

So - what would your approach be? Is it worth preloading everything? If not, is there a way to scan folder for files (they’ll be scenes and loaded as children) and randomly choose which scene to load? I had also considered adding everything as hidden sprites and only showing the randomly selected components - but that seems inelegant.

Cheers!