RhenaudTheLukark / CreateYourFrisk

Rhenaud The Lukark's Unitale fork
GNU General Public License v3.0
133 stars 56 forks source link

update the player hitbox based on the sprite #46

Closed TheEternalShine closed 5 years ago

TheEternalShine commented 5 years ago

Previously if you tried to change the sprite of the player then the hitbox will not update. So I changed it so it will update based on the sprite every frame (I tested it, and it doesn't impact performance).

RhenaudTheLukark commented 5 years ago

Hello, and thanks for trying to improve CYF! I noticed your issue and jumped right to your pull request.

There's a reason why it's done like this: we want the Player's hitbox to always be 8x8px: CYF's Pixel Perfect Collision system is pretty finicky and only handles a Player hitbox of size 8x8px.

Basically, this system check for each pixel of the Player and sees if any of this pixel collides with any Pixel-Perfect bullet close to it, for EACH bullet, for EACH frame: that means there are 64 checks per bullet per frame by just using a 8x8px hitbox.

So because of that, we plan to not update the Player's hitbox size and keep it at 8x8px: in your current version, if you try to use a Pixel-Perfect bullet, you'll see it'll only be active on a 8x8px hitbox no matter the size of the Player's non Pixel-Perfect hitbox.