Add a bounding box to dynentity_t
This commit is contained in:
parent
080de0da3c
commit
3f8ac4f890
10
game/main.c
10
game/main.c
@ -40,6 +40,8 @@
|
||||
#define PWIDTH 48
|
||||
#define PHEIGHT 64
|
||||
#define PANIMLEN 8
|
||||
#define PBBWIDTH 16
|
||||
#define PBBHEIGHT 24
|
||||
#define PFBWIDTH 20
|
||||
#define PFBHEIGHT 16
|
||||
#define PFBOFFX -10
|
||||
@ -108,7 +110,7 @@ typedef struct {
|
||||
double speed;
|
||||
dvec_t pos, dir;
|
||||
ivec_t animstep, svarstep, ext;
|
||||
dbox_t fbox;
|
||||
dbox_t bbox, fbox;
|
||||
SDL_Texture *tex;
|
||||
} dynentity_t;
|
||||
|
||||
@ -466,6 +468,10 @@ void game_init(int argc, char *argv[], void *mem, SDL_Renderer *renderer)
|
||||
state->p.animlen = PANIMLEN;
|
||||
state->p.animstep.x = PWIDTH;
|
||||
state->p.svarstep.y = PHEIGHT;
|
||||
state->p.bbox.off.x = -PBBWIDTH / 2;
|
||||
state->p.bbox.off.y = -PBBHEIGHT / 2;
|
||||
state->p.bbox.ext.x = PBBWIDTH;
|
||||
state->p.bbox.ext.y = PBBHEIGHT;
|
||||
state->p.fbox.off.x = PFBOFFX;
|
||||
state->p.fbox.off.y = PFBOFFY;
|
||||
state->p.fbox.ext.x = PFBWIDTH;
|
||||
@ -570,7 +576,7 @@ static inline bool tile_passable(const map_t map, int x, int y)
|
||||
|
||||
static inline double dynentity_bottom(dynentity_t *e)
|
||||
{
|
||||
return e->pos.y + (double)e->ext.y / 2.0;
|
||||
return e->pos.y + e->bbox.off.y + e->bbox.ext.y;
|
||||
}
|
||||
|
||||
static inline double objentity_bottom(objentity_t *e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user