Mercurial > touhou
comparison pytouhou/game/enemy.py @ 390:b11953cf1d3b
Use only half-size hitboxes for player.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 12 Nov 2012 18:34:24 +0100 |
parents | ac2891afb0bb |
children | c689ff1743bf |
comparison
equal
deleted
inserted
replaced
389:eef492100f4c | 390:b11953cf1d3b |
---|---|
303 | 303 |
304 # Check for enemy-bullet collisions | 304 # Check for enemy-bullet collisions |
305 for bullet in self._game.players_bullets: | 305 for bullet in self._game.players_bullets: |
306 if bullet.state != LAUNCHED: | 306 if bullet.state != LAUNCHED: |
307 continue | 307 continue |
308 half_size = bullet.hitbox_half_size | 308 half_size = bullet.hitbox |
309 bx, by = bullet.x, bullet.y | 309 bx, by = bullet.x, bullet.y |
310 bx1, bx2 = bx - half_size[0], bx + half_size[0] | 310 bx1, bx2 = bx - half_size[0], bx + half_size[0] |
311 by1, by2 = by - half_size[1], by + half_size[1] | 311 by1, by2 = by - half_size[1], by + half_size[1] |
312 | 312 |
313 if not (bx2 < ex1 or bx1 > ex2 | 313 if not (bx2 < ex1 or bx1 > ex2 |
320 # Check for enemy-laser collisions | 320 # Check for enemy-laser collisions |
321 for laser in self._game.players_lasers: | 321 for laser in self._game.players_lasers: |
322 if not laser: | 322 if not laser: |
323 continue | 323 continue |
324 | 324 |
325 half_size = laser.hitbox_half_size | 325 half_size = laser.hitbox |
326 lx, ly = laser.x, laser.y * 2. | 326 lx, ly = laser.x, laser.y * 2. |
327 lx1, lx2 = lx - half_size[0], lx + half_size[0] | 327 lx1, lx2 = lx - half_size[0], lx + half_size[0] |
328 | 328 |
329 if not (lx2 < ex1 or lx1 > ex2 | 329 if not (lx2 < ex1 or lx1 > ex2 |
330 or ly < ey1): | 330 or ly < ey1): |
337 ex1, ex2 = ex - ehalf_size_x * 2. / 3., ex + ehalf_size_x * 2. / 3. | 337 ex1, ex2 = ex - ehalf_size_x * 2. / 3., ex + ehalf_size_x * 2. / 3. |
338 ey1, ey2 = ey - ehalf_size_y * 2. / 3., ey + ehalf_size_y * 2. / 3. | 338 ey1, ey2 = ey - ehalf_size_y * 2. / 3., ey + ehalf_size_y * 2. / 3. |
339 if self.collidable: | 339 if self.collidable: |
340 for player in self._game.players: | 340 for player in self._game.players: |
341 px, py = player.x, player.y | 341 px, py = player.x, player.y |
342 phalf_size = player.hitbox_half_size | 342 phalf_size = player.sht.hitbox |
343 px1, px2 = px - phalf_size, px + phalf_size | 343 px1, px2 = px - phalf_size, px + phalf_size |
344 py1, py2 = py - phalf_size, py + phalf_size | 344 py1, py2 = py - phalf_size, py + phalf_size |
345 | 345 |
346 #TODO: box-box or point-in-box? | 346 #TODO: box-box or point-in-box? |
347 if not (ex2 < px1 or ex1 > px2 or ey2 < py1 or ey1 > py2): | 347 if not (ex2 < px1 or ex1 > px2 or ey2 < py1 or ey1 > py2): |