From 58c398475c5b56660738d6ffca214067eec01cd5 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 11 Feb 2018 12:37:37 +0000 Subject: [PATCH] Allow world to be set as static, for testing. --- src/structs.h | 1 + src/test/atlasTest.c | 5 ++++- src/world/entities.c | 28 ++++++++++++++++++++++++---- src/world/entities.h | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/structs.h b/src/structs.h index 31fde39..c1e5301 100644 --- a/src/structs.h +++ b/src/structs.h @@ -59,6 +59,7 @@ typedef struct { int cheatReload; int cheatBlind; int cheatNoEnemies; + int cheatStatic; int fps; } Dev; diff --git a/src/test/atlasTest.c b/src/test/atlasTest.c index a51b957..c88fbf1 100644 --- a/src/test/atlasTest.c +++ b/src/test/atlasTest.c @@ -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(); diff --git a/src/world/entities.c b/src/world/entities.c index a06515f..0f38ae5 100644 --- a/src/world/entities.c +++ b/src/world/entities.c @@ -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; diff --git a/src/world/entities.h b/src/world/entities.h index 8e61641..3e484ab 100644 --- a/src/world/entities.h +++ b/src/world/entities.h @@ -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;