Clear entire grid at start of frame (removing individuals is buggy right now).

This commit is contained in:
Steve 2015-12-08 06:44:53 +00:00
parent 22afef45c7
commit 767920478c
3 changed files with 3 additions and 36 deletions

View File

@ -52,14 +52,14 @@ void doEntities(void)
numAllies = numEnemies = numActiveAllies = numActiveEnemies = 0;
destroyGrid();
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
if (e->active)
{
self = e;
removeFromGrid(e);
e->reload = MAX(e->reload - 1, 0);
e->shieldRecharge = MAX(e->shieldRecharge - 1, 0);
e->armourHit = MAX(e->armourHit - 25, 0);

View File

@ -29,6 +29,7 @@ extern void doRope(Entity *e);
extern void drawRope(Entity *e);
extern void cutRope(Entity *e);
extern void drawShieldHitEffect(Entity *e);
extern void destroyGrid(void);
extern App app;
extern Battle battle;

View File

@ -56,40 +56,6 @@ void addToGrid(Entity *e)
}
}
void removeFromGrid(Entity *e)
{
GridCell *cell, *prev;
int x, y, x1, y1, x2, y2;
x1 = (e->x - e->w / 2) / GRID_CELL_WIDTH;
y1 = (e->y - e->h / 2) / GRID_CELL_HEIGHT;
x2 = (e->x + e->w / 2) / GRID_CELL_WIDTH;
y2 = (e->y + e->h / 2) / GRID_CELL_HEIGHT;
for (x = x1 ; x <= x2 ; x++)
{
for (y = y1 ; y <= y2 ; y++)
{
if (x >= 0 && y >= 0 && x < GRID_SIZE && y < GRID_SIZE)
{
prev = &battle.grid[x][y];
for (cell = battle.grid[x][y].next ; cell != NULL ; cell = cell->next)
{
if (cell->entity == e)
{
prev->next = cell->next;
free(cell);
cell = prev;
}
prev = cell;
}
}
}
}
}
Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore)
{
GridCell *cell;