comparison pytouhou/game/sprite.py @ 429:40d5f3083ebc

Implement PCB’s ANM2 format and vm.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:48:57 +0200
parents f3099ebf4f61
children d4874ebaa06e
comparison
equal deleted inserted replaced
428:f41a26971a19 429:40d5f3083ebc
16 from pytouhou.utils.interpolator import Interpolator 16 from pytouhou.utils.interpolator import Interpolator
17 17
18 18
19 class Sprite(object): 19 class Sprite(object):
20 __slots__ = ('anm', 'removed', 'changed', 'width_override', 'height_override', 20 __slots__ = ('anm', 'removed', 'changed', 'width_override', 'height_override',
21 'angle', 'force_rotation', 'scale_interpolator', 'fade_interpolator', 21 'angle', 'force_rotation', 'scale_interpolator',
22 'offset_interpolator', 'automatic_orientation', 'blendfunc', 22 'fade_interpolator', 'offset_interpolator',
23 'texcoords', 'dest_offset', 'allow_dest_offset', 'texoffsets', 23 'rotation_interpolator', 'color_interpolator',
24 'mirrored', 'rescale', 'scale_speed', 'rotations_3d', 24 'automatic_orientation', 'blendfunc', 'texcoords',
25 'dest_offset', 'allow_dest_offset', 'texoffsets', 'mirrored',
26 'rescale', 'scale_speed', 'rotations_3d',
25 'rotations_speed_3d', 'corner_relative_placement', 'frame', 27 'rotations_speed_3d', 'corner_relative_placement', 'frame',
26 'color', 'alpha', 'visible', '_rendering_data') 28 'color', 'alpha', 'visible', '_rendering_data')
27 def __init__(self, width_override=0, height_override=0): 29 def __init__(self, width_override=0, height_override=0):
28 self.anm = None 30 self.anm = None
29 self.removed = False 31 self.removed = False
36 self.force_rotation = False 38 self.force_rotation = False
37 39
38 self.scale_interpolator = None 40 self.scale_interpolator = None
39 self.fade_interpolator = None 41 self.fade_interpolator = None
40 self.offset_interpolator = None 42 self.offset_interpolator = None
43 self.rotation_interpolator = None
44 self.color_interpolator = None
41 45
42 self.automatic_orientation = False 46 self.automatic_orientation = False
43 47
44 self.blendfunc = 0 # 0 = Normal, 1 = saturate #TODO: proper constants 48 self.blendfunc = 0 # 0 = Normal, 1 = saturate #TODO: proper constants
45 49
76 self.offset_interpolator = Interpolator(self.dest_offset, self.frame, 80 self.offset_interpolator = Interpolator(self.dest_offset, self.frame,
77 (x, y, z), self.frame + duration, 81 (x, y, z), self.frame + duration,
78 formula) 82 formula)
79 83
80 84
85 def rotate_in(self, duration, rx, ry, rz, formula):
86 self.rotation_interpolator = Interpolator(self.rotations_3d, self.frame,
87 (rx, ry, rz), self.frame + duration,
88 formula)
89
90
91 def change_color_in(self, duration, r, g, b, formula):
92 self.color_interpolator = Interpolator(self.color, self.frame,
93 (r, g, b), self.frame + duration,
94 formula)
95
96
81 def update_orientation(self, angle_base=0., force_rotation=False): 97 def update_orientation(self, angle_base=0., force_rotation=False):
82 if (self.angle != angle_base or self.force_rotation != force_rotation): 98 if (self.angle != angle_base or self.force_rotation != force_rotation):
83 self.angle = angle_base 99 self.angle = angle_base
84 self.force_rotation = force_rotation 100 self.force_rotation = force_rotation
85 self.changed = True 101 self.changed = True