Update quadtree for pushed entities. Handle riders.
This commit is contained in:
parent
9f100106eb
commit
d09ceefbb9
|
@ -58,7 +58,7 @@ void initEntities(void)
|
||||||
|
|
||||||
void doEntities(void)
|
void doEntities(void)
|
||||||
{
|
{
|
||||||
Entity *prev, *oldSelf;
|
Entity *prev, *oldSelf, *e;
|
||||||
int camMidX, camMidY, flicker, i;
|
int camMidX, camMidY, flicker, i;
|
||||||
SDL_Rect *r;
|
SDL_Rect *r;
|
||||||
|
|
||||||
|
@ -218,6 +218,26 @@ void doEntities(void)
|
||||||
|
|
||||||
prev = self;
|
prev = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0 ; i < MAX_RIDERS ; i++)
|
||||||
|
{
|
||||||
|
e = riders[i];
|
||||||
|
|
||||||
|
if (e != NULL)
|
||||||
|
{
|
||||||
|
if (e->dy > 0)
|
||||||
|
{
|
||||||
|
pushEntity(e, e->riding->dx, 0);
|
||||||
|
|
||||||
|
if (!pushEntity(e, 0, e->riding->dy))
|
||||||
|
{
|
||||||
|
e->riding->y -= e->riding->dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->y = e->riding->y - e->h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawEntities(int plane)
|
void drawEntities(int plane)
|
||||||
|
@ -234,7 +254,7 @@ void drawEntities(int plane)
|
||||||
|
|
||||||
for (i = 0, self = candidates[i] ; self != NULL ; self = candidates[++i])
|
for (i = 0, self = candidates[i] ; self != NULL ; self = candidates[++i])
|
||||||
{
|
{
|
||||||
draw = self->isVisible && !(self->flags & EF_GONE) && self->plane == plane;
|
draw = self->isVisible && self->plane == plane;
|
||||||
|
|
||||||
if (draw)
|
if (draw)
|
||||||
{
|
{
|
||||||
|
@ -282,14 +302,13 @@ static int getMarkerType(void)
|
||||||
static void checkPlatformContact(void)
|
static void checkPlatformContact(void)
|
||||||
{
|
{
|
||||||
Entity *e;
|
Entity *e;
|
||||||
|
Entity **candidates;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
srcRect.x = self->x;
|
srcRect.x = self->x;
|
||||||
srcRect.y = self->y + 4;
|
srcRect.y = self->y + 4;
|
||||||
srcRect.w = self->w;
|
srcRect.w = self->w;
|
||||||
srcRect.h = self->h;
|
srcRect.h = self->h;
|
||||||
|
|
||||||
Entity **candidates;
|
|
||||||
|
|
||||||
candidates = getAllEntsWithin(srcRect.x, srcRect.y, srcRect.w, srcRect.h, NULL);
|
candidates = getAllEntsWithin(srcRect.x, srcRect.y, srcRect.w, srcRect.h, NULL);
|
||||||
|
|
||||||
|
@ -470,14 +489,13 @@ static int canWalkOnEntity(float x, float y)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Entity *e;
|
Entity *e;
|
||||||
|
Entity **candidates;
|
||||||
|
|
||||||
srcRect.x = x;
|
srcRect.x = x;
|
||||||
srcRect.x = y;
|
srcRect.x = y;
|
||||||
srcRect.w = 8;
|
srcRect.w = 8;
|
||||||
srcRect.h = MAP_TILE_SIZE * 4;
|
srcRect.h = MAP_TILE_SIZE * 4;
|
||||||
|
|
||||||
Entity **candidates;
|
|
||||||
|
|
||||||
candidates = getAllEntsWithin(srcRect.x, srcRect.y, srcRect.w, srcRect.h, NULL);
|
candidates = getAllEntsWithin(srcRect.x, srcRect.y, srcRect.w, srcRect.h, NULL);
|
||||||
|
|
||||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||||
|
@ -609,6 +627,8 @@ static int pushEntity(Entity *e, float dx, float dy)
|
||||||
oldSelf = self;
|
oldSelf = self;
|
||||||
|
|
||||||
self = e;
|
self = e;
|
||||||
|
|
||||||
|
removeFromQuadtree(self, &world.quadtree);
|
||||||
|
|
||||||
if (dx != 0)
|
if (dx != 0)
|
||||||
{
|
{
|
||||||
|
@ -626,6 +646,8 @@ static int pushEntity(Entity *e, float dx, float dy)
|
||||||
e->y = position.y;
|
e->y = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToQuadtree(self, &world.quadtree);
|
||||||
|
|
||||||
self = oldSelf;
|
self = oldSelf;
|
||||||
|
|
||||||
return (e->x == expectedX && e->y == expectedY);
|
return (e->x == expectedX && e->y == expectedY);
|
||||||
|
|
Loading…
Reference in New Issue