Advertisement
Guest User

auto define image LiveComposite

a guest
Mar 8th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.84 KB | None | 0 0
  1.     def define_composites(folder_name, image_size, side_image=False):
  2.         base = {}
  3.         mouth = {}
  4.         eyes = {}
  5.         brows = {}
  6.         arms = {}
  7.         hair = {}
  8.         effect = {}
  9.         blank = ""
  10.         sidedict = {}
  11.        
  12.         for path in renpy.list_files():
  13.             if path.startswith("sprites/" + folder_name):
  14.                 filename = path.split("/")[-1]
  15.                 filename = os.path.splitext(filename)[0]
  16.                
  17.                 if filename.endswith("base"):
  18.                     base[folder_name + filename[:-4]] = path
  19.                 elif filename.startswith("ku"):
  20.                     mouth[filename[2:]] = path
  21.                 elif filename.startswith("me"):
  22.                     eyes[filename[2:]] = path
  23.                 elif filename.startswith("ma"):
  24.                     brows[filename[2:]] = path
  25.                 elif filename.startswith("fx"):
  26.                     effect[filename[2:]] = path
  27.                 elif filename.startswith("pose"):
  28.                     arms[filename[4:]] = path
  29.                 elif filename.startswith("ka"):
  30.                     hair[filename[2:]] = path
  31.                 ### function requires a "none.png" file
  32.                 elif filename == "none":
  33.                     blank = path
  34.                      
  35.         effect["x"] = blank
  36.         for x in [mouth, eyes, brows, arms, hair, effect]:
  37.             if len(x) == 0:
  38.                 x["x"] = blank
  39.                
  40.         position = (0, 0)
  41.         for type in base:
  42.             layer0 = (position, base[type])
  43.             for teeth in mouth:
  44.                 layer1 = layer0 + (position, mouth[teeth])
  45.                 for ball in eyes:
  46.                     layer2 = layer1 + (position, eyes[ball])
  47.                     for brow in brows:
  48.                         layer3 = layer2 + (position, brows[brow])
  49.                         for arm in arms:
  50.                             layer4 = layer3 + (position, arms[arm])
  51.                             for cut in hair:
  52.                                 layer5 = layer4 + (position, hair[cut])
  53.                                 for shoot in effect:
  54.                                     layers = layer5 + (position, effect[shoot])
  55.                                     shortname = (type, teeth, ball, brow, arm, cut, shoot)
  56.                                     renpy.image(shortname, LiveComposite(image_size, *layers))
  57.                                    
  58.                                     if side_image:
  59.                                         shortstr = type + " " + teeth + " " + ball + " " + brow + " " + arm + " " + cut + " " + shoot
  60.                                         sidedict[shortstr] = LiveComposite(image_size, *layers)
  61.                                        
  62.         if side_image:
  63.             return sidedict
  64.         #end of define_composites function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement