Mercurial > touhou
annotate pytouhou/game/face.py @ 504:69c73023f7a0
Make ANM garbage collectable.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 23 Oct 2013 18:24:17 +0200 |
parents | b9d2db93972f |
children | e35bef07290d |
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 |
440
b9d2db93972f
Add a base Element class for every object in pytouhou.game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
433
diff
changeset
|
16 from pytouhou.game.element import Element |
286
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 from pytouhou.game.sprite import Sprite |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 from pytouhou.vm.anmrunner import ANMRunner |
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 |
440
b9d2db93972f
Add a base Element class for every object in pytouhou.game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
433
diff
changeset
|
21 class Face(Element): |
b9d2db93972f
Add a base Element class for every object in pytouhou.game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
433
diff
changeset
|
22 __slots__ = ('_anms', 'side') |
286
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
24 def __init__(self, anms, effect, side): |
440
b9d2db93972f
Add a base Element class for every object in pytouhou.game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
433
diff
changeset
|
25 Element.__init__(self, (-32, -16)) |
b9d2db93972f
Add a base Element class for every object in pytouhou.game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
433
diff
changeset
|
26 |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
27 self._anms = anms |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
28 self.sprite = Sprite() |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
29 self.anmrunner = ANMRunner(self._anms[0][0][0], side * 2, self.sprite) |
286
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 self.side = side |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 self.load(0) |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 self.animate(effect) |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 #FIXME: the same as game.effect. |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
35 self.sprite.allow_dest_offset = True |
286
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 |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 def animate(self, effect): |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
39 self.anmrunner.interrupt(effect) |
286
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 |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 def load(self, index): |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
43 self.sprite.anm, self.sprite.texcoords = self._anms[self.side][index] |
286
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): |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
47 self.anmrunner.run_frame() |