annotate pytouhou/game/game.py @ 336:72ef7e24b373

Fix MSG skipping.
author Thibaut Girka <thib@sitedethib.com>
date Sun, 01 Jul 2012 18:06:11 +0200
parents 2350147cf043
children 7a05edbab88a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
1 # -*- encoding: utf-8 -*-
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
2 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
3 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com>
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
4 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
6 ## it under the terms of the GNU General Public License as published
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
7 ## by the Free Software Foundation; version 3 only.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
8 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
9 ## This program is distributed in the hope that it will be useful,
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
12 ## GNU General Public License for more details.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
13 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
14
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
15 from itertools import chain
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
16
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
17 from pytouhou.utils.random import Random
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
18
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
19 from pytouhou.vm.eclrunner import ECLMainRunner
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
20 from pytouhou.vm.msgrunner import MSGRunner
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
21
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
22 from pytouhou.game.bullet import LAUNCHED, CANCELLED
98
d141c851c598 Rename pytouhou.game.enemymanager to pytouhou.game.enemy
Thibaut Girka <thib@sitedethib.com>
parents: 97
diff changeset
23 from pytouhou.game.enemy import Enemy
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
24 from pytouhou.game.item import Item
173
35d850502d1f Move effects where they should be.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 172
diff changeset
25 from pytouhou.game.effect import Effect
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
26 from pytouhou.game.effect import Particle
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
27 from pytouhou.game.text import Text
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
28
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
29
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
30
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
31 class Game(object):
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 193
diff changeset
32 def __init__(self, resource_loader, players, stage, rank, difficulty,
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
33 bullet_types, laser_types, item_types,
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 299
diff changeset
34 nb_bullets_max=None, width=384, height=448, prng=None, interface=None):
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
35 self.resource_loader = resource_loader
83
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
36
225
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
37 self.width, self.height = width, height
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
38
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
39 self.nb_bullets_max = nb_bullets_max
122
174324a4da51 Add support for launch animations! (Warning: slow :()
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
40 self.bullet_types = bullet_types
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
41 self.laser_types = laser_types
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
42 self.item_types = item_types
122
174324a4da51 Add support for launch animations! (Warning: slow :()
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
43
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 193
diff changeset
44 self.players = players
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
45 self.enemies = []
166
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
46 self.effects = []
106
c7847bfed427 Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 98
diff changeset
47 self.bullets = []
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
48 self.lasers = []
161
7e7368356445 Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents: 159
diff changeset
49 self.cancelled_bullets = []
164
5271789c067d Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 161
diff changeset
50 self.players_bullets = []
294
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
51 self.players_lasers = [None, None]
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
52 self.items = []
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
53 self.labels = []
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 299
diff changeset
54 self.interface = interface
106
c7847bfed427 Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 98
diff changeset
55
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
56 self.stage = stage
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
57 self.rank = rank
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
58 self.difficulty = difficulty
198
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
59 self.difficulty_counter = 0
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
60 self.difficulty_min = 12 if rank == 0 else 10
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
61 self.difficulty_max = 20 if rank == 0 else 32
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
62 self.boss = None
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 176
diff changeset
63 self.spellcard = None
299
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
64 self.time_stop = False
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
65 self.msg_runner = None
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
66 self.msg_wait = False
203
df8b2ab54639 Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents: 202
diff changeset
67 self.bonus_list = [0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0,
df8b2ab54639 Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents: 202
diff changeset
68 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 2]
188
008f90ebfdc0 Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents: 184
diff changeset
69 self.prng = prng or Random()
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
70 self.frame = 0
83
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
71
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
72 self.enm_anm_wrapper = resource_loader.get_anm_wrapper2(('stg%denm.anm' % stage,
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
73 'stg%denm2.anm' % stage))
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
74 self.etama4 = resource_loader.get_anm_wrapper(('etama4.anm',))
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
75 ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage)
157
ca6f8b3f739d Remove half of the new_enemy/pop_enemy mess.
Thibaut Girka <thib@sitedethib.com>
parents: 156
diff changeset
76 self.ecl_runner = ECLMainRunner(ecl, self)
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
77
306
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
78 self.spellcard_effect_anm_wrapper = resource_loader.get_anm_wrapper(('eff0%d.anm' % stage,))
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
79 self.spellcard_effect = None
217
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
80
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
81 #TODO: better place?
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
82 self.ascii_wrapper = resource_loader.get_anm_wrapper(('ascii.anm',))
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
83
188
008f90ebfdc0 Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents: 184
diff changeset
84 # See 102h.exe@0x413220 if you think you're brave enough.
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
85 self.deaths_count = self.prng.rand_uint16() % 3
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
86 self.next_bonus = self.prng.rand_uint16() % 8
188
008f90ebfdc0 Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents: 184
diff changeset
87
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
88 self.last_keystate = 0
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
89
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
90
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
91 def msg_sprites(self):
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
92 return []
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
93
83
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
94
294
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
95 def lasers_sprites(self):
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
96 return [laser for laser in self.players_lasers if laser]
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
97
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
98
198
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
99 def modify_difficulty(self, diff):
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
100 self.difficulty_counter += diff
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
101 while self.difficulty_counter < 0:
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
102 self.difficulty -= 1
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
103 self.difficulty_counter += 100
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
104 while self.difficulty_counter >= 100:
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
105 self.difficulty += 1
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
106 self.difficulty_counter -= 100
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
107 if self.difficulty < self.difficulty_min:
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
108 self.difficulty = self.difficulty_min
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
109 elif self.difficulty > self.difficulty_max:
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
110 self.difficulty = self.difficulty_max
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
111
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
112
321
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
113 def change_music(self, track):
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
114 #TODO: don’t crash if the track has already be played.
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
115 bgm = self.bgms[track]
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
116 if bgm:
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
117 self.music.queue(bgm)
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
118 self.music.next()
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
119
61adb5453e46 Implement music playback.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 320
diff changeset
120
306
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
121 def enable_spellcard_effect(self):
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
122 self.spellcard_effect = Effect((-32., -16.), 0,
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
123 self.spellcard_effect_anm_wrapper) #TODO: find why this offset is necessary.
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
124 self.spellcard_effect.sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate!
217
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
125
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
126
306
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
127 def disable_spellcard_effect(self):
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
128 self.spellcard_effect = None
217
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
129
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
130
172
ea2ad94c33a0 Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
131 def drop_bonus(self, x, y, _type, end_pos=None):
153
37df8c618c2e Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
132 player = self.players[0] #TODO
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 164
diff changeset
133 if _type > 6:
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 164
diff changeset
134 return
303
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
135 if len(self.items) >= self.nb_bullets_max:
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
136 return #TODO: check
153
37df8c618c2e Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
137 item_type = self.item_types[_type]
197
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
138 item = Item((x, y), _type, item_type, self, end_pos=end_pos)
153
37df8c618c2e Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
139 self.items.append(item)
37df8c618c2e Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
140
37df8c618c2e Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
141
208
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
142 def autocollect(self, player):
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
143 for item in self.items:
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
144 if not item.player:
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
145 item.autocollect(player)
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
146
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
147
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
148 def cancel_bullets(self):
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
149 for bullet in self.bullets:
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
150 bullet.cancel()
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
151 for laser in self.lasers:
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
152 laser.cancel()
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
153
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
154
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
155 def change_bullets_into_star_items(self):
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
156 player = self.players[0] #TODO
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
157 item_type = self.item_types[6]
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
158 self.items.extend(Item((bullet.x, bullet.y), 6, item_type, self, player=player)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
159 for bullet in self.bullets)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
160 for laser in self.lasers:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
161 self.items.extend(Item(pos, 6, item_type, self, player=player)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
162 for pos in laser.get_bullets_pos())
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
163 laser.cancel()
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
164 self.bullets = []
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
165
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
166
320
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
167 def change_bullets_into_bonus(self):
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
168 player = self.players[0] #TODO
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
169 score = 0
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
170 bonus = 2000
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
171 for bullet in self.bullets:
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
172 label = self.new_label((bullet.x, bullet.y), str(bonus))
320
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
173 score += bonus
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
174 bonus += 10
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
175 self.bullets = []
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
176 player.state.score += score
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
177 #TODO: display the final bonus score.
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
178
1a4ffdda8735 Cancel the bullets when a boss is killed and transfer them to the score.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 316
diff changeset
179
248
77b83064b57e Use the correct animation for player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 229
diff changeset
180 def new_effect(self, pos, anim, anm_wrapper=None):
77b83064b57e Use the correct animation for player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 229
diff changeset
181 self.effects.append(Effect(pos, anim, anm_wrapper or self.etama4))
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
182
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
183
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
184 def new_particle(self, pos, color, size, amp):
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
185 self.effects.append(Particle(pos, 7 + 4 * color + self.prng.rand_uint16() % 4, self.etama4, size, amp, self))
173
35d850502d1f Move effects where they should be.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 172
diff changeset
186
35d850502d1f Move effects where they should be.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 172
diff changeset
187
171
2f3665a77f11 Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 166
diff changeset
188 def new_enemy(self, pos, life, instr_type, bonus_dropped, die_score):
2f3665a77f11 Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 166
diff changeset
189 enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm_wrapper, self)
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
190 self.enemies.append(enemy)
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
191 return enemy
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
192
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
193
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
194 def new_msg(self, sub):
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
195 self.msg_runner = MSGRunner(self.msg, sub, self)
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
196 self.msg_runner.run_iteration()
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
197
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
198
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
199 def new_label(self, pos, text):
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
200 label = Text(pos, self.ascii_wrapper, text=text, xspacing=8, shift=48)
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
201 label.set_timeout(60)
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
202 self.labels.append(label)
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
203 return label
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
204
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
205
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
206 def run_iter(self, keystate):
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
207 # 1. VMs.
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
208 self.ecl_runner.run_iter()
316
f0be7ea62330 Fix a bug with ECL instruction 96, and fix overall ECL handling.
Thibaut Girka <thib@sitedethib.com>
parents: 306
diff changeset
209
f0be7ea62330 Fix a bug with ECL instruction 96, and fix overall ECL handling.
Thibaut Girka <thib@sitedethib.com>
parents: 306
diff changeset
210 # 2. Modify difficulty
198
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
211 if self.frame % (32*60) == (32*60): #TODO: check if that is really that frame.
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
212 self.modify_difficulty(+100)
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
213
316
f0be7ea62330 Fix a bug with ECL instruction 96, and fix overall ECL handling.
Thibaut Girka <thib@sitedethib.com>
parents: 306
diff changeset
214 # 3. Filter out destroyed enemies
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
215 self.enemies = [enemy for enemy in self.enemies if not enemy.removed]
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
216 self.effects = [effect for effect in self.effects if not effect.removed]
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
217 self.bullets = [bullet for bullet in self.bullets if not bullet.removed]
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
218 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if not bullet.removed]
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
219 self.items = [item for item in self.items if not item.removed]
83
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
220
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
221
316
f0be7ea62330 Fix a bug with ECL instruction 96, and fix overall ECL handling.
Thibaut Girka <thib@sitedethib.com>
parents: 306
diff changeset
222 # 4. Let's play!
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
223 # In the original game, updates are done in prioritized functions called "chains"
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
224 # We have to mimic this functionnality to be replay-compatible with the official game.
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
225
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
226 # Pri 6 is background
306
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
227 self.update_background() #TODO: Pri unknown
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
228 if self.msg_runner:
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
229 self.update_msg(keystate) # Pri ?
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
230 keystate &= ~3 # Remove the ability to attack (keystates 1 and 2).
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
231 self.update_players(keystate) # Pri 7
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
232 self.update_enemies() # Pri 9
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
233 self.update_effects() # Pri 10
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
234 self.update_bullets() # Pri 11
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
235 for laser in self.lasers: #TODO: what priority is it?
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
236 laser.update()
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 299
diff changeset
237 self.interface.update() # Pri 12
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
238 for label in self.labels: #TODO: what priority is it?
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
239 label.update()
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
240
316
f0be7ea62330 Fix a bug with ECL instruction 96, and fix overall ECL handling.
Thibaut Girka <thib@sitedethib.com>
parents: 306
diff changeset
241 # 5. Clean up
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
242 self.cleanup()
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
243
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
244 self.frame += 1
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
245
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
246
306
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
247 def update_background(self):
299
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
248 if self.time_stop:
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
249 return None
306
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
250 if self.spellcard_effect is not None:
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
251 self.spellcard_effect.update()
52d791bb7c32 Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents: 305
diff changeset
252 #TODO: update the actual background here?
217
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
253
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 208
diff changeset
254
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
255 def update_enemies(self):
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
256 for enemy in self.enemies:
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
257 enemy.update()
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
258
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
259
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
260 def update_msg(self, keystate):
336
72ef7e24b373 Fix MSG skipping.
Thibaut Girka <thib@sitedethib.com>
parents: 335
diff changeset
261 if any((keystate & k and not self.last_keystate & k) for k in (1, 256)):
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
262 self.msg_runner.skip()
336
72ef7e24b373 Fix MSG skipping.
Thibaut Girka <thib@sitedethib.com>
parents: 335
diff changeset
263 self.msg_runner.skipping = bool(keystate & 256)
286
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
264 self.last_keystate = keystate
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
265 self.msg_runner.run_iteration()
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
266
4838e9bab0f9 Implement dialogs (MSG files).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 274
diff changeset
267
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
268 def update_players(self, keystate):
299
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
269 if self.time_stop:
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
270 return None
328
56523a16db1d Fix some replay synchronization issues and update the TODO.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 327
diff changeset
271
56523a16db1d Fix some replay synchronization issues and update the TODO.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 327
diff changeset
272 for bullet in self.players_bullets:
56523a16db1d Fix some replay synchronization issues and update the TODO.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 327
diff changeset
273 bullet.update()
56523a16db1d Fix some replay synchronization issues and update the TODO.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 327
diff changeset
274
130
11ab06f4c4c6 Introduce characters!
Thibaut Girka <thib@sitedethib.com>
parents: 123
diff changeset
275 for player in self.players:
142
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
276 player.update(keystate) #TODO: differentiate keystates (multiplayer mode)
130
11ab06f4c4c6 Introduce characters!
Thibaut Girka <thib@sitedethib.com>
parents: 123
diff changeset
277 if player.state.x < 8.:
11ab06f4c4c6 Introduce characters!
Thibaut Girka <thib@sitedethib.com>
parents: 123
diff changeset
278 player.state.x = 8.
225
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
279 if player.state.x > self.width - 8:
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
280 player.state.x = self.width - 8
130
11ab06f4c4c6 Introduce characters!
Thibaut Girka <thib@sitedethib.com>
parents: 123
diff changeset
281 if player.state.y < 16.:
11ab06f4c4c6 Introduce characters!
Thibaut Girka <thib@sitedethib.com>
parents: 123
diff changeset
282 player.state.y = 16.
225
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
283 if player.state.y > self.height - 16:
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
284 player.state.y = self.height -16
130
11ab06f4c4c6 Introduce characters!
Thibaut Girka <thib@sitedethib.com>
parents: 123
diff changeset
285
303
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
286 #XXX: Why 78910? Is it really the right value?
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
287 player.state.effective_score = min(player.state.effective_score + 78910,
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
288 player.state.score)
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
289 #TODO: give extra lives to the player
647bde10353d Add score/effective_score distinction and prepare for highscore handling.
Thibaut Girka <thib@sitedethib.com>
parents: 300
diff changeset
290
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
291
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
292 def update_effects(self):
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
293 for effect in self.effects:
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
294 effect.update()
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
295
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
296
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
297 def update_bullets(self):
299
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
298 if self.time_stop:
e04e402e6380 Implemented Sakuya's time stop.
Elias Boutaleb <kagekyio@gmail.com>
parents: 294
diff changeset
299 return None
161
7e7368356445 Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents: 159
diff changeset
300 for bullet in self.cancelled_bullets:
7e7368356445 Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents: 159
diff changeset
301 bullet.update()
7e7368356445 Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents: 159
diff changeset
302
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
303 for bullet in self.bullets:
164
5271789c067d Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 161
diff changeset
304 bullet.update()
5271789c067d Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 161
diff changeset
305
294
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
306 for laser in self.players_lasers:
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
307 if laser:
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
308 laser.update()
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
309
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
310 for item in self.items:
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
311 item.update()
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
312
142
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
313 for player in self.players:
172
ea2ad94c33a0 Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
314 if not player.state.touchable:
ea2ad94c33a0 Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
315 continue
ea2ad94c33a0 Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
316
142
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
317 px, py = player.x, player.y
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
318 phalf_size = player.hitbox_half_size
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
319 px1, px2 = px - phalf_size, px + phalf_size
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
320 py1, py2 = py - phalf_size, py + phalf_size
152
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
321
176
80a4c7ed43b3 Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 173
diff changeset
322 ghalf_size = player.graze_hitbox_half_size
80a4c7ed43b3 Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 173
diff changeset
323 gx1, gx2 = px - ghalf_size, px + ghalf_size
80a4c7ed43b3 Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 173
diff changeset
324 gy1, gy2 = py - ghalf_size, py + ghalf_size
80a4c7ed43b3 Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 173
diff changeset
325
293
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
326 for laser in self.lasers:
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
327 if laser.check_collision((px, py)):
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
328 if player.state.invulnerable_time == 0:
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
329 player.collide()
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
330 elif laser.check_grazing((px, py)):
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
331 player.state.graze += 1 #TODO
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
332 player.state.score += 500 #TODO
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
333 self.modify_difficulty(+6) #TODO
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
334 self.new_particle((px, py), 0, .8, 192) #TODO
ab618c2bbce8 Implement laser collision.
Thibaut Girka <thib@sitedethib.com>
parents: 290
diff changeset
335
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
336 for bullet in self.bullets:
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
337 if bullet.state != LAUNCHED:
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
338 continue
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
339
142
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
340 half_size = bullet.hitbox_half_size
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
341 bx, by = bullet.x, bullet.y
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: 217
diff changeset
342 bx1, bx2 = bx - half_size[0], bx + half_size[0]
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: 217
diff changeset
343 by1, by2 = by - half_size[1], by + half_size[1]
142
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
344
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
345 if not (bx2 < px1 or bx1 > px2
c7f0fd9d2145 Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
346 or by2 < py1 or by1 > py2):
156
ebfd328e700c Rename a few functions, move a few things around...
Thibaut Girka <thib@sitedethib.com>
parents: 154
diff changeset
347 bullet.collide()
172
ea2ad94c33a0 Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
348 if player.state.invulnerable_time == 0:
ea2ad94c33a0 Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
349 player.collide()
152
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
350
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
351 elif not bullet.grazed and not (bx2 < gx1 or bx1 > gx2
176
80a4c7ed43b3 Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 173
diff changeset
352 or by2 < gy1 or by1 > gy2):
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
353 bullet.grazed = True
184
54eb6b254b7b When touched, drop the items at the right place, and add precisions about particles.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 181
diff changeset
354 player.state.graze += 1
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
355 player.state.score += 500 # found experimentally
198
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
356 self.modify_difficulty(+6)
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
357 self.new_particle((px, py), 0, .8, 192) #TODO: find the real size and range.
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
358 #TODO: display a static particle during one frame at
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
359 # 12 pixels of the player, in the axis of the “collision”.
176
80a4c7ed43b3 Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 173
diff changeset
360
208
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
361 #TODO: is it the right place?
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
362 if py < 128 and player.state.power >= 128: #TODO: check py.
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
363 self.autocollect(player)
d07506a2e16e Implement autocollection of items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 203
diff changeset
364
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 227
diff changeset
365 half_size = player.sht.item_hitbox / 2.
152
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
366 for item in self.items:
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
367 bx, by = item.x, item.y
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
368 bx1, bx2 = bx - half_size, bx + half_size
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
369 by1, by2 = by - half_size, by + half_size
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
370
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
371 if not (bx2 < px1 or bx1 > px2
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
372 or by2 < py1 or by1 > py2):
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: 217
diff changeset
373 item.on_collect(player)
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 143
diff changeset
374
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
375
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
376 def cleanup(self):
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
377 # Filter out non-visible enemies
255
a0d6b1915591 Fix bullet removal condition.
Thibaut Girka <thib@sitedethib.com>
parents: 248
diff changeset
378 for enemy in self.enemies:
225
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
379 if enemy.is_visible(self.width, self.height):
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
380 enemy.was_visible = True
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
381 elif enemy.was_visible:
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
382 # Filter out-of-screen enemy
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
383 enemy.removed = True
255
a0d6b1915591 Fix bullet removal condition.
Thibaut Girka <thib@sitedethib.com>
parents: 248
diff changeset
384
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
385 self.enemies = [enemy for enemy in self.enemies if not enemy.removed]
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
386
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
387 # Update cancelled bullets
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
388 self.cancelled_bullets = [b for b in chain(self.cancelled_bullets,
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
389 self.bullets,
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
390 self.players_bullets)
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
391 if b.state == CANCELLED and not b.removed]
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
392 # Filter out-of-scren bullets
225
2d35565b5608 Move game size in the game's definition, and don't keep changing the window's size.
Thibaut Girka <thib@sitedethib.com>
parents: 220
diff changeset
393 self.bullets = [bullet for bullet in self.bullets
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
394 if not bullet.removed and bullet.state != CANCELLED]
255
a0d6b1915591 Fix bullet removal condition.
Thibaut Girka <thib@sitedethib.com>
parents: 248
diff changeset
395 self.players_bullets = [bullet for bullet in self.players_bullets
335
2350147cf043 Fix bullet cancellation and removal
Thibaut Girka <thib@sitedethib.com>
parents: 328
diff changeset
396 if not bullet.removed and bullet.state != CANCELLED]
294
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
397 for i, laser in enumerate(self.players_lasers):
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
398 if laser and laser.removed:
294
94c636f8f863 Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 293
diff changeset
399 self.players_lasers[i] = None
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
400 self.effects = [effect for effect in self.effects if not effect.removed]
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
401
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
402 # Filter “timed-out” lasers
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
403 self.lasers = [laser for laser in self.lasers if not laser.removed]
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 259
diff changeset
404
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 164
diff changeset
405 # Filter out-of-scren items
198
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
406 items = []
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
407 for item in self.items:
300
da53bc29b94a Add the game interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 299
diff changeset
408 if item.y < self.height:
198
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
409 items.append(item)
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
410 else:
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
411 self.modify_difficulty(-3)
13918723d1bc Modify difficulty when it has to.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
412 self.items = items
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 164
diff changeset
413
327
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
414 self.labels = [label for label in self.labels if not label.removed]
13201d90bb22 Display the text when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 321
diff changeset
415
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
416 # Disable boss mode if it is dead/it has timeout
304
f3099ebf4f61 Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents: 303
diff changeset
417 if self.boss and self.boss._enemy.removed:
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
418 self.boss = None
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
419