comparison pytouhou/game/text.py @ 304:f3099ebf4f61

Update attribute names to reflect the actual interface.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 13 Mar 2012 18:38:14 +0100
parents da53bc29b94a
children 4e8192aadcaa
comparison
equal deleted inserted replaced
303:647bde10353d 304:f3099ebf4f61
18 from pytouhou.vm.anmrunner import ANMRunner 18 from pytouhou.vm.anmrunner import ANMRunner
19 19
20 20
21 class Glyph(object): 21 class Glyph(object):
22 def __init__(self, sprite, pos): 22 def __init__(self, sprite, pos):
23 self._sprite = sprite 23 self.sprite = sprite
24 self._removed = False 24 self.removed = False
25 25
26 self.x, self.y = pos 26 self.x, self.y = pos
27 27
28 28
29 class Text(object): 29 class Text(object):
30 def __init__(self, pos, text, front_wrapper, ascii_wrapper): 30 def __init__(self, pos, text, front_wrapper, ascii_wrapper):
31 self._sprite = Sprite() 31 self.sprite = Sprite()
32 self._anmrunner = ANMRunner(front_wrapper, 22, self._sprite) 32 self.anmrunner = ANMRunner(front_wrapper, 22, self.sprite)
33 self._anmrunner.run_frame() 33 self.anmrunner.run_frame()
34 self._removed = False 34 self.removed = False
35 self._changed = True 35 self.changed = True
36 36
37 self.text = '' 37 self.text = ''
38 self.glyphes = [] 38 self.glyphes = []
39 39
40 self.front_wrapper = front_wrapper 40 self.front_wrapper = front_wrapper
61 for i in range(len(self.glyphes), len(text))) 61 for i in range(len(self.glyphes), len(text)))
62 elif len(text) < len(self.glyphes): 62 elif len(text) < len(self.glyphes):
63 self.glyphes[:] = self.glyphes[:len(text)] 63 self.glyphes[:] = self.glyphes[:len(text)]
64 64
65 for glyph, character in zip(self.glyphes, text): 65 for glyph, character in zip(self.glyphes, text):
66 glyph._sprite.anm, glyph._sprite.texcoords = self.ascii_wrapper.get_sprite(ord(character) - 21) 66 glyph.sprite.anm, glyph.sprite.texcoords = self.ascii_wrapper.get_sprite(ord(character) - 21)
67 glyph._sprite._changed = True 67 glyph.sprite.changed = True
68 68
69 self.text = text 69 self.text = text
70 self._changed = True 70 self.changed = True
71 71
72 72
73 def update(self): 73 def update(self):
74 if self._changed: 74 if self.changed:
75 if self._anmrunner and not self._anmrunner.run_frame(): 75 if self.anmrunner and not self.anmrunner.run_frame():
76 self._anmrunner = None 76 self.anmrunner = None
77 self._changed = False 77 self.changed = False
78 78