Mercurial > touhou
changeset 176:80a4c7ed43b3
Add grazing check.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 22 Oct 2011 06:21:38 -0700 |
parents | 5dc243bcf312 |
children | 6e8653ff2b23 |
files | pytouhou/game/character.py pytouhou/game/game.py pytouhou/game/games.py pytouhou/game/player.py |
diffstat | 4 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/game/character.py +++ b/pytouhou/game/character.py @@ -1,6 +1,7 @@ class Character(object): - def __init__(self, anm_wrapper, speed, focused_speed, hitbox_size): + def __init__(self, anm_wrapper, speed, focused_speed, hitbox_size, graze_hitbox_size): self.anm_wrapper = anm_wrapper self.speed = speed self.focused_speed = focused_speed self.hitbox_size = hitbox_size + self.graze_hitbox_size = graze_hitbox_size
--- a/pytouhou/game/game.py +++ b/pytouhou/game/game.py @@ -135,6 +135,10 @@ class Game(object): px1, px2 = px - phalf_size, px + phalf_size py1, py2 = py - phalf_size, py + phalf_size + ghalf_size = player.graze_hitbox_half_size + gx1, gx2 = px - ghalf_size, px + ghalf_size + gy1, gy2 = py - ghalf_size, py + ghalf_size + for bullet in self.bullets: half_size = bullet.hitbox_half_size bx, by = bullet.x, bullet.y @@ -147,6 +151,10 @@ class Game(object): if player.state.invulnerable_time == 0: player.collide() + elif not (bx2 < gx1 or bx1 > gx2 + or by2 < gy1 or by1 > gy2): + pass#TODO: graze + for enemy in self.enemies: half_size_x, half_size_y = enemy.hitbox_half_size bx, by = enemy.x, enemy.y
--- a/pytouhou/game/games.py +++ b/pytouhou/game/games.py @@ -42,10 +42,10 @@ class EoSDGame(Game): player00 = resource_loader.get_anm_wrapper(('player00.anm',)) player01 = resource_loader.get_anm_wrapper(('player01.anm',)) - characters = [Character(player00, 4., 2., 2.5), - Character(player00, 4., 2., 2.5), - Character(player01, 5., 2.5, 2.5), - Character(player01, 5., 2.5, 2.5)] + characters = [Character(player00, 4., 2., 2.5, 42.), + Character(player00, 4., 2., 2.5, 42.), + Character(player01, 5., 2.5, 2.5, 42.), + Character(player01, 5., 2.5, 2.5, 42.)] Game.__init__(self, resource_loader, players, stage, rank, difficulty, bullet_types, item_types, characters, nb_bullets_max=640)