Closed codeimpossible closed 10 years ago
For version 1:
public bool IsTouching( Rectangle box )
I spent some time looking into this ticket today. The entity code isn't consistent in how it figures out where to place things on the screen.
So, in order to complete this ticket I need to make these changes:
correctedBoundingBox
property which is Position + Offset
correctedBoundingBox
correctedBoundingBox
should be used to compute collisionsI created a HitBox
struct that stores the height and width of the hitbox and the offset that should be applied to it. The HitBox has some operator overloads that enable it to be added with Vector2
and Rectangle
objects, developers can also explicitly create HitBox
objects by casting from a Vector2
or a Rectangle
:
var hitBox = (HitBox)( new Vector2( 100, 100 ) );
MonoGame.Framework contains a BoundingBox
class but this is centered around Vector3
and since it is a struct, cannot be inherited ( so I couldn't extend it with the operator overloads ).
I'm not sold on this yet. I'm thinking of abandoning this and possibly using the BoundingBox
class from MonoGame.Framework.
I don't like how the HitBox keeps track of the offset. I feel like these are two different concepts and should be kept separate (the entity/game object should know how to use either one). Another problem is that the HitBox would need to know about it's position in the game world so that it can encapsulate the logic for applying the offset.
That feels like the HitBox would know way too much about it's use case(s) and would be prone to churn/bugs.
As a game developer I would like to be able to specify a vector offset that should be applied to the current Actors
BoundingBox
. This would allow me to constrict the hit box for an actor and keep the animation positioned correctly.