Mercurial > touhou
comparison pytouhou/game/game.py @ 225:2d35565b5608
Move game size in the game's definition, and don't keep changing the window's size.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 19 Dec 2011 21:35:40 +0100 |
parents | 0595315d3880 |
children | 31460b2ec530 |
comparison
equal
deleted
inserted
replaced
224:9bb26dbb8438 | 225:2d35565b5608 |
---|---|
24 | 24 |
25 | 25 |
26 | 26 |
27 class Game(object): | 27 class Game(object): |
28 def __init__(self, resource_loader, players, stage, rank, difficulty, | 28 def __init__(self, resource_loader, players, stage, rank, difficulty, |
29 bullet_types, item_types, prng=None, nb_bullets_max=None): | 29 bullet_types, item_types, |
30 nb_bullets_max=None, width=384, height=448, prng=None): | |
30 self.resource_loader = resource_loader | 31 self.resource_loader = resource_loader |
32 | |
33 self.width, self.height = width, height | |
31 | 34 |
32 self.nb_bullets_max = nb_bullets_max | 35 self.nb_bullets_max = nb_bullets_max |
33 self.bullet_types = bullet_types | 36 self.bullet_types = bullet_types |
34 self.item_types = item_types | 37 self.item_types = item_types |
35 | 38 |
172 def update_players(self, keystate): | 175 def update_players(self, keystate): |
173 for player in self.players: | 176 for player in self.players: |
174 player.update(keystate) #TODO: differentiate keystates (multiplayer mode) | 177 player.update(keystate) #TODO: differentiate keystates (multiplayer mode) |
175 if player.state.x < 8.: | 178 if player.state.x < 8.: |
176 player.state.x = 8. | 179 player.state.x = 8. |
177 if player.state.x > 384.-8: #TODO | 180 if player.state.x > self.width - 8: |
178 player.state.x = 384.-8 | 181 player.state.x = self.width - 8 |
179 if player.state.y < 16.: | 182 if player.state.y < 16.: |
180 player.state.y = 16. | 183 player.state.y = 16. |
181 if player.state.y > 448.-16: #TODO | 184 if player.state.y > self.height - 16: |
182 player.state.y = 448.-16 | 185 player.state.y = self.height -16 |
183 | 186 |
184 for bullet in self.players_bullets: | 187 for bullet in self.players_bullets: |
185 bullet.update() | 188 bullet.update() |
186 | 189 |
187 | 190 |
251 | 254 |
252 | 255 |
253 def cleanup(self): | 256 def cleanup(self): |
254 # Filter out non-visible enemies | 257 # Filter out non-visible enemies |
255 for enemy in tuple(self.enemies): | 258 for enemy in tuple(self.enemies): |
256 if enemy.is_visible(384, 448): #TODO | 259 if enemy.is_visible(self.width, self.height): |
257 enemy._was_visible = True | 260 enemy._was_visible = True |
258 elif enemy._was_visible: | 261 elif enemy._was_visible: |
259 # Filter out-of-screen enemy | 262 # Filter out-of-screen enemy |
260 enemy._removed = True | 263 enemy._removed = True |
261 self.enemies.remove(enemy) | 264 self.enemies.remove(enemy) |
262 | 265 |
263 # Filter out-of-scren bullets | 266 # Filter out-of-scren bullets |
264 # TODO: was_visible thing | 267 # TODO: was_visible thing |
265 self.bullets = [bullet for bullet in self.bullets if bullet.is_visible(384, 448)] | 268 self.bullets = [bullet for bullet in self.bullets |
266 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if bullet.is_visible(384, 448)] | 269 if bullet.is_visible(self.width, self.height)] |
267 self.players_bullets = [bullet for bullet in self.players_bullets if bullet.is_visible(384, 448)] | 270 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets |
271 if bullet.is_visible(self.width, self.height)] | |
272 self.players_bullets = [bullet for bullet in self.players_bullets | |
273 if bullet.is_visible(self.width, self.height)] | |
268 | 274 |
269 # Filter out-of-scren items | 275 # Filter out-of-scren items |
270 items = [] | 276 items = [] |
271 for item in self.items: | 277 for item in self.items: |
272 if item.y < 448: | 278 if item.y < 448: |