Add basic AABB collision detection

This commit is contained in:
2016-06-25 19:12:25 +10:00
parent 7acf36cd59
commit b7063963b8
3 changed files with 55 additions and 8 deletions
+13
View File
@@ -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