Mercurial > touhou
annotate pytouhou/games/sample/game.py @ 665:965ecdbf0316
Make rank user-defined in eclrenderer.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 11 Aug 2019 20:14:20 +0200 |
parents | d1f0bb0b7a17 |
children |
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 |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
17 from pytouhou.game.game import Game as GameBase |
196
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 |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
21 from pytouhou.game.player import Player as PlayerBase |
199
8ec34c56fed0
Implement orbs.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
197
diff
changeset
|
22 from pytouhou.game.orb import Orb |
428
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
23 from pytouhou.game.background import Background |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 |
599
d471b07ce4fd
Add a sample Python ECL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
598
diff
changeset
|
25 from pytouhou.vm import PythonMainRunner |
600
2a748aa29c3f
Add a sample character.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
599
diff
changeset
|
26 from . import enemies, shots |
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 |
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 |
615
d1f0bb0b7a17
Don’t inherit explicitely from object, we are not on Python 2.7 anymore. :)
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
614
diff
changeset
|
29 class Common: |
614
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
30 default_power = [0, 64, 128, 128, 128, 128, 0] |
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
31 |
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
32 def __init__(self, resource_loader, player_characters, continues, *, |
503
c622eaf64428
Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
494
diff
changeset
|
33 width=384, height=448): |
c622eaf64428
Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
494
diff
changeset
|
34 self.width, self.height = width, height |
c622eaf64428
Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
494
diff
changeset
|
35 |
434
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
36 self.etama = resource_loader.get_multi_anm(('etama3.anm', 'etama4.anm')) |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
37 self.bullet_types = [BulletType(self.etama[0], 0, 11, 14, 15, 16, hitbox_size=2, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
38 type_id=0), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
39 BulletType(self.etama[0], 1, 12, 17, 18, 19, hitbox_size=3, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
40 type_id=1), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
41 BulletType(self.etama[0], 2, 12, 17, 18, 19, hitbox_size=2, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
42 type_id=2), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
43 BulletType(self.etama[0], 3, 12, 17, 18, 19, hitbox_size=3, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
44 type_id=3), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
45 BulletType(self.etama[0], 4, 12, 17, 18, 19, hitbox_size=2.5, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
46 type_id=4), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
47 BulletType(self.etama[0], 5, 12, 17, 18, 19, hitbox_size=2, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
48 type_id=5), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
49 BulletType(self.etama[0], 6, 13, 20, 20, 20, hitbox_size=8, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
50 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
51 type_id=6), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
52 BulletType(self.etama[0], 7, 13, 20, 20, 20, hitbox_size=5.5, |
470
98995d8ac744
Reset ANMRunner.sprite_index_offset after the first frame, fixes bullettype 7; also forbid glitch bullet types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
53 launch_anim_offsets=(1, 1, 1, 1), |
434
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
54 type_id=7), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
55 BulletType(self.etama[0], 8, 13, 20, 20, 20, hitbox_size=4.5, |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
56 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
57 type_id=8), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
58 BulletType(self.etama[1], 0, 1, 2, 2, 2, hitbox_size=16, |
470
98995d8ac744
Reset ANMRunner.sprite_index_offset after the first frame, fixes bullettype 7; also forbid glitch bullet types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
59 launch_anim_offsets=(0, 1, 2, 3), |
434
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
60 type_id=9)] |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
61 |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
62 self.laser_types = [LaserType(self.etama[0], 9), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
63 LaserType(self.etama[0], 10)] |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
64 |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
65 self.item_types = [ItemType(self.etama[0], 0, 7), #Power |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
66 ItemType(self.etama[0], 1, 8), #Point |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
67 ItemType(self.etama[0], 2, 9), #Big power |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
68 ItemType(self.etama[0], 3, 10), #Bomb |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
69 ItemType(self.etama[0], 4, 11), #Full power |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
70 ItemType(self.etama[0], 5, 12), #1up |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
71 ItemType(self.etama[0], 6, 13)] #Star |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
72 |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
73 self.enemy_face = [('face03a.anm', 'face03b.anm'), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
74 ('face05a.anm',), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
75 ('face06a.anm', 'face06b.anm'), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
76 ('face08a.anm', 'face08b.anm'), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
77 ('face09a.anm', 'face09b.anm'), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
78 ('face09b.anm', 'face10a.anm', 'face10b.anm'), |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
79 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')] |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
80 |
600
2a748aa29c3f
Add a sample character.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
599
diff
changeset
|
81 sample_characters = shots.characters |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
82 self.first_character = player_characters[0] // 2 |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
83 self.player_anms = {} |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
84 self.players = [None] * len(player_characters) |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
85 for i, player_character in enumerate(player_characters): |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
86 character = player_character // 2 |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
87 if character not in self.player_anms: |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
88 face = resource_loader.get_multi_anm(('face0%da.anm' % character, |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
89 'face0%db.anm' % character, |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
90 'face0%dc.anm' % character)) |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
91 anm = resource_loader.get_single_anm('player0%d.anm' % character) |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
92 self.player_anms[character] = (anm, face) |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
93 |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
94 self.players[i] = Player(i, self.player_anms[character][0], |
600
2a748aa29c3f
Add a sample character.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
599
diff
changeset
|
95 sample_characters[player_character], |
614
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
96 character, continues) |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
97 |
434
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
98 |
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
99 |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
100 class Game(GameBase): |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
101 def __init__(self, resource_loader, stage, rank, difficulty, |
508
1bc014f9d572
Make GameRunner entirely independent of Window or GameRenderer, so we can run a game without display.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
503
diff
changeset
|
102 common, prng, hints=None, friendly_fire=True, |
503
c622eaf64428
Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
494
diff
changeset
|
103 nb_bullets_max=640): |
235
e59bd7979ddc
Do a little cleanup, and fix PCB SHT usage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
233
diff
changeset
|
104 |
434
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
105 self.etama = common.etama #XXX |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
106 try: |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
107 self.enm_anm = resource_loader.get_multi_anm(('stg%denm.anm' % stage, |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
108 'stg%denm2.anm' % stage)) |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
109 except KeyError: |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
110 self.enm_anm = resource_loader.get_anm('stg%denm.anm' % stage) |
599
d471b07ce4fd
Add a sample Python ECL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
598
diff
changeset
|
111 |
d471b07ce4fd
Add a sample Python ECL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
598
diff
changeset
|
112 self.ecl_runners = [PythonMainRunner(getattr(enemies, 'stage%d' % stage), self)] |
428
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
113 |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
114 self.spellcard_effect_anm = resource_loader.get_single_anm('eff0%d.anm' % stage) |
428
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
115 |
286
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
116 self.msg = resource_loader.get_msg('msg%d.dat' % stage) |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
117 msg_anm = [common.player_anms[common.first_character][1], #TODO: does it break bomb face of non-first player? |
434
18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
430
diff
changeset
|
118 resource_loader.get_multi_anm(common.enemy_face[stage - 1])] |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
119 |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
120 self.msg_anm = [[], []] |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
121 for i, anms in enumerate(msg_anm): |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
122 for anm in anms: |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
123 for sprite in anm.sprites.values(): |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
124 self.msg_anm[i].append((anm, sprite)) |
286
4838e9bab0f9
Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
274
diff
changeset
|
125 |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
126 for player in common.players: |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
127 player._game = self |
614
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
128 if player.power < 0: |
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
129 player.power = common.default_power[stage - 1] |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 |
428
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
131 # Load stage data |
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
132 self.std = resource_loader.get_stage('stage%d.std' % stage) |
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
133 |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
134 background_anm = resource_loader.get_single_anm('stg%dbg.anm' % stage) |
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
428
diff
changeset
|
135 self.background = Background(self.std, background_anm) |
428
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
409
diff
changeset
|
136 |
456
cae1ae9de430
Add native text support, MSG instructions 3 and 8, and text at the beginning of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
434
diff
changeset
|
137 common.interface.start_stage(self, stage) |
cae1ae9de430
Add native text support, MSG instructions 3 and 8, and text at the beginning of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
434
diff
changeset
|
138 |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
139 GameBase.__init__(self, common.players, stage, rank, difficulty, |
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
140 common.bullet_types, common.laser_types, |
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
141 common.item_types, nb_bullets_max, common.width, |
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
142 common.height, prng, common.interface, hints, |
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
143 friendly_fire) |
300
da53bc29b94a
Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
289
diff
changeset
|
144 |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
145 |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
146 |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
147 class Player(PlayerBase): |
614
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
148 def __init__(self, number, anm, shts, character, continues): |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
149 self.sht = shts[0] |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
150 self.focused_sht = shts[1] |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
151 |
614
2cf518129725
Delay power assignment to players until the game is started.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
600
diff
changeset
|
152 PlayerBase.__init__(self, number, anm, character, continues, power=-1) |
229
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
153 |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
154 self.orbs = [Orb(anm, 128, self), |
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
155 Orb(anm, 129, self)] |
206
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 self.orbs[0].offset_x = -24 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
158 self.orbs[1].offset_x = 24 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
159 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
160 def start_focusing(self): |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
161 self.focused = True |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
162 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
163 def stop_focusing(self): |
494
6be9c99a3a24
Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
492
diff
changeset
|
164 self.focused = False |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
165 |
384
690b5faaa0e6
Make rendering of multiple-sprites elements work like single-sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
379
diff
changeset
|
166 @property |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
167 def objects(self): |
598
a7286a0facf9
Add a sample game.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
597
diff
changeset
|
168 return [self] + self.orbs |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
169 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
170 def update(self, keystate): |
597
244c99c568c8
Don’t hardcode the available games and interfaces, and relocation them.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
548
diff
changeset
|
171 PlayerBase.update(self, keystate) |
206
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
172 |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
173 for orb in self.orbs: |
eca53abdfeab
Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
200
diff
changeset
|
174 orb.update() |