Allow world to be set as static, for testing.

This commit is contained in:
Steve 2018-02-11 12:37:37 +00:00
parent 7c2120d0d2
commit 58c398475c
4 changed files with 30 additions and 5 deletions

View File

@ -59,6 +59,7 @@ typedef struct {
int cheatReload;
int cheatBlind;
int cheatNoEnemies;
int cheatStatic;
int fps;
} Dev;

View File

@ -22,15 +22,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void initAtlasTest(void)
{
dev.cheatStatic = 1;
dev.cheatBlind = 0;
dev.cheatNoEnemies = 0;
dev.cheatKeys = 1;
dev.cheatPower = 1;
dev.cheatHealth = 1;
initGame();
initHub();
loadWorld("beachApproach");
loadWorld("beachFront4");
initWorld();

View File

@ -45,6 +45,7 @@ static Marker targetMarker[3];
void initEntities(void)
{
int i;
SDL_Rect *r;
atlasTexture = getTexture("gfx/atlas/atlas.png");
@ -53,6 +54,23 @@ void initEntities(void)
memset(&targetMarker[i], 0, sizeof(Marker));
targetMarker[i].sprite = getSprite("Marker");
}
for (self = world.entityHead.next ; self != NULL ; self = self->next)
{
/*
* Most things retain their dimensions, so this isn't a big deal. If we set
* this each frame, it will muck up the bouncing, especially in the case of grenades.
*/
if (self->w == 0 || self->h == 0)
{
r = &self->sprite[self->facing]->frames[self->spriteFrame]->rect;
self->w = r->w;
self->h = r->h;
}
addToQuadtree(self, &world.quadtree);
}
}
void doEntities(void)
@ -76,10 +94,12 @@ void doEntities(void)
for (self = world.entityHead.next ; self != NULL ; self = self->next)
{
/*
* Most things retain their dimensions, so this isn't a big deal. If we set
* this each frame, it will muck up the bouncing, especially in the case of grenades.
*/
if (dev.cheatStatic && self != (Entity*)world.bob)
{
self->isVisible = 1;
continue;
}
if (self->w == 0 || self->h == 0)
{
r = &self->sprite[self->facing]->frames[self->spriteFrame]->rect;

View File

@ -40,6 +40,7 @@ extern int isSolid(int x, int y);
extern void terminateJetpack(void);
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
extern Dev dev;
extern Entity *self;
extern Camera camera;
extern World world;