annotate pytouhou/games/eosd.py @ 504:69c73023f7a0

Make ANM garbage collectable.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 23 Oct 2013 18:24:17 +0200
parents c622eaf64428
children 1bc014f9d572
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
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
24 from pytouhou.game.text import Text, Counter, Gauge, NativeText
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
25 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
26
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
27 from pytouhou.vm.eclrunner import ECLMainRunner
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
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
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
30 class EoSDCommon(object):
503
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
31 def __init__(self, resource_loader, player_characters, continues, stage,
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
32 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
33 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
34
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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60
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 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
62 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
63
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 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
65 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
66 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
67 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
68 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
69 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
70 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
71
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 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
73 ('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
74 ('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
75 ('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
76 ('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
77 ('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
78 ('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
79
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
80 default_power = [0, 64, 128, 128, 128, 128, 0][stage]
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
81
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
82 eosd_characters = resource_loader.get_eosd_characters()
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
83 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
84 self.player_anms = {}
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
85 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
86 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
87 character = player_character // 2
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
88 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
89 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
90 'face0%db.anm' % character,
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
91 'face0%dc.anm' % character))
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
92 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
93 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
94
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
95 self.players[i] = EoSDPlayer(i, self.player_anms[character][0],
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
96 eosd_characters[player_character],
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
97 character, default_power, continues)
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
98
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
99 self.interface = EoSDInterface(resource_loader, self.players[0]) #XXX
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
100
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
101
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
102
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 class EoSDGame(Game):
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
104 def __init__(self, resource_loader, stage, rank, difficulty,
503
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
105 common, prng=None, hints=None, friendly_fire=True,
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
106 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
107
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
108 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
109 try:
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_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
111 'stg%denm2.anm' % stage))
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
112 except KeyError:
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
113 self.enm_anm = resource_loader.get_anm('stg%denm.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
114 ecl = resource_loader.get_ecl('ecldata%d.ecl' % 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
115 self.ecl_runners = [ECLMainRunner(main, ecl.subs, self) for main in ecl.mains]
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
116
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
117 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
118
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
119 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
120 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
121 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
122
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
123 self.msg_anm = [[], []]
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
124 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
125 for anm in anms:
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
126 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
127 self.msg_anm[i].append((anm, sprite))
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
128
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
129 for player in common.players:
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
130 player._game = self
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131
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
132 # 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
133 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
134
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
135 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
136 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
137
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
138 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
139 self.native_texts = [common.interface.stage_name, common.interface.song_name]
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
140
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
141 Game.__init__(self, common.players, stage, rank, difficulty,
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
142 common.bullet_types, common.laser_types,
503
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
143 common.item_types, nb_bullets_max, common.width,
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
144 common.height, prng, common.interface, hints,
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 494
diff changeset
145 friendly_fire)
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
146
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
147
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
148
322
4e8192aadcaa Give a better interface for text handling.
Thibaut Girka <thib@sitedethib.com>
parents: 321
diff changeset
149 class EoSDInterface(object):
487
711c75115675 Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 471
diff changeset
150 def __init__(self, resource_loader, player_state):
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
151 self.game = None
487
711c75115675 Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 471
diff changeset
152 self.player_state = player_state
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
153 front = resource_loader.get_single_anm('front.anm')
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
154 self.ascii_anm = resource_loader.get_single_anm('ascii.anm')
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
155
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
156 self.width = 640
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
157 self.height = 480
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
158 self.game_pos = (32, 16)
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
159
303
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
160 self.highscore = 1000000 #TODO: read score.dat
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
161 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
162 [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
163 [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
164 [Effect((32 + 32 * i, 464), 8, front) for i in range(12)] +
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
165 [Effect((0, 0), i, front) for i in reversed(range(6))] +
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
166 [Effect((0, 0), i, front) for i in range(9, 16)])
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
167 for item in self.items:
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
168 item.sprite.allow_dest_offset = True #XXX
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
169
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
170 self.level_start = []
387
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
171
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
172 self.labels = {
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
173 'highscore': Text((500, 58), self.ascii_anm, front, text='0'),
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
174 'score': Text((500, 82), self.ascii_anm, front, text='0'),
323
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
175 'player': Counter((500, 122), front, front, script=16, value=0),
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
176 'bombs': Counter((500, 146), front, front, script=17, value=0),
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
177 'power': Text((500, 186), self.ascii_anm, front, text='0'),
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
178 'graze': Text((500, 206), self.ascii_anm, front, text='0'),
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
179 'points': Text((500, 226), self.ascii_anm, front, text='0'),
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
180 'framerate': Text((512, 464), self.ascii_anm, front),
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
181 'debug?': Text((0, 464), self.ascii_anm, front),
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
182
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
183 # Only when there is a boss.
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
184 'boss_lives': Text((80, 16), self.ascii_anm),
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 428
diff changeset
185 'timeout': Text((384, 16), self.ascii_anm),
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
186 }
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
187 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
188
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
189 self.boss_items = [
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
190 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
191 Gauge((100, 24), front), # Gauge
347
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
192 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
193 ]
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
194 for item in self.boss_items:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
195 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
196
346
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
197
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
198 def start_stage(self, game, stage):
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
199 self.game = game
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
200 if stage < 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
201 text = 'STAGE %d' % stage
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
202 elif stage == 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
203 text = 'FINAL STAGE'
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
204 elif stage == 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
205 text = 'EXTRA STAGE'
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
206
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
207 self.stage_name = NativeText((192, 200), unicode(game.std.name), shadow=True, align='center')
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
208 self.stage_name.set_timeout(240, effect='fadeout', duration=60, start=120)
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
209
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
210 self.set_song_name(game.std.bgms[0][0])
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
211
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
212 self.level_start = [Text((16+384/2, 200), self.ascii_anm, text=text, align='center')] #TODO: find the exact location.
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
213 self.level_start[0].set_timeout(240, effect='fadeout', duration=60, start=120)
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
214 self.level_start[0].set_color('yellow')
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
215
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
216
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
217 def set_song_name(self, name):
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
218 #TODO: use the correct animation.
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
219 self.song_name = NativeText((384, 432), u'♪ ' + name, shadow=True, align='right')
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
220 self.song_name.set_timeout(240, effect='fadeout', duration=60, start=120)
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
221
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
222
346
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
223 def set_boss_life(self):
356
a5595de3fe7e Fix crasher
Thibaut Girka <thib@sitedethib.com>
parents: 351
diff changeset
224 if not self.game.boss:
a5595de3fe7e Fix crasher
Thibaut Girka <thib@sitedethib.com>
parents: 351
diff changeset
225 return
349
96e30d6268dd Quick and dirty fixes
Thibaut Girka <thib@sitedethib.com>
parents: 348
diff changeset
226 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
227 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
228
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
229
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
230 def set_spell_life(self):
348
685b782a4da4 Fix issue when disabling low life trigger
Thibaut Girka <thib@sitedethib.com>
parents: 347
diff changeset
231 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
232
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
233
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
234 def update(self):
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
235 for elem in self.items:
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
236 elem.update()
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
237
387
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
238 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
239 elem.update()
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
240 if elem.removed: #XXX
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
241 self.level_start = []
e1f5dcd4b83e Display something at the start of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 384
diff changeset
242
487
711c75115675 Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 471
diff changeset
243 player_state = self.player_state
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
244
303
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
245 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
246 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
247 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
248 self.labels['power'].set_text('%d' % player_state.power)
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
249 self.labels['graze'].set_text('%d' % player_state.graze)
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 289
diff changeset
250 self.labels['points'].set_text('%d' % player_state.points)
323
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
251 self.labels['player'].set_value(player_state.lives)
2fcdb8966957 Display lives and bombs.
Thibaut Girka <thib@sitedethib.com>
parents: 322
diff changeset
252 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
253
350
b3049fb5c448 Fix remaining lives display issue
Thibaut Girka <thib@sitedethib.com>
parents: 349
diff changeset
254 if self.game.boss:
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
255 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
256
862011266f2c Add a gauge and use it for the enemy life bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 345
diff changeset
257 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
258 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
259
347
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
260 spell_gauge = self.boss_items[2]
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
261 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
262 if boss.life < spell_gauge.value:
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
263 spell_gauge.set_value(boss.life)
b150ed7188a2 Show the size of the spellcard life.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 346
diff changeset
264
345
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
265 for item in self.boss_items:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
266 item.update()
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
267
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
268 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
269 self.labels['boss_lives'].changed = True
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
270
351
a628b48a745f Fix timeout display issue (> 99 should be displayed as 99)
Thibaut Girka <thib@sitedethib.com>
parents: 350
diff changeset
271 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
272 timeout_label = self.labels['timeout']
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
273 if timeout >= 20:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
274 timeout_label.set_color('blue')
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
275 elif timeout >= 10:
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
276 timeout_label.set_color('darkblue')
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
277 else:
379
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
278 if timeout >= 5:
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
279 timeout_label.set_color('purple')
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
280 else:
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
281 timeout_label.set_color('red')
e0e284fcb288 Make a sound when an enemy is hit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 356
diff changeset
282 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
283 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
284 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
285 timeout_label.changed = True
2c4589370cc6 Display a boss remaining lives and timeout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 341
diff changeset
286
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
287
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
288
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
289 class EoSDPlayer(Player):
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
290 def __init__(self, number, anm, shts, character, power, continues):
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
291 self.sht = shts[0]
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
292 self.focused_sht = shts[1]
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
293
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
294 Player.__init__(self, number, anm, character, power, continues)
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
295
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
296 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
297 Orb(anm, 129, self)]
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
298
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
299 self.orbs[0].offset_x = -24
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
300 self.orbs[1].offset_x = 24
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
301
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
302 self.orb_dx_interpolator = None
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
303 self.orb_dy_interpolator = None
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
304
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
305
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
306 def start_focusing(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
307 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
308 (8,), self._game.frame + 8,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
309 lambda x: x ** 2)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
310 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
311 (-32,), self._game.frame + 8)
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
312 self.focused = True
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
313
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
314
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
315 def stop_focusing(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
316 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
317 (24,), self._game.frame + 8,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
318 lambda x: x ** 2)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
319 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
320 (0,), self._game.frame + 8)
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
321 self.focused = False
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
322
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
323
384
690b5faaa0e6 Make rendering of multiple-sprites elements work like single-sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 379
diff changeset
324 @property
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
325 def objects(self):
494
6be9c99a3a24 Merge PlayerState into Player, fix player respawn position.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 492
diff changeset
326 return [self] + (self.orbs if self.power >= 8 else [])
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
327
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
328
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
329 def update(self, keystate):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
330 Player.update(self, keystate)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
331
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
332 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
333 if self.orb_dx_interpolator:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
334 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
335 dx, = self.orb_dx_interpolator.values
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
336 self.orbs[0].offset_x = -dx
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
337 self.orbs[1].offset_x = dx
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
338 if self.orb_dy_interpolator:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
339 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
340 dy, = self.orb_dy_interpolator.values
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
341 self.orbs[0].offset_y = dy
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
342 self.orbs[1].offset_y = dy
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
343
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
344 for orb in self.orbs:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
345 orb.update()