So uh, here's an example of a portrait that's not dynamic:
Code: Select all
image akane casual idle = Flatten(LiveComposite(
(384, 640),
(0, 0), im.Crop("graphics/char/akane/casual/idle.png", (0,0,384,640)),
(128, 144), "aci eyes",
(128, 208), WhileSpeaking("akane", "aci mouth")
))
image aci eyes:
animation
Null()
choice:
pause 3.8
choice:
pause 2.8
choice:
pause 1.5
choice:
pause 0.8
im.Crop("graphics/char/akane/casual/idle.png", (384, 0, 128, 64))
pause 0.1
im.Crop("graphics/char/akane/casual/idle.png", (384, 64, 128, 64))
pause 0.1
im.Crop("graphics/char/akane/casual/idle.png", (384, 0, 128, 64))
pause 0.1
repeat
image aci mouth:
Null()
pause 0.13
im.Crop("graphics/char/akane/casual/idle.png", (384, 160, 128, 64))
pause 0.13
im.Crop("graphics/char/akane/casual/idle.png", (384, 224, 128, 64))
pause 0.13
repeat
It went well, until I wanted to work with animations - the eyes and the mouth. I don't know the equivalents for the functions used in the latter two blocks, for use in python. The dynamic system I have currently looks like this, based on some of the code from the documentation:
Code: Select all
class Portrait(renpy.Displayable):
def __init__(self, image, width, eyepos, moupos, **kwargs):
# Pass additional properties on to the constructor.
super(Portrait, self).__init__(**kwargs)
# Values
self.image = ("graphics/char/%s" % image)
self.width = width
self.eyepos = eyepos
self.moupos = moupos
def render(self, width, height, st, at):
# Display the portrait
portrait = Flatten(LiveComposite(
(self.width, 640),
(0, 0), im.Crop(self.image, (0, 0, self.width,640)),
(self.eyepos[0], self.eyepos[1]), self.eyes(self.image, self.width),
))
# Process the portrait to render it
child_render = renpy.render(portrait, self.width, 640, st, at)
return child_render
def eyes(self, image, x):
return im.Crop(image, (x, 64, 128, 64))
The code can be called with an image like image akane_test = Portrait("akane/casual/idle.png", width=384, eyepos=(128, 144), moupos=(128,208)). Portrait defines the image, width of the portrait, and the x/y of the eyes and mouth elements.
The image in question looks like this. I use im.Crop to slice the image up as necessary.
So my question remains; how do I perform what I do with the first lot of code in a dynamic system, so that I simply have to refer to that Portrait() for all character art? What is the equivalent of animation, choice, pause, repeat, and how do I get it to work just like the non-dynamic code? (It seems like it works so far though, sans the animation.)