My sprites have a lot of different layers, which I mix and match to show different emotions. So if I want to show the “angry” emotion, for example, I need to change a bunch of different layers (eyes, mouth, eyebrows, arms, etc.).
In the olden days of LiveComposite, I would just write a function to set a bunch of variables. So something like:
Code: Select all
init python:
def set_emotion(emotion):
if emotion == “angry”:
$ eyes = “narrow”
$ mouth = “yell”
$ eyebrows = “down”
$ right_arm = “down”
$ left_arm = “punch”
# and so forth
elif emotion == “sad”:
$ eyes = “narrow”
$ mouth = “frown”
$ eyebrows = “up”
$ right_arm = “down”
$ left_arm = “down”
# and so forth
# and so on for other emotions
$ set_emotion(“angry”)
char “I’m angry!”
$ set_emotion(“sad”)
char “I’m sad.”
$ mouth = “yell”
char “I’m still sad but yelling now!”
Code: Select all
char eyes_narrow mouth_yell eyebrows_down rightarm_up leftarm_punch “I’m angry!”
Code: Select all
init python:
class Picker(object):
def __init__(self, options):
self.options = [ i.split() for i in options ]
def __call__(self, attributes):
rv = set(attributes)
for i in self.options:
if i[0] in attributes:
rv.update(i[1:])
return rv
layeredimage char:
attribute_function Picker([
"angry eyes_narrow mouth_yell eyebrows_down rightarm_up leftarm_punch",
"sad eyes_narrow mouth_frown eyebrows_up rightarm_down leftarm_down",
"sad_yell eyes_narrow mouth_yell eyebrows_up rightarm_down leftarm_down",
# and so on for other emotions
])
group combos:
attribute angry null
attribute sad null
attribute sad_yell null
# and so on for other emotions
# add groups for all the attributes below
char sad "I'm sad."
char sad_yell "I'm sad but yelling now!"
What I really want is to use sets of attributes with the ability to change individual attributes without defining a completely new set. Something like this would be perfect:
Code: Select all
char sad “I’m sad.”
#where “sad” is a set of eyes, mouth, eyebrows, etc. attributes I defined
char mouth_yell “I’m still sad but yelling now!”
#swaps the mouth attribute to “yell,” but keeps the rest of the attributes in the “sad” set
char angry mouth_smile “I’m angry but smiling.”
#shows all the attributes in the “angry” set, but swaps the mouth attribute to “smile”