annotate pytouhou/games/eosd.py @ 409:608468be7a93

Move ascii_wrapper to the interface, as it is game-dependent.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 12 Jun 2013 16:03:26 +0200
parents 6c0cb3eee33e
children f41a26971a19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 ## Copyright (C) 2011 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 ## it under the terms of the GNU General Public License as published
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 ## by the Free Software Foundation; version 3 only.
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 ## This program is distributed in the hope that it will be useful,
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 ## GNU General Public License for more details.
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
15 from pytouhou.utils.interpolator import Interpolator
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 from pytouhou.game.game import Game
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 from pytouhou.game.bullettype import BulletType
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
19 from pytouhou.game.lasertype import LaserType
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 from pytouhou.game.itemtype import ItemType
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 from pytouhou.game.player import Player
199
8ec34c56fed0 Implement orbs.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
22 from pytouhou.game.orb import Orb
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
23 from pytouhou.game.effect import Effect
346
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
24 from pytouhou.game.text import Text, Counter, Gauge
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26
220
0595315d3880 Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 216
diff changeset
27 SQ2 = 2. ** 0.5 / 2.
0595315d3880 Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 216
diff changeset
28
0595315d3880 Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 216
diff changeset
29
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 class EoSDGame(Game):
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
31 def __init__(self, resource_loader, player_states, stage, rank, difficulty,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
32 bullet_types=None, laser_types=None, item_types=None,
404
6c0cb3eee33e Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 390
diff changeset
33 nb_bullets_max=640, width=384, height=448, prng=None,
6c0cb3eee33e Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 390
diff changeset
34 continues=0, hints=None):
235
e59bd7979ddc Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 233
diff changeset
35
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
36 if not bullet_types:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
37 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',))
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
38 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',))
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
39 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=2,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
40 type_id=0),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
41 BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=3,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
42 type_id=1),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
43 BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=2,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
44 type_id=2),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
45 BulletType(etama3, 3, 12, 17, 18, 19, hitbox_size=3,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
46 type_id=3),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
47 BulletType(etama3, 4, 12, 17, 18, 19, hitbox_size=2.5,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
48 type_id=4),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
49 BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=2,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
50 type_id=5),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
51 BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=8,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
52 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0),
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
53 type_id=6),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
54 BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=5.5,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
55 launch_anim_offsets=(1,)*28,
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
56 type_id=7),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
57 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=4.5,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
58 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0),
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
59 type_id=8),
390
b11953cf1d3b Use only half-size hitboxes for player.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 387
diff changeset
60 BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=16,
312
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
61 launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8),
8d1768fa4cbb Fix Remilia's “Red Magic”.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
62 type_id=9)]
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
63
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
64 if not laser_types:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
65 laser_types = [LaserType(etama3, 9),
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
66 LaserType(etama3, 10)]
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
67
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
68 if not item_types:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
69 item_types = [ItemType(etama3, 0, 7), #Power
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
70 ItemType(etama3, 1, 8), #Point
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
71 ItemType(etama3, 2, 9), #Big power
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
72 ItemType(etama3, 3, 10), #Bomb
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
73 ItemType(etama3, 4, 11), #Full power
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
74 ItemType(etama3, 5, 12), #1up
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
75 ItemType(etama3, 6, 13)] #Star
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
77 player_face = player_states[0].character // 2
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
78 enemy_face = [('face03a.anm', 'face03b.anm'),
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
79 ('face05a.anm',),
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
80 ('face06a.anm', 'face06b.anm'),
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
81 ('face08a.anm', 'face08b.anm'),
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
82 ('face09a.anm', 'face09b.anm'),
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
83 ('face09b.anm', 'face10a.anm', 'face10b.anm'),
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
84 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')]
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
85 self.msg = resource_loader.get_msg('msg%d.dat' % stage)
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
86 self.msg_anm_wrapper = resource_loader.get_anm_wrapper2(('face0%da.anm' % player_face,
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
87 'face0%db.anm' % player_face,
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
88 'face0%dc.anm' % player_face)
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
89 + enemy_face[stage - 1],
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
90 (0, 2, 4, 8, 10, 11, 12))
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
91
262
8fa660da5f0c Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents: 235
diff changeset
92 characters = resource_loader.get_eosd_characters()
235
e59bd7979ddc Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 233
diff changeset
93 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states]
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94
387
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
95 self.stage = stage #XXX
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
96 interface = EoSDInterface(self, resource_loader)
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
97
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 Game.__init__(self, resource_loader, players, stage, rank, difficulty,
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 262
diff changeset
99 bullet_types, laser_types, item_types, nb_bullets_max,
404
6c0cb3eee33e Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 390
diff changeset
100 width, height, prng, interface, continues, hints)
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
101
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
102
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
103
322
4e8192aadcaa Give a better interface for text handling.
Thibaut Girka <thib@sitedethib.com>
parents: 321
diff changeset
104 class EoSDInterface(object):
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
105 def __init__(self, game, resource_loader):
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
106 self.game = game
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
107 front = resource_loader.get_anm_wrapper(('front.anm',))
409
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
108 self.ascii_wrapper = resource_loader.get_anm_wrapper(('ascii.anm',))
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
109
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
110 self.width = 640
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
111 self.height = 480
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
112 self.game_pos = (32, 16)
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
113
303
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
114 self.highscore = 1000000 #TODO: read score.dat
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
115 self.items = ([Effect((0, 32 * i), 6, front) for i in range(15)] +
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
116 [Effect((416 + 32 * i, 32 * j), 6, front) for i in range(7) for j in range(15)] +
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
117 [Effect((32 + 32 * i, 0), 7, front) for i in range(12)] +
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
118 [Effect((32 + 32 * i, 464), 8, front) for i in range(12)] +
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
119 [Effect((0, 0), 5, front)] +
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
120 [Effect((0, 0), i, front) for i in range(5) + range(9, 16)])
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
121 for item in self.items:
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
122 item.sprite.allow_dest_offset = True #XXX
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
123
409
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
124 self.level_start = [Text((176, 200), self.ascii_wrapper, text='STAGE %d' % game.stage)] #TODO: find the exact location.
404
6c0cb3eee33e Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 390
diff changeset
125 self.level_start[0].set_timeout(240, effect='fadeout', duration=60, start=120)
387
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
126 self.level_start[0].set_color('yellow')
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
127 #TODO: use the system text for the stage name, and the song name.
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
128
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
129 self.labels = {
409
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
130 'highscore': Text((500, 58), self.ascii_wrapper, front, text='0'),
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
131 'score': Text((500, 82), self.ascii_wrapper, front, text='0'),
323
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
132 'player': Counter((500, 122), front, front, script=16, value=0),
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
133 'bombs': Counter((500, 146), front, front, script=17, value=0),
409
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
134 'power': Text((500, 186), self.ascii_wrapper, front, text='0'),
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
135 'graze': Text((500, 206), self.ascii_wrapper, front, text='0'),
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
136 'points': Text((500, 226), self.ascii_wrapper, front, text='0'),
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
137 'framerate': Text((512, 464), self.ascii_wrapper, front),
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
138 'debug?': Text((0, 464), self.ascii_wrapper, front),
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
139
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
140 # Only when there is a boss.
409
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
141 'boss_lives': Text((80, 16), self.ascii_wrapper),
608468be7a93 Move ascii_wrapper to the interface, as it is game-dependent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 404
diff changeset
142 'timeout': Text((384, 16), self.ascii_wrapper),
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
143 }
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
144 self.labels['boss_lives'].set_color('yellow')
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
145
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
146 self.boss_items = [
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
147 Effect((0, 0), 19, front), # Enemy
346
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
148 Gauge((100, 24), front), # Gauge
347
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
149 Gauge((100, 24), front), # Spellcard gauge
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
150 ]
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
151 for item in self.boss_items:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
152 item.sprite.allow_dest_offset = True #XXX
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
153
346
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
154
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
155 def set_boss_life(self):
356
a5595de3fe7e Fix crasher
Thibaut Girka <thib@sitedethib.com>
parents: 351
diff changeset
156 if not self.game.boss:
a5595de3fe7e Fix crasher
Thibaut Girka <thib@sitedethib.com>
parents: 351
diff changeset
157 return
349
96e30d6268dd Quick and dirty fixes
Thibaut Girka <thib@sitedethib.com>
parents: 348
diff changeset
158 self.boss_items[1].maximum = self.game.boss._enemy.life or 1
96e30d6268dd Quick and dirty fixes
Thibaut Girka <thib@sitedethib.com>
parents: 348
diff changeset
159 self.boss_items[2].maximum = self.game.boss._enemy.life or 1
347
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
160
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
161
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
162 def set_spell_life(self):
348
685b782a4da4 Fix issue when disabling low life trigger
Thibaut Girka <thib@sitedethib.com>
parents: 347
diff changeset
163 self.boss_items[2].set_value(self.game.boss._enemy.low_life_trigger if self.game.boss else 0)
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
164
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
165
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
166 def update(self):
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
167 for elem in self.items:
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
168 elem.update()
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
169
387
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
170 for elem in self.level_start:
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
171 elem.update()
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
172 if elem.removed: #XXX
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
173 self.level_start = []
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
174
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
175 player_state = self.game.players[0].state
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
176
303
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
177 self.highscore = max(self.highscore, player_state.effective_score)
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
178 self.labels['highscore'].set_text('%09d' % self.highscore)
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
179 self.labels['score'].set_text('%09d' % player_state.effective_score)
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
180 self.labels['power'].set_text('%d' % player_state.power)
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
181 self.labels['graze'].set_text('%d' % player_state.graze)
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
182 self.labels['points'].set_text('%d' % player_state.points)
323
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
183 self.labels['player'].set_value(player_state.lives)
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
184 self.labels['bombs'].set_value(player_state.bombs)
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
185
350
b3049fb5c448 Fix remaining lives display issue
Thibaut Girka <thib@sitedethib.com>
parents: 349
diff changeset
186 if self.game.boss:
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
187 boss = self.game.boss._enemy
346
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
188
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
189 life_gauge = self.boss_items[1]
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
190 life_gauge.set_value(boss.life)
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
191
347
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
192 spell_gauge = self.boss_items[2]
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
193 spell_gauge.sprite.color = (255, 192, 192)
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
194 if boss.life < spell_gauge.value:
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
195 spell_gauge.set_value(boss.life)
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
196
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
197 for item in self.boss_items:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
198 item.update()
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
199
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
200 self.labels['boss_lives'].set_text('%d' % boss.remaining_lives)
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
201 self.labels['boss_lives'].changed = True
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
202
351
a628b48a745f Fix timeout display issue (> 99 should be displayed as 99)
Thibaut Girka <thib@sitedethib.com>
parents: 350
diff changeset
203 timeout = min((boss.timeout - boss.frame) // 60, 99)
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
204 timeout_label = self.labels['timeout']
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
205 if timeout >= 20:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
206 timeout_label.set_color('blue')
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
207 elif timeout >= 10:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
208 timeout_label.set_color('darkblue')
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
209 else:
379
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
210 if timeout >= 5:
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
211 timeout_label.set_color('purple')
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
212 else:
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
213 timeout_label.set_color('red')
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
214 if (boss.timeout - boss.frame) % 60 == 0 and boss.timeout != 0:
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
215 self.game.sfx_player.play('timeout.wav', volume=1.)
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
216 timeout_label.set_text('%02d' % (timeout if timeout >= 0 else 0))
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
217 timeout_label.changed = True
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
218
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
219
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
220
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
221 class EoSDPlayer(Player):
235
e59bd7979ddc Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 233
diff changeset
222 def __init__(self, state, game, resource_loader, character):
e59bd7979ddc Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 233
diff changeset
223 self.sht = character[0]
e59bd7979ddc Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 233
diff changeset
224 self.focused_sht = character[1]
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
225 anm_wrapper = resource_loader.get_anm_wrapper(('player0%d.anm' % (state.character // 2),))
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
226 self.anm_wrapper = anm_wrapper
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
227
235
e59bd7979ddc Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 233
diff changeset
228 Player.__init__(self, state, game, anm_wrapper)
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
230 self.orbs = [Orb(self.anm_wrapper, 128, self.state, None),
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
231 Orb(self.anm_wrapper, 129, self.state, None)]
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
232
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
233 self.orbs[0].offset_x = -24
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
234 self.orbs[1].offset_x = 24
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
235
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
236 self.orb_dx_interpolator = None
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
237 self.orb_dy_interpolator = None
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
238
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
239
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
240 def start_focusing(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
241 self.orb_dx_interpolator = Interpolator((24,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
242 (8,), self._game.frame + 8,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
243 lambda x: x ** 2)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
244 self.orb_dy_interpolator = Interpolator((0,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
245 (-32,), self._game.frame + 8)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
246 self.state.focused = True
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
247
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
248
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
249 def stop_focusing(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
250 self.orb_dx_interpolator = Interpolator((8,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
251 (24,), self._game.frame + 8,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
252 lambda x: x ** 2)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
253 self.orb_dy_interpolator = Interpolator((-32,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
254 (0,), self._game.frame + 8)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
255 self.state.focused = False
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
256
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
257
384
690b5faaa0e6 Make rendering of multiple-sprites elements work like single-sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 379
diff changeset
258 @property
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
259 def objects(self):
384
690b5faaa0e6 Make rendering of multiple-sprites elements work like single-sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 379
diff changeset
260 return [self] + (self.orbs if self.state.power >= 8 else [])
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
261
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
262
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
263 def update(self, keystate):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
264 Player.update(self, keystate)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
265
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
266 if self.death_time == 0 or self._game.frame - self.death_time > 60:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
267 if self.orb_dx_interpolator:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
268 self.orb_dx_interpolator.update(self._game.frame)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
269 dx, = self.orb_dx_interpolator.values
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
270 self.orbs[0].offset_x = -dx
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
271 self.orbs[1].offset_x = dx
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
272 if self.orb_dy_interpolator:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
273 self.orb_dy_interpolator.update(self._game.frame)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
274 dy, = self.orb_dy_interpolator.values
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
275 self.orbs[0].offset_y = dy
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
276 self.orbs[1].offset_y = dy
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
277
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
278 for orb in self.orbs:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
279 orb.update()
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
280