Add basic AABB collision detection
This commit is contained in:
@@ -31,11 +31,24 @@ typedef struct Entity
|
||||
v2 size;
|
||||
enum Direction direction;
|
||||
Texture *tex;
|
||||
b32 collides;
|
||||
|
||||
// TODO(doyle): String based access
|
||||
SpriteAnim anim[16];
|
||||
i32 freeAnimIndex;
|
||||
i32 currAnimIndex;
|
||||
|
||||
} Entity;
|
||||
|
||||
INTERNAL inline v4 getEntityScreenRect(Entity entity)
|
||||
{
|
||||
v2 entityUpperLeftBound = v2_add(entity.pos, V2(0.0f, entity.size.y));
|
||||
v2 entityLowerRightBound = v2_add(entity.pos, V2(entity.size.x, 0.0f));
|
||||
|
||||
v4 result = V4(entityUpperLeftBound.x, entityUpperLeftBound.y,
|
||||
entityLowerRightBound.x, entityLowerRightBound.y);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user