Mercurial > touhou
annotate pytouhou/game/game.py @ 196:1e501e3b6645
Add a subclass for each character, and implement player attacks.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 29 Oct 2011 14:21:42 -0700 |
parents | 9f58e2a6e950 |
children | e1bc8c4cbb1a |
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 |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
15 |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
16 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
|
17 |
97 | 18 from pytouhou.vm.eclrunner import ECLMainRunner |
19 | |
130 | 20 from pytouhou.game.player import Player |
98
d141c851c598
Rename pytouhou.game.enemymanager to pytouhou.game.enemy
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
21 from pytouhou.game.enemy import Enemy |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
22 from pytouhou.game.item import Item |
173
35d850502d1f
Move effects where they should be.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
172
diff
changeset
|
23 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
|
24 from pytouhou.game.effect import Particle |
97 | 25 |
26 | |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
27 |
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
28 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
|
29 def __init__(self, resource_loader, players, stage, rank, difficulty, |
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
193
diff
changeset
|
30 bullet_types, item_types, prng=None, nb_bullets_max=None): |
97 | 31 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
|
32 |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
33 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
|
34 self.bullet_types = bullet_types |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
35 self.item_types = item_types |
122
174324a4da51
Add support for launch animations! (Warning: slow :()
Thibaut Girka <thib@sitedethib.com>
parents:
106
diff
changeset
|
36 |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
193
diff
changeset
|
37 self.players = players |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
38 self.enemies = [] |
166
dcf32488a2c9
Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
165
diff
changeset
|
39 self.effects = [] |
106 | 40 self.bullets = [] |
161
7e7368356445
Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents:
159
diff
changeset
|
41 self.cancelled_bullets = [] |
164
5271789c067d
Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
161
diff
changeset
|
42 self.players_bullets = [] |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
43 self.items = [] |
106 | 44 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
45 self.stage = stage |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
46 self.rank = rank |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
47 self.difficulty = difficulty |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
48 self.boss = None |
180
5a1533677a9a
Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents:
176
diff
changeset
|
49 self.spellcard = None |
192
5e84dfd153ab
Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
190
diff
changeset
|
50 self.bonus_list = [0,0,1,0,1,0,0,1,1,1,0,0,0,1,1,0,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
|
51 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
|
52 self.frame = 0 |
83
fc0294c745b6
Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
53 |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
54 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
|
55 '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
|
56 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
|
57 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
|
58 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
|
59 |
188
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
184
diff
changeset
|
60 # 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
|
61 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
|
62 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
|
63 |
83
fc0294c745b6
Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
64 |
172
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
65 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
|
66 player = self.players[0] #TODO |
165
c8c60291c56f
Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
164
diff
changeset
|
67 if _type > 6: |
c8c60291c56f
Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
164
diff
changeset
|
68 return |
153
37df8c618c2e
Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
152
diff
changeset
|
69 item_type = self.item_types[_type] |
172
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
70 item = Item((x, y), item_type, self, end_pos=end_pos) |
153
37df8c618c2e
Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
152
diff
changeset
|
71 self.items.append(item) |
37df8c618c2e
Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
152
diff
changeset
|
72 |
37df8c618c2e
Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
152
diff
changeset
|
73 |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
74 def change_bullets_into_star_items(self): |
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
75 player = self.players[0] #TODO |
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
76 item_type = self.item_types[6] |
153
37df8c618c2e
Add falling items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
152
diff
changeset
|
77 self.items.extend(Item((bullet.x, bullet.y), item_type, self, player=player) for bullet in self.bullets) |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
78 self.bullets = [] |
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
79 |
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
80 |
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
|
81 def new_death(self, pos, index): |
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
|
82 anim = {0: 3, 1: 4, 2: 5}[index % 256] # The TB is wanted, if index isn’t in these values the original game crashs. |
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
|
83 self.effects.append(Effect(pos, anim, self.etama4)) |
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
|
84 |
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
|
85 |
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
|
86 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
|
87 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
|
88 |
35d850502d1f
Move effects where they should be.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
172
diff
changeset
|
89 |
171
2f3665a77f11
Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
166
diff
changeset
|
90 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
|
91 enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm_wrapper, self) |
97 | 92 self.enemies.append(enemy) |
93 return enemy | |
94 | |
95 | |
96 def run_iter(self, keystate): | |
97 # 1. VMs. | |
98 self.ecl_runner.run_iter() | |
99 | |
100 # 2. Filter out destroyed enemies | |
123 | 101 self.enemies = [enemy for enemy in self.enemies if not enemy._removed] |
166
dcf32488a2c9
Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
165
diff
changeset
|
102 self.effects = [enemy for enemy in self.effects if not enemy._removed] |
152
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
103 self.bullets = [bullet for bullet in self.bullets if not bullet._removed] |
161
7e7368356445
Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents:
159
diff
changeset
|
104 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if not bullet._removed] |
152
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
105 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
|
106 |
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
|
107 |
97 | 108 # 3. 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
|
109 # 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
|
110 # 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
|
111 |
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
|
112 # Pri 6 is background |
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
|
113 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
|
114 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
|
115 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
|
116 self.update_bullets() # Pri 11 |
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
|
117 # Pri 12 is HUD |
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
|
118 |
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
|
119 # 4. Cleaning |
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
|
120 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
|
121 |
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
|
122 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
|
123 |
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
|
124 |
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
|
125 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
|
126 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
|
127 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
|
128 |
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
|
129 # Check for collisions |
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
|
130 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
|
131 ex, ey = enemy.x, enemy.y |
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
|
132 ehalf_size_x, ehalf_size_y = enemy.hitbox_half_size |
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
|
133 ex1, ex2 = ex - ehalf_size_x, ex + ehalf_size_x |
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
|
134 ey1, ey2 = ey - ehalf_size_y, ey + ehalf_size_y |
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
|
135 |
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
|
136 for bullet in self.players_bullets: |
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
|
137 half_size = bullet.hitbox_half_size |
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
|
138 bx, by = bullet.x, bullet.y |
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
|
139 bx1, bx2 = bx - half_size, bx + half_size |
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
|
140 by1, by2 = by - half_size, by + half_size |
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
|
141 |
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
|
142 if not (bx2 < ex1 or bx1 > ex2 |
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
|
143 or by2 < ey1 or by1 > ey2): |
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
|
144 bullet.collide() |
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
|
145 enemy.on_attack(bullet) |
196
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
193
diff
changeset
|
146 #TODO: place that at the right place. |
1e501e3b6645
Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
193
diff
changeset
|
147 #player.state.score += 90 # found experimentally |
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
|
148 |
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
|
149 |
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
|
150 def update_players(self, keystate): |
130 | 151 for player in self.players: |
142
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
152 player.update(keystate) #TODO: differentiate keystates (multiplayer mode) |
130 | 153 if player.state.x < 8.: |
154 player.state.x = 8. | |
155 if player.state.x > 384.-8: #TODO | |
156 player.state.x = 384.-8 | |
157 if player.state.y < 16.: | |
158 player.state.y = 16. | |
159 if player.state.y > 448.-16: #TODO | |
160 player.state.y = 448.-16 | |
161 | |
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
|
162 for bullet in self.players_bullets: |
97 | 163 bullet.update() |
164 | |
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
|
165 # Check for collisions |
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
|
166 for player in self.players: |
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
|
167 if not player.state.touchable: |
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
|
168 continue |
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
|
169 |
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
|
170 px, py = player.x, player.y |
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
|
171 phalf_size = player.hitbox_half_size |
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
|
172 px1, px2 = px - phalf_size, px + phalf_size |
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
|
173 py1, py2 = py - phalf_size, py + phalf_size |
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
|
174 |
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
|
175 ghalf_size = player.graze_hitbox_half_size |
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
|
176 gx1, gx2 = px - ghalf_size, px + ghalf_size |
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
|
177 gy1, gy2 = py - ghalf_size, py + ghalf_size |
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
|
178 |
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
|
179 #TODO: Should that be done here or in update_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
|
180 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
|
181 half_size_x, half_size_y = enemy.hitbox_half_size |
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
|
182 bx, by = enemy.x, enemy.y |
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
|
183 bx1, bx2 = bx - half_size_x, bx + half_size_x |
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 by1, by2 = by - half_size_y, by + half_size_y |
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 |
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
|
186 #TODO: box-box or point-in-box? |
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
|
187 if enemy.touchable and not (bx2 < px1 or bx1 > px2 |
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
|
188 or by2 < py1 or by1 > py2): |
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
|
189 enemy.on_collide() |
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
|
190 if player.state.invulnerable_time == 0: |
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
|
191 player.collide() |
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
|
192 |
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
|
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
|
194 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
|
195 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
|
196 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
|
197 |
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
|
198 |
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
|
199 def update_bullets(self): |
161
7e7368356445
Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents:
159
diff
changeset
|
200 for bullet in self.cancelled_bullets: |
7e7368356445
Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents:
159
diff
changeset
|
201 bullet.update() |
7e7368356445
Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents:
159
diff
changeset
|
202 |
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
|
203 for bullet in self.bullets: |
164
5271789c067d
Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
161
diff
changeset
|
204 bullet.update() |
5271789c067d
Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
161
diff
changeset
|
205 |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
206 for item in self.items: |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
207 item.update() |
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
208 |
142
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
209 for player in self.players: |
172
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
210 if not player.state.touchable: |
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
211 continue |
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
212 |
142
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
213 px, py = player.x, player.y |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
214 phalf_size = player.hitbox_half_size |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
215 px1, px2 = px - phalf_size, px + phalf_size |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
216 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
|
217 |
176
80a4c7ed43b3
Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
173
diff
changeset
|
218 ghalf_size = player.graze_hitbox_half_size |
80a4c7ed43b3
Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
173
diff
changeset
|
219 gx1, gx2 = px - ghalf_size, px + ghalf_size |
80a4c7ed43b3
Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
173
diff
changeset
|
220 gy1, gy2 = py - ghalf_size, py + ghalf_size |
80a4c7ed43b3
Add grazing check.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
173
diff
changeset
|
221 |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
222 for bullet in self.bullets: |
142
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
223 half_size = bullet.hitbox_half_size |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
224 bx, by = bullet.x, bullet.y |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
225 bx1, bx2 = bx - half_size, bx + half_size |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
226 by1, by2 = by - half_size, by + half_size |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
227 |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
228 if not (bx2 < px1 or bx1 > px2 |
c7f0fd9d2145
Simple collision detection
Thibaut Girka <thib@sitedethib.com>
parents:
134
diff
changeset
|
229 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
|
230 bullet.collide() |
172
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
231 if player.state.invulnerable_time == 0: |
ea2ad94c33a0
Implement player death.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
171
diff
changeset
|
232 player.collide() |
152
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
233 |
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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 player.state.score += 500 # found experimentally |
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
|
239 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
|
240 #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
|
241 # 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
|
242 |
152
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
243 for item in self.items: |
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
244 half_size = item.hitbox_half_size |
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
245 bx, by = item.x, item.y |
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
246 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
|
247 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
|
248 |
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
249 if not (bx2 < px1 or bx1 > px2 |
86807b8a63bd
Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
151
diff
changeset
|
250 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
|
251 player.collect(item) |
150
4f46717390aa
Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents:
143
diff
changeset
|
252 |
97 | 253 |
254 def cleanup(self): | |
255 # Filter out non-visible enemies | |
256 for enemy in tuple(self.enemies): | |
257 if enemy.is_visible(384, 448): #TODO | |
258 enemy._was_visible = True | |
259 elif enemy._was_visible: | |
260 # Filter out-of-screen enemy | |
261 enemy._removed = True | |
262 self.enemies.remove(enemy) | |
263 | |
264 # Filter out-of-scren bullets | |
265 # TODO: was_visible thing | |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
266 self.bullets = [bullet for bullet in self.bullets if bullet.is_visible(384, 448)] |
161
7e7368356445
Add bullet cancel anim support
Thibaut Girka <thib@sitedethib.com>
parents:
159
diff
changeset
|
267 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if bullet.is_visible(384, 448)] |
164
5271789c067d
Implement player bullets rendering and updating.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
161
diff
changeset
|
268 self.players_bullets = [bullet for bullet in self.players_bullets if bullet.is_visible(384, 448)] |
97 | 269 |
165
c8c60291c56f
Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
164
diff
changeset
|
270 # Filter out-of-scren items |
c8c60291c56f
Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
164
diff
changeset
|
271 self.items = [item for item in self.items if item.y < 448] |
c8c60291c56f
Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
164
diff
changeset
|
272 |
97 | 273 # Disable boss mode if it is dead/it has timeout |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
274 if self.boss and self.boss._removed: |
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
150
diff
changeset
|
275 self.boss = None |
97 | 276 |