Mercurial > touhou
comparison pytouhou/game/text.py @ 327:13201d90bb22
Display the text when collecting an item.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 21 Jun 2012 15:01:25 +0200 |
parents | 2fcdb8966957 |
children | 2c4589370cc6 |
comparison
equal
deleted
inserted
replaced
326:efcdf2ce747c | 327:13201d90bb22 |
---|---|
29 class Widget(object): | 29 class Widget(object): |
30 def __init__(self, pos, back_wrapper=None): | 30 def __init__(self, pos, back_wrapper=None): |
31 self.sprite = None | 31 self.sprite = None |
32 self.removed = False | 32 self.removed = False |
33 self.changed = True | 33 self.changed = True |
34 self.anmrunner = None | |
34 | 35 |
35 # Set up the backround sprite | 36 # Set up the backround sprite |
36 self.back_wrapper = back_wrapper | 37 self.back_wrapper = back_wrapper |
37 if back_wrapper: | 38 if back_wrapper: |
38 self.sprite = Sprite() | 39 self.sprite = Sprite() |
85 glyph.sprite.changed = True | 86 glyph.sprite.changed = True |
86 | 87 |
87 | 88 |
88 | 89 |
89 class Text(GlyphCollection): | 90 class Text(GlyphCollection): |
90 def __init__(self, pos, ascii_wrapper, back_wrapper=None, text=''): | 91 def __init__(self, pos, ascii_wrapper, back_wrapper=None, text='', xspacing=14, shift=21): |
91 GlyphCollection.__init__(self, pos, ascii_wrapper, back_wrapper) | 92 GlyphCollection.__init__(self, pos, ascii_wrapper, back_wrapper, xspacing=xspacing) |
92 self.text = '' | 93 self.text = '' |
94 self.shift = shift | |
93 | 95 |
94 self.set_text(text) | 96 self.set_text(text) |
95 | 97 |
96 | 98 |
97 def set_text(self, text): | 99 def set_text(self, text): |
98 if text == self.text: | 100 if text == self.text: |
99 return | 101 return |
100 | 102 |
101 self.set_sprites([ord(c) - 21 for c in text]) | 103 self.set_sprites([ord(c) - self.shift for c in text]) |
102 self.text = text | 104 self.text = text |
103 self.changed = True | 105 self.changed = True |
106 | |
107 | |
108 def set_color(self, color): | |
109 colors = {'white': (255, 255, 255), 'yellow': (255, 255, 0), 'blue': (192, 192, 255)} | |
110 for glyph in self.glyphes: | |
111 glyph.sprite.color = colors[color] | |
112 | |
113 | |
114 def timeout_update(self): | |
115 GlyphCollection.update(self) | |
116 if self.timeout % 2: | |
117 for glyph in self.glyphes: | |
118 glyph.y -= 1 | |
119 self.timeout -= 1 | |
120 if self.timeout == 0: | |
121 self.removed = True | |
122 | |
123 | |
124 def set_timeout(self, timeout): | |
125 self.timeout = timeout | |
126 self.update = self.timeout_update | |
104 | 127 |
105 | 128 |
106 | 129 |
107 class Counter(GlyphCollection): | 130 class Counter(GlyphCollection): |
108 def __init__(self, pos, anm_wrapper, back_wrapper=None, script=0, xspacing=16, value=0): | 131 def __init__(self, pos, anm_wrapper, back_wrapper=None, script=0, xspacing=16, value=0): |