Looking for advice on how to better organize layeredimage code for multiple poses of the same character.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Sydney
Newbie
Posts: 1
Joined: Fri Jun 11, 2021 11:40 am
Contact:

Looking for advice on how to better organize layeredimage code for multiple poses of the same character.

#1 Post by Sydney »

Hey! I have a friend I'm trying to help out with some layeredimages they're making for their own project, and I'm trying to figure out a better way to reuse identical attributes across multiple poses of the same sprite.

So in a nutshell, they have multiple poses for a sprite in their project they're developing, and there is the potential for the assets of said sprite being updated as the project goes on (mostly in the form of another potential pose? I think? I'm not involved in any direct development on their project, so I'm unsure as to how their workflow and asset creation works). However, to try and cut down on the amount of additional work necessary for these sprites, at least two of the poses share one entire set of identical groups/attributes - that being the individual facial components of the character (eyes/mouth/blush/etc); the end result is that even though the face of the character is in a different spot across the two poses, the actual assets and logic behind showing them on said characters' face is entirely identical code.

As a really simplified example:

Code: Select all

layeredimage char pose1:
    group face:
        #all the code for the facial features

layeredimage char pose2:
    group face:
        xoffset 10 yoffset -10
        #all the *same* code for the facial features as pose1
However...this kind of presents a unique problem, and it's the specific one I'm trying to help said friend with (And, well, my own work would also benefit from learning this); this basically means that the identical code in question *can* be copy/pasted across the two poses, but in case that process is overlooked or forgotten - or, additionally, if a minor tweak is enacted on one but neglected to be applied to the other - then there's a lot more potential for issues to arise across one or the other of the poses. This is before even adding in the requirement for the x/y offsets to be different for these, since those obviously also need to be unique to the two poses (And thus can't be copy/pasted from one to the other either, adding in another possible complication).

I haven't been able to come up with a good solution to this, though. Obviously I've already outlined "just copy/paste", but I want to try and avoid the pitfalls I've outlined above.

One solution I originally thought might be promising would be to, instead, disregard the two poses entirely and just list the two "poses" now as different attributes under the same layeredimage definition; I figured this would eliminate the problem since there'd then only be one place to update...but then, instead, that just seems to shift the problem elsewhere, since to do *that* requires adding in a lot more "if_any / if_not / if_all" conditionals to be applied to the attributes so that only the correct set of facial features appears when the relevant "pose" attribute is in place. This feels like a complicated way to accomplish this, and...still not really make the code easy to update without the same potential problems as before. If it was possible to conditionally apply ATL attributes to a number of attributes quickly and simply - i.e., without just copy/pasting the code as a different group entirely and just putting in different ATL between two groups - then this wouldn't be anywhere near as big of an issue, but I don't think this is possible?

I even briefly thought of maybe just putting in the "face" itself (or the features of the face, anyway) as their own layeredimage and then putting that into the overall layeredimage of the character sprite...except there doesn't seem to be a way to pass attributes into one layeredimage to then be applied to a layeredimage within that one quickly and easily - or at all?

I've pretty much run out of ideas here. Does anyone know of a better way to accomplish this cleanly and simply? Thank you for any advice you might give!

Post Reply

Who is online

Users browsing this forum: Google [Bot]