Return pointer to sprite rect.

This commit is contained in:
Steve 2018-02-17 16:53:30 +00:00
parent 357fbdc8a4
commit 17ee7642e9
5 changed files with 29 additions and 24 deletions

View File

@ -78,9 +78,9 @@ static void animateSprite(Sprite *s)
}
}
SDL_Rect getCurrentFrame(Sprite *s)
SDL_Rect *getCurrentFrame(Sprite *s)
{
return s->frames[s->currentFrame]->rect;
return &s->frames[s->currentFrame]->rect;
}
static void loadGameSprites(void)

View File

@ -28,22 +28,13 @@ void initAtlasTest(void)
dev.cheatKeys = 0;
dev.cheatPower = 1;
dev.cheatHealth = 1;
dev.cheatLevels = 1;
dev.cheatLevels = 0;
loadGame();
/*
loadWorld("beachApproach");
STRNCPY(game.worldId, "", MAX_NAME_LENGTH);
initWorld();
initMap();
initEntities();
saveConfig();
saveGame();
*/
initHub();

View File

@ -1079,3 +1079,17 @@ static int drawComparator(const void *a, const void *b)
return e2->type - e1->type;
}
void destroyEntities(void)
{
Entity *e;
while (world.entityHead.next)
{
e = world.entityHead.next;
world.entityHead.next = e->next;
free(e);
}
}

View File

@ -165,7 +165,7 @@ static void drawInventory(void)
{
int x, y, i, size, mid;
float w, h, d;
SDL_Rect r;
SDL_Rect *r;
size = 45;
mid = size / 2;
@ -188,8 +188,8 @@ static void drawInventory(void)
if (world.bob->items[i] != NULL)
{
r = getCurrentFrame(world.bob->items[i]->sprite[0]);
w = r.w;
h = r.h;
w = r->w;
h = r->h;
d = 40;
d /= (w > h) ? w : h;
@ -197,7 +197,7 @@ static void drawInventory(void)
w *= d;
h *= d;
blitRectScaled(atlasTexture->texture, x + mid, y + mid, w, h, &r, 1);
blitRectScaled(atlasTexture->texture, x + mid, y + mid, w, h, r, 1);
}
x += (size + 5);
@ -210,7 +210,7 @@ void drawMissionStatus(void)
int y, x, w, h, size, mid, i;
float rw, rh, d;
SDL_Color c;
SDL_Rect r;
SDL_Rect *r;
char *status;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 64);
@ -266,8 +266,8 @@ void drawMissionStatus(void)
if (world.bob->items[i] != NULL)
{
r = getCurrentFrame(world.bob->items[i]->sprite[0]);
rw = r.w;
rh = r.h;
rw = r->w;
rh = r->h;
d = 40;
d /= (rw > rh) ? rw : rh;
@ -275,7 +275,7 @@ void drawMissionStatus(void)
rw *= d;
rh *= d;
blitRectScaled(atlasTexture->texture, x + mid, y + mid, rw, rh, &r, 1);
blitRectScaled(atlasTexture->texture, x + mid, y + mid, rw, rh, r, 1);
drawText(x + size - 5, y, 14, TA_RIGHT, colors.white, "%d", world.bob->items[i]->value);
}

View File

@ -28,7 +28,7 @@ extern void limitTextWidth(int width);
extern int getWrappedTextHeight(const char *text, int size);
extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center);
extern Texture *getTexture(const char *filename);
extern SDL_Rect getCurrentFrame(Sprite *s);
extern SDL_Rect *getCurrentFrame(Sprite *s);
extern int getPercent(float current, float total);
extern App app;