Mercurial > touhou
comparison pytouhou/game/text.py @ 590:e15672733c93
Switch to Python 3.x instead of 2.7.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 30 Sep 2014 17:14:24 +0200 |
parents | e35bef07290d |
children | f2c3848dabff |
comparison
equal
deleted
inserted
replaced
589:0768122da817 | 590:e15672733c93 |
---|---|
96 glyph.sprite.alpha = alpha | 96 glyph.sprite.alpha = alpha |
97 | 97 |
98 | 98 |
99 | 99 |
100 class Text(GlyphCollection): | 100 class Text(GlyphCollection): |
101 def __init__(self, pos, ascii_anm, back_anm=None, text='', | 101 def __init__(self, pos, ascii_anm, back_anm=None, text=b'', |
102 xspacing=14, shift=21, back_script=22, align='left'): | 102 xspacing=14, shift=21, back_script=22, align='left'): |
103 GlyphCollection.__init__(self, pos, ascii_anm, back_anm, | 103 GlyphCollection.__init__(self, pos, ascii_anm, back_anm, |
104 xspacing=xspacing, back_script=back_script) | 104 xspacing=xspacing, back_script=back_script) |
105 self.text = b'' | 105 self.text = b'' |
106 self.shift = shift | 106 self.shift = shift |
117 | 117 |
118 def set_text(self, text): | 118 def set_text(self, text): |
119 if text == self.text: | 119 if text == self.text: |
120 return | 120 return |
121 | 121 |
122 self.set_sprites([ord(c) - self.shift for c in text]) | 122 if isinstance(text, str): |
123 text = text.encode() | |
124 | |
125 self.set_sprites([c - self.shift for c in text]) | |
123 self.text = text | 126 self.text = text |
124 self.changed = True | 127 self.changed = True |
125 | 128 |
126 | 129 |
127 def timeout_update(self): | 130 def timeout_update(self): |