Add margin to the bounding box

This commit is contained in:
2014-06-28 19:58:17 +02:00
committed by Valeriano A.R
parent 4fd5af74bc
commit ef1f660f24
3 changed files with 5 additions and 5 deletions

View File

@@ -64,7 +64,6 @@ void Draw_SetOffset(DrawImg img,int x,int y);
void Draw_GetOffset(DrawImg img,int *x,int *y);
/////////////////////////////
// Draw_DrawImg
//

View File

@@ -149,10 +149,11 @@ Entity Entity_Copy(Entity e){
// Entity_CalcBBox
//
//
#define BBox_ExtraMargin 10
#define max(a,b) ((a)>(b)?(a):(b))
void Entity_CalcBBox(Entity e){
int hHeight=(max(e->height,e->radius)/2)+2;
int hWidth=(max(e->width,e->radius)/2)+2;
float hHeight=(max(e->height,e->radius)/2)+BBox_ExtraMargin;
float hWidth=(max(e->width,e->radius)/2)+BBox_ExtraMargin;
if(e->vel[0]>0){
e->maxX=e->pos[0]+e->vel[0]+hWidth;
e->minX=e->pos[0]-hWidth;

View File

@@ -63,8 +63,8 @@ struct TEntity {
int D;
Entity child;
int maxX,minX;
int maxY,minY;
float maxX,minX;
float maxY,minY;
Entity next;
};