comparison pytouhou/game/face.py @ 286:4838e9bab0f9

Implement dialogs (MSG files).
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 12 Feb 2012 16:06:03 +0100
parents
children f3099ebf4f61
comparison
equal deleted inserted replaced
285:2100276c289d 286:4838e9bab0f9
1 # -*- encoding: utf-8 -*-
2 ##
3 ## Copyright (C) 2012 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published
7 ## by the Free Software Foundation; version 3 only.
8 ##
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details.
13 ##
14
15
16 from pytouhou.game.sprite import Sprite
17 from pytouhou.vm.anmrunner import ANMRunner
18
19
20 class Face(object):
21 __slots__ = ('_anm_wrapper', '_sprite', '_anmrunner', 'side', 'x', 'y')
22
23 def __init__(self, anm_wrapper, effect, side):
24 self._anm_wrapper = anm_wrapper
25 self._sprite = Sprite()
26 self._anmrunner = ANMRunner(anm_wrapper, side * 2, self._sprite)
27 self.side = side
28 self.load(0)
29 self.animate(effect)
30
31 #FIXME: the same as game.effect.
32 self.x = -32
33 self.y = -16
34 self._sprite.allow_dest_offset = True
35
36
37 def animate(self, effect):
38 self._anmrunner.interrupt(effect)
39
40
41 def load(self, index):
42 self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(self.side * 8 + index)
43 self._anmrunner.run_frame()
44
45
46 def update(self):
47 self._anmrunner.run_frame()