annotate pytouhou/game/face.py @ 296:c074783d0847

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