Mercurial > touhou
annotate pytouhou/games/eosd.py @ 302:34ea45d95489
Fix ECL instruction 119.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 10 Mar 2012 20:31:49 +0100 |
parents | da53bc29b94a |
children | 647bde10353d |
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 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
24 from pytouhou.game.text import Text |
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 from math import pi |
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 |
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 |
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
|
29 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
|
30 |
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
|
31 |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 class EoSDGame(Game): |
274
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
33 def __init__(self, resource_loader, player_states, stage, rank, difficulty, |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
34 bullet_types=None, laser_types=None, item_types=None, |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
35 nb_bullets_max=640, width=384, height=448, prng=None): |
235
e59bd7979ddc
Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
233
diff
changeset
|
36 |
274
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
37 if not bullet_types: |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
38 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',)) |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
39 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',)) |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
40 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4), |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
41 BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=6), |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
42 BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=4), |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
43 BulletType(etama3, 3, 12, 17, 18, 19, hitbox_size=6), |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
44 BulletType(etama3, 4, 12, 17, 18, 19, hitbox_size=5), |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
45 BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=4), |
289
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
46 BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=16, |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
47 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0)), |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
48 BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=11, |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
49 launch_anim_offsets=(1,)*28), |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
50 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=9, |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
51 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0)), |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
52 BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=32, |
e7f40bff72fc
Fix launch_anim_offsets.
Thibaut Girka <thib@sitedethib.com>
parents:
286
diff
changeset
|
53 launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8))] |
274
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
54 |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
55 if not laser_types: |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
56 laser_types = [LaserType(etama3, 9), |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
57 LaserType(etama3, 10)] |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
58 |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
59 if not item_types: |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
60 item_types = [ItemType(etama3, 0, 7), #Power |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
61 ItemType(etama3, 1, 8), #Point |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
62 ItemType(etama3, 2, 9), #Big power |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
63 ItemType(etama3, 3, 10), #Bomb |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
64 ItemType(etama3, 4, 11), #Full power |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
65 ItemType(etama3, 5, 12), #1up |
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
66 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
|
67 |
286
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
68 player_face = player_states[0].character // 2 |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
69 enemy_face = [('face03a.anm', 'face03b.anm'), |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
70 ('face05a.anm',), |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
71 ('face06a.anm', 'face06b.anm'), |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
72 ('face08a.anm', 'face08b.anm'), |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
73 ('face09a.anm', 'face09b.anm'), |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
74 ('face09b.anm', 'face10a.anm', 'face10b.anm'), |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
75 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')] |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
76 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
|
77 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
|
78 'face0%db.anm' % player_face, |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
79 'face0%dc.anm' % player_face) |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
80 + enemy_face[stage - 1], |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
81 (0, 2, 4, 8, 10, 11, 12)) |
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
82 |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
235
diff
changeset
|
83 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
|
84 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
|
85 |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
86 interface = EoSDInterface(player_states, resource_loader) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
87 |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 Game.__init__(self, resource_loader, players, stage, rank, difficulty, |
274
f037bca24f2d
Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
89 bullet_types, laser_types, item_types, nb_bullets_max, |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
90 width, height, prng, interface) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
91 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
92 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
93 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
94 class EoSDInterface(Game): |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
95 def __init__(self, states, resource_loader): |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
96 self.states = states |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
97 front = resource_loader.get_anm_wrapper(('front.anm',)) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
98 ascii_wrapper = resource_loader.get_anm_wrapper(('ascii.anm',)) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
99 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
100 self.width = 640 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
101 self.height = 480 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
102 self.game_pos = (32, 16) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
103 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
104 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
|
105 [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
|
106 [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
|
107 [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
|
108 [Effect((0, 0), 5, front)] + |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
109 [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
|
110 for item in self.items: |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
111 item._sprite.allow_dest_offset = True #XXX |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
112 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
113 self.labels = { |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
114 'highscore': Text((500, 58), '0', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
115 'score': Text((500, 82), '0', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
116 'player': Text((500, 122), 'star star', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
117 'bombs': Text((500, 146), 'star star', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
118 'power': Text((500, 186), '0', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
119 'graze': Text((500, 206), '0', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
120 'points': Text((500, 226), '0', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
121 'framerate': Text((512, 464), '', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
122 'debug?': Text((0, 464), '', front, ascii_wrapper), |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
123 } |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
124 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
125 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
126 def update(self): |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
127 for elem in self.items: |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
128 elem.update() |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
129 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
130 player_state = self.states[0] |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
131 |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
132 self.labels['score'].set_text('%09d' % player_state.score) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
133 self.labels['power'].set_text('%d' % player_state.power) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
134 self.labels['graze'].set_text('%d' % player_state.graze) |
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
135 self.labels['points'].set_text('%d' % player_state.points) |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 |
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
138 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
139 class EoSDPlayer(Player): |
235
e59bd7979ddc
Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
233
diff
changeset
|
140 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
|
141 self.sht = character[0] |
e59bd7979ddc
Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
233
diff
changeset
|
142 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
|
143 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
|
144 self.anm_wrapper = anm_wrapper |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
145 |
235
e59bd7979ddc
Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
233
diff
changeset
|
146 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
|
147 |
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
148 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
|
149 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
|
150 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
151 self.orbs[0].offset_x = -24 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
152 self.orbs[1].offset_x = 24 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
153 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
154 self.orb_dx_interpolator = None |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
155 self.orb_dy_interpolator = None |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
156 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
157 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
158 def start_focusing(self): |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
159 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
|
160 (8,), self._game.frame + 8, |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
161 lambda x: x ** 2) |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
162 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
|
163 (-32,), self._game.frame + 8) |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
164 self.state.focused = True |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
165 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
166 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
167 def stop_focusing(self): |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
168 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
|
169 (24,), self._game.frame + 8, |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
170 lambda x: x ** 2) |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
171 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
|
172 (0,), self._game.frame + 8) |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
173 self.state.focused = False |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
174 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
175 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
176 def objects(self): |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
177 return self.orbs if self.state.power >= 8 else [] |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
178 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
179 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
180 def update(self, keystate): |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
181 Player.update(self, keystate) |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
182 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
183 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
|
184 if self.orb_dx_interpolator: |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
185 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
|
186 dx, = self.orb_dx_interpolator.values |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
187 self.orbs[0].offset_x = -dx |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
188 self.orbs[1].offset_x = dx |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
189 if self.orb_dy_interpolator: |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
190 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
|
191 dy, = self.orb_dy_interpolator.values |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
192 self.orbs[0].offset_y = dy |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
193 self.orbs[1].offset_y = dy |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
194 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
195 for orb in self.orbs: |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
196 orb.update() |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
197 |