Mercurial > touhou
comparison pytouhou/resource/anmwrapper.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 | 2100276c289d |
children |
comparison
equal
deleted
inserted
replaced
428:f41a26971a19 | 429:40d5f3083ebc |
---|---|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 ## GNU General Public License for more details. | 12 ## GNU General Public License for more details. |
13 ## | 13 ## |
14 | 14 |
15 from itertools import repeat | 15 from itertools import repeat, chain |
16 | 16 |
17 | 17 |
18 class AnmWrapper(object): | 18 class AnmWrapper(object): |
19 def __init__(self, anm_files, offsets=None): | 19 def __init__(self, anm_files, offsets=None): |
20 """Wrapper for scripts and sprites described in “anm_files”. | 20 """Wrapper for scripts and sprites described in “anm_files”. |
30 self.sprites = {} | 30 self.sprites = {} |
31 | 31 |
32 if not offsets: | 32 if not offsets: |
33 offsets = repeat(0) # “offsets” defaults to zeroes | 33 offsets = repeat(0) # “offsets” defaults to zeroes |
34 | 34 |
35 for anm, offset in zip(anm_files, offsets): | 35 for anm, offset in zip(chain(*anm_files), offsets): |
36 for script_id, script in anm.scripts.iteritems(): | 36 for script_id, script in anm.scripts.iteritems(): |
37 self.scripts[script_id + offset] = (anm, script) #TODO: check | 37 self.scripts[script_id + offset] = (anm, script) #TODO: check |
38 for sprite_id, sprite in anm.sprites.iteritems(): | 38 for sprite_id, sprite in anm.sprites.iteritems(): |
39 self.sprites[sprite_id + offset] = (anm, sprite) | 39 self.sprites[sprite_id + offset] = (anm, sprite) |
40 | 40 |