Init functions.

This commit is contained in:
Steve 2018-02-15 07:49:20 +00:00
parent b3ed2b1762
commit aa02babf98
3 changed files with 27 additions and 12 deletions

View File

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "destructable.h"
static void init(void);
static void applyDamage(int amount);
static void action(void);
static void load(cJSON *root);
@ -41,8 +42,7 @@ Entity *initDestructable(void)
s->health = s->healthMax = 10;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite(s->spriteName);
s->init = init;
s->applyDamage = applyDamage;
s->action = action;
s->load = load;
@ -51,6 +51,15 @@ Entity *initDestructable(void)
return (Entity*)s;
}
static void init(void)
{
Structure *s;
s = (Structure*)self;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite(s->spriteName);
}
static void applyDamage(int amount)
{
if (self->health > 0)

View File

@ -28,7 +28,6 @@ extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void addScorchDecal(int x, int y);
extern Sprite *getSprite(char *name);
extern void updateObjective(char *targetName);
extern void initEntity(Entity *e);
extern Structure *createStructure(void);
extern Entity *self;

View File

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "exit.h"
static void init(void);
static void tick(void);
static void action(void);
static void touch(Entity *other);
@ -41,18 +42,10 @@ Entity *initExit(void)
s->isStatic = 1;
s->active = 0;
if (!s->active)
{
s->spriteFrame = 0;
}
else
{
s->spriteFrame = 1;
}
s->spriteTime = -1;
s->init = init;
s->tick = tick;
s->action = action;
s->touch = touch;
@ -62,6 +55,20 @@ Entity *initExit(void)
return (Entity*)s;
}
static void init(void)
{
if (!self->active)
{
self->spriteFrame = 0;
}
else
{
self->spriteFrame = 1;
}
self->spriteTime = -1;
}
static void tick(void)
{
Structure *s;