-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pick up replacement images from world directory #95
Draft
wjt
wants to merge
7
commits into
main
Choose a base branch
from
find-images-in-world
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+158
−34
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dylanmccall I briefly demoed this to you yesterday – this is the tidied-up version of the branch. @jbourqueendless Does this match what you were expecting? |
Previously, all the candy falling in the background would have to be one specific texture. With this change, it is possible to specify more than one texture. They will be used in a different order each time, cycling through the list to avoid repetition until it is necessary. Because CandySpawner maintains a cache of candy sprites, this doesn't mean that every candy that falls will be random. On early levels where only one candy is visible at a time, it will be the same one on repeat; once the player gets far enough for two to be visible at once, a second one will be added to the mix; and so on. But on each playthrough, the exact textures that get used will be different.
We will, in due course, need a new variant of this function that finds image files. In preparation, move it to a new ResourceFinder class. This function, and its future sibling, are essentially polyfills for a new function that will ship with Godot 4.4, so putting them in one place will make it easier to clean up later.
To help build interest in getting to know Godot in an introductory workshop, we want to make it possible to override a world's image assets textures by just placing image files at particular paths in the world's directory, without needing to adjust anything in the editor itself. Add a helper function which looks up images in a named subdirectory of an Image directory adjacent to the current scene.
Previously, to override the texture(s) used by a world's CandySpawner instance, you would use the inspector to set the candy_textures property on the instance. The default value of the property was a one-element list of the default Candy.png image. To help build interest in getting to know Godot in an introductory workshop, we want to make it possible to override a world's candy textures by just placing image files at a particular path in the world's directory, without needing to adjust anything in the editor itself. Use ResourceFinder.load_world_assets() during CandySpawner's initialisation if the candy_textures property is empty. If no textures are found in this directory, fall back in code to the default texture. Change the default value of the property to the empty list.
Previously, to override the texture(s) used by a world's Goobers or Player, you would need to: 1. Copy the Goober/Player scene into the world (perhaps as an inherited scene) 2. Adjust its Sprite2D's texture 3. Copy the TileSet into the world 4. Replace the Goober/Player scene in the TileSet with the custom instance To help build interest in getting to know Godot in an introductory workshop, we want to make it possible to override a world's Goober or Player textures by just placing image files at a particular path in the world's directory, without needing to adjust anything in the editor itself. Use ResourceFinder.load_world_assets() to look for Player and Goober textures in a directory adjacent to the current scene. If any are found, pick one at random for each instance. If none are found, preserve the old behaviour.
It might be that a learner will drop any old image into the Image/Candy directory of their world. Handle this case by scaling down any image that is larger than the default image so that its longest axis is the same size as the default.
1cd28e9
to
b383268
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To help build interest in getting to know Godot in an introductory workshop, we want to make it possible to override a world's image assets textures by just placing image files at particular paths in the world's directory, without needing to adjust anything in the editor itself.
Add a helper function which looks up images in a named subdirectory of an Image directory adjacent to the current scene.
Adjust CandySpawner, Player and Goober to use these images, if present, selecting at random if there are more than one. Scale down any alternative Candy images that are too big.
Update the documentation accordingly.