Sunday, January 8, 2017

Jan 8 2017 - Displaying images sanely

I think one of the most difficult challenges I face with not having a strong programming background is not knowing exactly how syntax is set up for different languages.

Case in point: Renpy. You would think flipping an image is a simple thing. Spoiler alert: It is. But figuring out how the heck the engine expects you to do it with the spaghetti documentation that exists is kind of a nightmare in my experience.

I have a picture, and I want to be able to display it facing left or right. This isn't a difficult thing to ask. But there are a lot of ways to do this, some of which are more trouble than others. It's possible to declare the image transforms upon initialization, but when you could potentially be flipping thousands of images, you need a much better solution. Same with exporting duplicates of every image that could be flipped and hoping you remember the naming conventions.

It's a nightmare, and while it might work for a one-off instance, it DOESN'T work for my project at all (or most projects, I'd wager).

Fortunately, there's a much easier solution, one that isn't covered in ANY of the documentation at all.

I present to you the xzoom command.

    scene black
    "This here is just a test scene meant to play around."
    "We're going to play around with some images right now."
    show tzania happy at right:
          xzoom -1.0

 The gist here is pretty simple: By declaring a show command with a colon, you can apply transformations such as scale, zoom, rotate, whatever. It does NOT work like the following:

                 show tzania happy at right with xflip
Despite the fact that the documentation seems to indicate this should work. (It doesn't because it has no idea what xflip is. Or xzoom. Or a lot of other things for that matter.)

So lessons learned once again, and if you ever need to flip an image in renpy quickly, this is how you do it. (You can also use yzoom -1.0, that works just as well but with the other axis.)

I'm sure I'll figure out other ways I can use this to my advantage in the future.

No comments:

Post a Comment