Mercurial > touhou
changeset 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 | eef492100f4c |
children | 84b151962708 |
files | pytouhou/formats/exe.py pytouhou/game/bullet.pyx pytouhou/game/enemy.py pytouhou/game/game.py pytouhou/game/laser.py pytouhou/game/player.py pytouhou/games/eosd.py |
diffstat | 7 files changed, 28 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/formats/exe.py +++ b/pytouhou/formats/exe.py @@ -50,10 +50,10 @@ class SHT(object): #self.unknown1 = None #self.bombs = 0. #self.unknown2 = None - self.hitbox = 4. - self.graze_hitbox = 42. + self.hitbox = 2. + self.graze_hitbox = 21. self.autocollection_speed = 8. - self.item_hitbox = 38. + self.item_hitbox = 19. # No percentage_of_cherry_loss_on_die self.point_of_collection = 128 #TODO: find the real default. self.horizontal_vertical_speed = 0.
--- a/pytouhou/game/bullet.pyx +++ b/pytouhou/game/bullet.pyx @@ -27,7 +27,7 @@ cdef class Bullet(object): cdef public object player_bullet, target cdef public object _game, _bullet_type cdef public object sprite, anmrunner, removed, was_visible, objects - cdef public object attributes, damage, hitbox_half_size, speed_interpolator, grazed + cdef public object attributes, damage, hitbox, speed_interpolator, grazed cdef public object x, y #TODO def __init__(self, pos, bullet_type, sprite_idx_offset, @@ -43,9 +43,9 @@ cdef class Bullet(object): self.objects = [self] if hitbox: - self.hitbox_half_size = (hitbox[0] / 2., hitbox[1] / 2.) + self.hitbox = (hitbox[0], hitbox[1]) else: - self.hitbox_half_size = (bullet_type.hitbox_size / 2., bullet_type.hitbox_size / 2.) + self.hitbox = (bullet_type.hitbox_size, bullet_type.hitbox_size) self.speed_interpolator = None self.frame = 0
--- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -305,7 +305,7 @@ class Enemy(object): for bullet in self._game.players_bullets: if bullet.state != LAUNCHED: continue - half_size = bullet.hitbox_half_size + half_size = bullet.hitbox bx, by = bullet.x, bullet.y bx1, bx2 = bx - half_size[0], bx + half_size[0] by1, by2 = by - half_size[1], by + half_size[1] @@ -322,7 +322,7 @@ class Enemy(object): if not laser: continue - half_size = laser.hitbox_half_size + half_size = laser.hitbox lx, ly = laser.x, laser.y * 2. lx1, lx2 = lx - half_size[0], lx + half_size[0] @@ -339,7 +339,7 @@ class Enemy(object): if self.collidable: for player in self._game.players: px, py = player.x, player.y - phalf_size = player.hitbox_half_size + phalf_size = player.sht.hitbox px1, px2 = px - phalf_size, px + phalf_size py1, py2 = py - phalf_size, py + phalf_size
--- a/pytouhou/game/game.py +++ b/pytouhou/game/game.py @@ -319,11 +319,11 @@ class Game(object): continue px, py = player.x, player.y - phalf_size = player.hitbox_half_size + phalf_size = player.sht.hitbox px1, px2 = px - phalf_size, px + phalf_size py1, py2 = py - phalf_size, py + phalf_size - ghalf_size = player.graze_hitbox_half_size + ghalf_size = player.sht.graze_hitbox gx1, gx2 = px - ghalf_size, px + ghalf_size gy1, gy2 = py - ghalf_size, py + ghalf_size @@ -342,10 +342,10 @@ class Game(object): if bullet.state != LAUNCHED: continue - half_size = bullet.hitbox_half_size + bhalf_width, bhalf_height = bullet.hitbox bx, by = bullet.x, bullet.y - bx1, bx2 = bx - half_size[0], bx + half_size[0] - by1, by2 = by - half_size[1], by + half_size[1] + bx1, bx2 = bx - bhalf_width, bx + bhalf_width + by1, by2 = by - bhalf_height, by + bhalf_height if not (bx2 < px1 or bx1 > px2 or by2 < py1 or by1 > py2): @@ -368,11 +368,11 @@ class Game(object): if py < 128 and player.state.power >= 128: #TODO: check py. self.autocollect(player) - half_size = player.sht.item_hitbox / 2. + ihalf_size = player.sht.item_hitbox for item in self.items: bx, by = item.x, item.y - bx1, bx2 = bx - half_size, bx + half_size - by1, by2 = by - half_size, by + half_size + bx1, bx2 = bx - ihalf_size, bx + ihalf_size + by1, by2 = by - ihalf_size, by + ihalf_size if not (bx2 < px1 or bx1 > px2 or by2 < py1 or by1 > py2):
--- a/pytouhou/game/laser.py +++ b/pytouhou/game/laser.py @@ -205,7 +205,7 @@ class PlayerLaser(object): self.origin = origin self.objects = [self] - self.hitbox_half_size = hitbox[0] / 2., hitbox[1] / 2. + self.hitbox = hitbox[0], hitbox[1] self.frame = 0 self.duration = duration
--- a/pytouhou/game/player.py +++ b/pytouhou/game/player.py @@ -64,9 +64,6 @@ class Player(object): self.sht.horizontal_vertical_focused_speed, self.sht.diagonal_focused_speed) - self.hitbox_half_size = self.sht.hitbox / 2. - self.graze_hitbox_half_size = self.sht.graze_hitbox / 2. - self.fire_time = 0 self.state = state
--- a/pytouhou/games/eosd.py +++ b/pytouhou/games/eosd.py @@ -35,28 +35,28 @@ class EoSDGame(Game): if not bullet_types: etama3 = resource_loader.get_anm_wrapper(('etama3.anm',)) etama4 = resource_loader.get_anm_wrapper(('etama4.anm',)) - bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4, + bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=2, type_id=0), - BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=6, + BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=3, type_id=1), - BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=4, + BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=2, type_id=2), - BulletType(etama3, 3, 12, 17, 18, 19, hitbox_size=6, + BulletType(etama3, 3, 12, 17, 18, 19, hitbox_size=3, type_id=3), - BulletType(etama3, 4, 12, 17, 18, 19, hitbox_size=5, + BulletType(etama3, 4, 12, 17, 18, 19, hitbox_size=2.5, type_id=4), - BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=4, + BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=2, type_id=5), - BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=16, + BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=8, launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), type_id=6), - BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=11, + BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=5.5, launch_anim_offsets=(1,)*28, type_id=7), - BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=9, + BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=4.5, launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), type_id=8), - BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=32, + BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=16, launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8), type_id=9)]