Mercurial > touhou
annotate pytouhou/game/text.py @ 337:bc162f60f0a0
Skip dialogs in the boss rush mode, and make boss rush skipping faster
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 01 Jul 2012 18:07:33 +0200 |
parents | 13201d90bb22 |
children | 2c4589370cc6 |
rev | line source |
---|---|
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 ## |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 ## Copyright (C) 2011 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 ## |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 ## |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 ## GNU General Public License for more details. |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ## |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 from copy import copy |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 from pytouhou.game.sprite import Sprite |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 from pytouhou.vm.anmrunner import ANMRunner |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 class Glyph(object): |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 def __init__(self, sprite, pos): |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
23 self.sprite = sprite |
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
24 self.removed = False |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 self.x, self.y = pos |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
29 class Widget(object): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
30 def __init__(self, pos, back_wrapper=None): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
31 self.sprite = None |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
32 self.removed = False |
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
33 self.changed = True |
327
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
34 self.anmrunner = None |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
36 # Set up the backround sprite |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
37 self.back_wrapper = back_wrapper |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
38 if back_wrapper: |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
39 self.sprite = Sprite() |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
40 self.anmrunner = ANMRunner(back_wrapper, 22, self.sprite) |
322
4e8192aadcaa
Give a better interface for text handling.
Thibaut Girka <thib@sitedethib.com>
parents:
304
diff
changeset
|
41 self.anmrunner.run_frame() |
4e8192aadcaa
Give a better interface for text handling.
Thibaut Girka <thib@sitedethib.com>
parents:
304
diff
changeset
|
42 |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 self.x, self.y = pos |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 def update(self): |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
46 if self.changed: |
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
47 if self.anmrunner and not self.anmrunner.run_frame(): |
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
48 self.anmrunner = None |
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
300
diff
changeset
|
49 self.changed = False |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
51 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
52 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
53 class GlyphCollection(Widget): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
54 def __init__(self, pos, anm_wrapper, back_wrapper=None, ref_script=0, xspacing=14): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
55 Widget.__init__(self, pos, back_wrapper) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
56 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
57 self.ref_sprite = Sprite() |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
58 self.anm_wrapper = anm_wrapper |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
59 self.glyphes = [] |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
60 self.xspacing = xspacing |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
61 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
62 # Set up ref sprite |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
63 anm_runner = ANMRunner(anm_wrapper, ref_script, self.ref_sprite) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
64 anm_runner.run_frame() |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
65 self.ref_sprite.corner_relative_placement = True #TODO: perhaps not right |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
66 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
67 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
68 def objects(self): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
69 return self.glyphes |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
70 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
71 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
72 def set_length(self, length): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
73 current_length = len(self.glyphes) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
74 if length > current_length: |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
75 self.glyphes.extend(Glyph(copy(self.ref_sprite), |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
76 (self.x + self.xspacing * i, self.y)) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
77 for i in range(current_length, length)) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
78 elif length < current_length: |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
79 self.glyphes[:] = self.glyphes[:length] |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
80 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
81 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
82 def set_sprites(self, sprite_indexes): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
83 self.set_length(len(sprite_indexes)) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
84 for glyph, idx in zip(self.glyphes, sprite_indexes): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
85 glyph.sprite.anm, glyph.sprite.texcoords = self.anm_wrapper.get_sprite(idx) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
86 glyph.sprite.changed = True |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
87 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
88 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
89 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
90 class Text(GlyphCollection): |
327
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
91 def __init__(self, pos, ascii_wrapper, back_wrapper=None, text='', xspacing=14, shift=21): |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
92 GlyphCollection.__init__(self, pos, ascii_wrapper, back_wrapper, xspacing=xspacing) |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
93 self.text = '' |
327
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
94 self.shift = shift |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
95 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
96 self.set_text(text) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
97 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
98 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
99 def set_text(self, text): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
100 if text == self.text: |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
101 return |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
102 |
327
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
103 self.set_sprites([ord(c) - self.shift for c in text]) |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
104 self.text = text |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
105 self.changed = True |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
106 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
107 |
327
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
108 def set_color(self, color): |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
109 colors = {'white': (255, 255, 255), 'yellow': (255, 255, 0), 'blue': (192, 192, 255)} |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
110 for glyph in self.glyphes: |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
111 glyph.sprite.color = colors[color] |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
112 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
113 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
114 def timeout_update(self): |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
115 GlyphCollection.update(self) |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
116 if self.timeout % 2: |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
117 for glyph in self.glyphes: |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
118 glyph.y -= 1 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
119 self.timeout -= 1 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
120 if self.timeout == 0: |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
121 self.removed = True |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
122 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
123 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
124 def set_timeout(self, timeout): |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
125 self.timeout = timeout |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
126 self.update = self.timeout_update |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
127 |
13201d90bb22
Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
323
diff
changeset
|
128 |
323
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
129 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
130 class Counter(GlyphCollection): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
131 def __init__(self, pos, anm_wrapper, back_wrapper=None, script=0, xspacing=16, value=0): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
132 GlyphCollection.__init__(self, pos, |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
133 anm_wrapper, back_wrapper=back_wrapper, |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
134 ref_script=script, xspacing=xspacing) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
135 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
136 self.value = value |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
137 self.set_value(value) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
138 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
139 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
140 def set_value(self, value): |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
141 if value < 0: |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
142 value = 0 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
143 if value == self.value: |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
144 return |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
145 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
146 self.set_length(value) |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
147 self.value = value |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
148 self.changed = True |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
149 |
2fcdb8966957
Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents:
322
diff
changeset
|
150 |