Mercurial > touhou
annotate pytouhou/interfaces/eosd.py @ 548:1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 21 May 2014 20:56:53 +0200 |
parents | |
children | e15672733c93 |
rev | line source |
---|---|
548
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 ## |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 ## Copyright (C) 2014 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 ## |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 ## |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 ## GNU General Public License for more details. |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ## |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 from pytouhou.game.effect import Effect |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 from pytouhou.game.text import Text, Counter, Gauge, NativeText |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 class EoSDInterface(object): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 def __init__(self, resource_loader, player_state): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 self.game = None |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 self.player_state = player_state |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 front = resource_loader.get_single_anm('front.anm') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 self.ascii_anm = resource_loader.get_single_anm('ascii.anm') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 self.width = 640 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 self.height = 480 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 self.game_pos = (32, 16) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 self.highscore = 1000000 #TODO: read score.dat |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 self.items = ([Effect((0, 32 * i), 6, front) for i in range(15)] + |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 [Effect((416 + 32 * i, 32 * j), 6, front) for i in range(7) for j in range(15)] + |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 [Effect((32 + 32 * i, 0), 7, front) for i in range(12)] + |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 [Effect((32 + 32 * i, 464), 8, front) for i in range(12)] + |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 [Effect((0, 0), i, front) for i in reversed(range(6))] + |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 [Effect((0, 0), i, front) for i in range(9, 16)]) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 for item in self.items: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 item.sprite.allow_dest_offset = True #XXX |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 self.level_start = [] |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 self.labels = { |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 'highscore': Text((500, 58), self.ascii_anm, front, text='0'), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 'score': Text((500, 82), self.ascii_anm, front, text='0'), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 'player': Counter((500, 122), front, front, script=16, value=0), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 'bombs': Counter((500, 146), front, front, script=17, value=0), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 'power': Text((500, 186), self.ascii_anm, front, text='0'), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 'graze': Text((500, 206), self.ascii_anm, front, text='0'), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 'points': Text((500, 226), self.ascii_anm, front, text='0'), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 'framerate': Text((512, 464), self.ascii_anm, front), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 'debug?': Text((0, 464), self.ascii_anm, front), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 # Only when there is a boss. |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 'boss_lives': Text((80, 16), self.ascii_anm), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 'timeout': Text((384, 16), self.ascii_anm), |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 } |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 self.labels['boss_lives'].set_color('yellow') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 self.boss_items = [ |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 Effect((0, 0), 19, front), # Enemy |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 Gauge((100, 24), front), # Gauge |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 Gauge((100, 24), front), # Spellcard gauge |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 ] |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 for item in self.boss_items: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 item.sprite.allow_dest_offset = True #XXX |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 def start_stage(self, game, stage): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 self.game = game |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
70 if stage < 6: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 text = 'STAGE %d' % stage |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 elif stage == 6: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 text = 'FINAL STAGE' |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 elif stage == 7: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 text = 'EXTRA STAGE' |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 self.stage_name = NativeText((192, 200), unicode(game.std.name), shadow=True, align='center') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 self.stage_name.set_timeout(240, effect='fadeout', duration=60, start=120) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 self.set_song_name(game.std.bgms[0][0]) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 self.level_start = [Text((16+384/2, 200), self.ascii_anm, text=text, align='center')] #TODO: find the exact location. |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 self.level_start[0].set_timeout(240, effect='fadeout', duration=60, start=120) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 self.level_start[0].set_color('yellow') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 def set_song_name(self, name): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 #TODO: use the correct animation. |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 self.song_name = NativeText((384, 432), u'♪ ' + name, shadow=True, align='right') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 self.song_name.set_timeout(240, effect='fadeout', duration=60, start=120) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 def set_boss_life(self): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
94 if not self.game.boss: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 return |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 self.boss_items[1].maximum = self.game.boss.life or 1 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
97 self.boss_items[2].maximum = self.game.boss.life or 1 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
100 def set_spell_life(self): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 self.boss_items[2].set_value(self.game.boss.low_life_trigger if self.game.boss else 0) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 def update(self): |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 for elem in self.items: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 elem.update() |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 for elem in self.level_start: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 elem.update() |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 if elem.removed: #XXX |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 self.level_start = [] |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
113 player_state = self.player_state |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 self.highscore = max(self.highscore, player_state.effective_score) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 self.labels['highscore'].set_text('%09d' % self.highscore) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 self.labels['score'].set_text('%09d' % player_state.effective_score) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 self.labels['power'].set_text('%d' % player_state.power) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 self.labels['graze'].set_text('%d' % player_state.graze) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 self.labels['points'].set_text('%d' % player_state.points) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 self.labels['player'].set_value(player_state.lives) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 self.labels['bombs'].set_value(player_state.bombs) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 if self.game.boss: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 boss = self.game.boss |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 life_gauge = self.boss_items[1] |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 life_gauge.set_value(boss.life) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 spell_gauge = self.boss_items[2] |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 spell_gauge.sprite.color = (255, 192, 192) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 if boss.life < spell_gauge.value: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 spell_gauge.set_value(boss.life) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 for item in self.boss_items: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 item.update() |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 self.labels['boss_lives'].set_text('%d' % boss.remaining_lives) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 self.labels['boss_lives'].changed = True |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
141 timeout = min((boss.timeout - boss.frame) // 60, 99) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
142 timeout_label = self.labels['timeout'] |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
143 if timeout >= 20: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
144 timeout_label.set_color('blue') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
145 elif timeout >= 10: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
146 timeout_label.set_color('darkblue') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
147 else: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
148 if timeout >= 5: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
149 timeout_label.set_color('purple') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
150 else: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
151 timeout_label.set_color('red') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
152 if (boss.timeout - boss.frame) % 60 == 0 and boss.timeout != 0: |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
153 self.game.sfx_player.set_volume('timeout.wav', 1.) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
154 self.game.sfx_player.play('timeout.wav') |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
155 timeout_label.set_text('%02d' % (timeout if timeout >= 0 else 0)) |
1e9ea6519f3c
Make EoSDInterface separate from EoSD game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
156 timeout_label.changed = True |