0 votes

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!

in Engine by (72 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.