Mercurial > touhou
comparison pytouhou/game/game.py @ 293:ab618c2bbce8
Implement laser collision.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 20 Feb 2012 18:58:07 +0100 |
parents | 18e4ed141dd8 |
children | 94c636f8f863 |
comparison
equal
deleted
inserted
replaced
292:3a81b607f974 | 293:ab618c2bbce8 |
---|---|
250 | 250 |
251 ghalf_size = player.graze_hitbox_half_size | 251 ghalf_size = player.graze_hitbox_half_size |
252 gx1, gx2 = px - ghalf_size, px + ghalf_size | 252 gx1, gx2 = px - ghalf_size, px + ghalf_size |
253 gy1, gy2 = py - ghalf_size, py + ghalf_size | 253 gy1, gy2 = py - ghalf_size, py + ghalf_size |
254 | 254 |
255 for laser in self.lasers: | |
256 if laser.check_collision((px, py)): | |
257 if player.state.invulnerable_time == 0: | |
258 player.collide() | |
259 elif laser.check_grazing((px, py)): | |
260 player.state.graze += 1 #TODO | |
261 player.state.score += 500 #TODO | |
262 self.modify_difficulty(+6) #TODO | |
263 self.new_particle((px, py), 0, .8, 192) #TODO | |
264 | |
255 for bullet in self.bullets: | 265 for bullet in self.bullets: |
256 half_size = bullet.hitbox_half_size | 266 half_size = bullet.hitbox_half_size |
257 bx, by = bullet.x, bullet.y | 267 bx, by = bullet.x, bullet.y |
258 bx1, bx2 = bx - half_size[0], bx + half_size[0] | 268 bx1, bx2 = bx - half_size[0], bx + half_size[0] |
259 by1, by2 = by - half_size[1], by + half_size[1] | 269 by1, by2 = by - half_size[1], by + half_size[1] |