Loading some entities.

This commit is contained in:
Steve 2018-01-30 08:29:09 +00:00
parent 21e50e51e7
commit 917753aefe
45 changed files with 383 additions and 153 deletions

View File

@ -10,6 +10,7 @@ SEARCHPATH += src/entities/boss
SEARCHPATH += src/entities/cannons
SEARCHPATH += src/entities/decoration
SEARCHPATH += src/entities/evilBlobs
SEARCHPATH += src/entities/eyeDroids
SEARCHPATH += src/entities/items
SEARCHPATH += src/entities/misc
SEARCHPATH += src/entities/structures
@ -32,7 +33,7 @@ OBJS += atlas.o atlasTest.o aquaBlob.o
OBJS += battery.o blaze.o bob.o boss.o blobBoss.o
OBJS += camera.o cannon.o cardReader.o cell.o cherry.o combat.o consumable.o
OBJS += debris.o destructable.o door.o draw.o
OBJS += effects.o entities.o entityFactory.o exit.o explosions.o eyeDroidCommander.o evilBlob.o
OBJS += effects.o entities.o entityFactory.o exit.o explosions.o eyeDroid.o eyeDroidCommander.o evilBlob.o
OBJS += fleshChunk.o frost.o
OBJS += game.o grenade.o
OBJS += heart.o horizontalDoor.o horizontalLaserTrap.o hub.o hud.o
@ -42,7 +43,7 @@ OBJS += key.o keycard.o
OBJS += laser.o laserTrap.o lift.o lookup.o
OBJS += main.o map.o maths.o mia.o missile.o
OBJS += objectives.o
OBJS += particles.o player.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o
OBJS += particles.o player.o pistolBlob.o pistolDroid.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o
OBJS += quadtree.o
OBJS += sound.o sprites.o structures.o
OBJS += tankCommander.o tankTrack.o teeka.o teleporter.o text.o textures.o title.o triggers.o

View File

@ -26,13 +26,15 @@ static void touch(Entity *other);
static void preTeleport(void);
static void teleport(void);
void initMIA(void)
Entity *initMIA(void)
{
MIA *m;
m = malloc(sizeof(MIA));
memset(m, 0, sizeof(MIA));
initEntity((Entity*)m);
m->type = ET_MIA;
m->tx = m->ty = -1;
@ -53,6 +55,8 @@ void initMIA(void)
m->touch = touch;
m->isMissionTarget = 1;
return (Entity*)m;
}
void reinitMIA(Entity *e)

View File

@ -28,6 +28,7 @@ extern void setGameplayMessage(int type, char *format, ...);
extern void playSound(int snd, int ch);
extern void updateObjective(char *targetName);
extern void addRescuedMIA(char *name);
extern void initEntity(Entity *e);
extern Entity *self;
extern World world;

View File

@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "entityFactory.h"
static void addEntityDef(char *name, int type, Entity *(*initFunc)(void));
static void addEntityDef(char *name, Entity *(*initFunc)(void));
static Entity *initGenericEvilBlob(void);
static Entity *initGenericEyeDroid(void);
static EntityDef head;
static EntityDef *tail;
@ -30,11 +32,33 @@ void initEntityFactory(void)
memset(&head, 0, sizeof(EntityDef));
tail = &head;
addEntityDef("AquaBlob", ET_ENEMY, initAquaBlob);
addEntityDef("AquaBlob", initAquaBlob);
addEntityDef("PistolBlob", initPistolBlob);
addEntityDef("PistolEyeDroid", initPistolDroid);
addEntityDef("GenericEvilBlob", initGenericEvilBlob);
addEntityDef("GenericEyeDroid", initGenericEyeDroid);
addEntityDef("Bob", ET_BOB, initBob);
addEntityDef("Bob", initBob);
addEntityDef("MIA", initMIA);
addEntityDef("Exit", ET_EXIT, initExit);
addEntityDef("Item", initItem);
addEntityDef("BronzeKey", initBronzeKey);
addEntityDef("SilverKey", initSilverKey);
addEntityDef("GoldKey", initGoldKey);
addEntityDef("Exit", initExit);
addEntityDef("PowerPool", initPowerPool);
addEntityDef("Teleporter", initTeleporter);
addEntityDef("PressurePlate", initPressurePlate);
addEntityDef("InfoPoint", initInfoPoint);
addEntityDef("PowerPoint", initPowerPoint);
addEntityDef("PushBlock", initPushBlock);
addEntityDef("Lift", initLift);
addEntityDef("Door", initDoor);
addEntityDef("BronzeDoor", initBronzeDoor);
addEntityDef("SilverDoor", initSilverDoor);
addEntityDef("GoldDoor", initGoldDoor);
addEntityDef("HorizontalDoor", initHorizontalDoor);
}
Entity *createEntity(char *name)
@ -55,7 +79,7 @@ Entity *createEntity(char *name)
return NULL;
}
static void addEntityDef(char *name, int type, Entity *(*initFunc)(void))
static void addEntityDef(char *name, Entity *(*initFunc)(void))
{
EntityDef *def;
@ -65,6 +89,31 @@ static void addEntityDef(char *name, int type, Entity *(*initFunc)(void))
tail = def;
STRNCPY(def->name, name, MAX_NAME_LENGTH);
def->type = type;
def->initFunc = initFunc;
}
static Entity *initGenericEvilBlob(void)
{
int r;
char name[MAX_NAME_LENGTH];
strcpy(name, "");
r = rand() % world.numEnemyTypes;
sprintf(name, "%sBlob", world.enemyTypes[r]);
return createEntity(name);
}
static Entity *initGenericEyeDroid(void)
{
int r;
char name[MAX_NAME_LENGTH];
strcpy(name, "");
r = rand() % world.numEnemyTypes;
sprintf(name, "%sEyeDroid", world.enemyTypes[r]);
return createEntity(name);
}

View File

@ -21,5 +21,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h"
extern Entity *initAquaBlob(void);
extern Entity *initPistolBlob(void);
extern Entity *initPistolDroid(void);
extern Entity *initBob(void);
extern Entity *initExit(void);
extern Entity *initPowerPool(void);
extern Entity *initTeleporter(void);
extern Entity *initPressurePlate(void);
extern Entity *initInfoPoint(void);
extern Entity *initPowerPoint(void);
extern Entity *initPushBlock(void);
extern Entity *initLift(void);
extern Entity *initDoor(void);
extern Entity *initBronzeDoor(void);
extern Entity *initSilverDoor(void);
extern Entity *initGoldDoor(void);
extern Entity *initHorizontalDoor(void);
extern Entity *initMIA(void);
extern Entity *initItem(void);
extern Entity *initBronzeKey(void);
extern Entity *initSilverKey(void);
extern Entity *initGoldKey(void);
extern World world;

View File

@ -22,8 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int canFire(Entity *target);
void initPistolBlob(Unit *u)
Entity *initPistolBlob(void)
{
Unit *u;
u = createUnit();
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSprite("PistolBlobLeft");
@ -35,9 +39,11 @@ void initPistolBlob(Unit *u)
u->maxShotsToFire = 3;
u->canFire = canFire;
return (Entity*)u;
}
static int canFire(Entity *target)
{
return true;
return 1;
}

View File

@ -0,0 +1,25 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../../common.h"
extern Unit *createUnit(void);
extern void initEvilBlob(Unit *u);
extern Sprite *getSprite(char *name);

View File

@ -20,20 +20,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "eyeDroid.h"
static void walk(void);
static void die(void);
static void tick(void);
static void superTick(void);
static void touch(void);
static void superTouch(void);
static void touch(Entity *other);
static void (*superTick)(void);
static void (*superTouch)(Entity *other);
void initEyeDroid(void)
void initEyeDroid(Unit *u)
{
u->flags |= FL_WEIGHTLESS | FL_HALT_AT_EDGE | FL_EXPLODES;
u->flags |= EF_WEIGHTLESS | EF_HALT_AT_EDGE | EF_EXPLODES;
superTick = u->tick;
superTouch = u->touch;
u->walk = walk;
u->tick = tick;
u->touch = touch;
u->die = die;
}
static void tick(void)
@ -57,7 +61,7 @@ static void touch(Entity *other)
u = (Unit*)self;
superTouch();
superTouch(other);
if (u->alive == ALIVE_DYING && (other == NULL || other->isSolid))
{
@ -76,7 +80,9 @@ static void touch(Entity *other)
addRandomItems((int) u->x, (int) u->y);
updateObjectives();
updateObjective(u->name);
updateObjective("ENEMY");
fireTriggers(u->name);
if (u->isMissionTarget)
{
@ -94,7 +100,7 @@ static void touch(Entity *other)
static void unitDie(void)
{
if (self->environment != Environment.AIR)
if (self->environment != ENV_AIR)
{
touch(NULL);
}
@ -106,7 +112,7 @@ static void die(void)
u = (Unit*)self;
u->dx = (fRand() - fRand()) * 3;
u->dx = (randF() - randF()) * 3;
u->spriteTime = 0;
u->spriteFrame = 0;
@ -187,7 +193,7 @@ static void lookForPlayer(void)
u->thinkTime = rrnd(FPS / 2, FPS);
if (world.state != WS_IN_PROGRESS || game.cheatBlind)
if (world.state != WS_IN_PROGRESS || dev.cheatBlind)
{
patrol();
return;
@ -207,23 +213,23 @@ static void lookForPlayer(void)
return;
}
r = fRand();
r = randF();
if (u->isMissionTarget)
{
r = fRand() * 0.3;
r = randF() * 0.3;
}
if (r < 0.125)
{
chase();
u->shotsToFire = rrnd(1, u->maxShotsToFire);
u->action = preFire;
u->action = u->preFire;
}
else if (r < 0.25)
{
u->dx = 0;
u->shotsToFire = rrnd(1, u->maxShotsToFire);
u->action = preFire;
u->action = u->preFire;
}
else if (r < 0.5)
{

View File

@ -0,0 +1,45 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../../common.h"
extern void dropCarriedItem(void);
extern int getDistance(int x1, int y1, int x2, int y2);
extern double randF(void);
extern void throwFleshChunks(float x, float y, int amount);
extern void addRandomWeapon(float x, float y);
extern float limit(float i, float a, float b);
extern void playSound(int snd, int ch);
extern void addBloodDecal(int x, int y);
extern void updateObjective(char *targetName);
extern int enemyCanSeePlayer(Entity *e);
extern void addDefeatedTarget(char *name);
extern void fireTriggers(char *name);
extern void addRandomItems(float x, float y);
extern int rrnd(int low, int high);
extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void throwDebris(float x, float y, int amount);
extern void addSmokeParticles(float x, float y);
extern void addScorchDecal(int x, int y);
extern Dev dev;
extern Entity *self;
extern Game game;
extern World world;

View File

@ -22,8 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int canFire(Entity *target);
void initPistolDroid(Unit *u)
Entity *initPistolDroid(void)
{
Unit *u;
u = createUnit();
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSprite("PistolDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("PistolDroidRight");
u->sprite[FACING_DIE] = getSprite("PistolDroidDie");
@ -33,9 +39,11 @@ void initPistolDroid(Unit *u)
u->maxShotsToFire = 3;
u->canFire = canFire;
return (Entity*)u;
}
static int canFire(Entity *target)
{
return true;
return 1;
}

View File

@ -0,0 +1,25 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../../common.h"
extern Unit *createUnit(void);
extern void initEyeDroid(Unit *u);
extern Sprite *getSprite(char *name);

View File

@ -22,13 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void touch(Entity *other);
void initCell(Entity *e)
Entity *initCell(void)
{
Item *i;
initItem(e);
i = (Item*)self;
i = (Item*)createItem();
i->type = ET_HEART_CELL;
@ -42,6 +40,8 @@ void initCell(Entity *e)
i->spriteTime = -1;
i->touch = touch;
return (Entity*)i;
}
static void touch(Entity *other)

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initItem(Entity *e);
extern Entity *createItem(void);
extern Sprite *getSprite(char *name);
extern void setGameplayMessage(int type, char *format, ...);
extern void playSound(int snd, int ch);

View File

@ -23,13 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void action(void);
static void touch(Entity *other);
void initHeart(Entity *e)
Entity *initHeart(Entity *e)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_HEART_CELL;
@ -44,6 +42,8 @@ void initHeart(Entity *e)
i->action = action;
i->touch = touch;
return (Entity*)i;
}
static void action(void)

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void playSound(int snd, int ch);
extern void setGameplayMessage(int type, char *format, ...);
extern void initItem(Entity *e);
extern Entity *createItem(void);
extern Sprite *getSprite(char *name);
extern void updateObjective(char *targetName);
extern int rrnd(int low, int high);

View File

@ -29,13 +29,16 @@ static void destructablePickupItem(Structure *s);
static void enemyPickupItem(Unit *u);
static void bobPickupItem(void);
void initItem(Entity *e)
Entity *createItem(void)
{
Item *i;
initEntity(e);
i = malloc(sizeof(Item));
memset(i, 0, sizeof(Item));
world.entityTail->next = (Entity*)i;
world.entityTail = (Entity*)i;
i = (Item*)e;
initEntity((Entity*)i);
i->type = ET_ITEM;
@ -55,6 +58,13 @@ void initItem(Entity *e)
i->changeEnvironment = changeEnvironment;
i->reset = reset;
i->die = die;
return (Entity*)i;
}
Entity *initItem(void)
{
return createItem();
}
static void reset(void)

View File

@ -20,44 +20,44 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "key.h"
void initBronzeKey(Entity *e)
Entity *initBronzeKey(Entity *e)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Bronze Key", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "BronzeKey", MAX_NAME_LENGTH);
return (Entity*)i;
}
void initSilverKey(Entity *e)
Entity *initSilverKey(Entity *e)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Silver Key", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "SilverKey", MAX_NAME_LENGTH);
return (Entity*)i;
}
void initGoldKey(Entity *e)
Entity *initGoldKey(Entity *e)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Gold Key", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "GoldKey", MAX_NAME_LENGTH);
return (Entity*)i;
}

View File

@ -20,4 +20,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initItem(Entity *e);
extern Entity *createItem(void);

View File

@ -23,69 +23,67 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void (*itemTouch)(Entity *other);
static void touchWhiteKeycard(Entity *other);
void initRedKeycard(Entity *e)
Entity *initRedKeycard(void)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Red Keycard", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "RedKeycard", MAX_NAME_LENGTH);
return (Entity*)i;
}
void initBlueKeycard(Entity *e)
Entity *initBlueKeycard(void)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Blue Keycard", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "BlueKeycard", MAX_NAME_LENGTH);
return (Entity*)i;
}
void initGreenKeycard(Entity *e)
Entity *initGreenKeycard(void)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Green Keycard", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "GreenKeycard", MAX_NAME_LENGTH);
return (Entity*)i;
}
void initYellowKeycard(Entity *e)
Entity *initYellowKeycard(void)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
STRNCPY(i->name, "Yellow Keycard", MAX_NAME_LENGTH);
STRNCPY(i->spriteName, "YellowKeycard", MAX_NAME_LENGTH);
return (Entity*)i;
}
void initWhiteKeycard(Entity *e)
Entity *initWhiteKeycard(void)
{
Item *i;
initItem(e);
i = (Item*)e;
i = (Item*)createItem();
i->type = ET_KEY;
@ -95,6 +93,8 @@ void initWhiteKeycard(Entity *e)
itemTouch = i->touch;
i->touch = touchWhiteKeycard;
return (Entity*)i;
}
static void touchWhiteKeycard(Entity *other)

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initItem(Entity *e);
extern Entity *createItem(void);
extern void updateObjective(char *targetName);
extern void teekaExitMission(void);

View File

@ -23,13 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void tick(void);
static void touch(Entity *other);
void initInfoPoint(Entity *e)
Entity *initInfoPoint(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_INFO_POINT;
@ -43,6 +41,8 @@ void initInfoPoint(Entity *e)
s->tick = tick;
s->touch = touch;
return (Entity*)s;
}
static void tick(void)

View File

@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern Sprite *getSprite(char *name);
extern void initEntity(Entity *e);
extern void showInfoMessage(char *message);
extern Structure *createStructure(void);
extern Entity *self;
extern World world;

View File

@ -27,13 +27,11 @@ static int isClosed(void);
static int isOpening(void);
static int isClosing(void);
void initDoor(Entity *e)
Entity *initDoor(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_DOOR;
@ -59,51 +57,53 @@ void initDoor(Entity *e)
s->tick = tick;
s->touch = touch;
return (Entity*)s;
}
void initBronzeDoor(Entity *e)
Entity *initBronzeDoor(void)
{
Structure *s;
initDoor(e);
s = (Structure*)e;
s = (Structure*)initDoor();
STRNCPY(s->requiredItem, "Bronze Key", MAX_NAME_LENGTH);
s->speed = 2;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("BronzeDoor");
return (Entity*)s;
}
void initSilverDoor(Entity *e)
Entity *initSilverDoor(void)
{
Structure *s;
initDoor(e);
s = (Structure*)e;
s = (Structure*)initDoor();
STRNCPY(s->requiredItem, "Silver Key", MAX_NAME_LENGTH);
s->speed = 2;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("SilverDoor");
return (Entity*)s;
}
void initGoldDoor(Entity *e)
Entity *initGoldDoor(void)
{
Structure *s;
initDoor(e);
s = (Structure*)e;
s = (Structure*)initDoor();
STRNCPY(s->requiredItem, "Gold Key", MAX_NAME_LENGTH);
s->speed = 2;
s->sprite[0] = s->sprite[1] = e->sprite[2] = getSprite("GoldDoor");
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("GoldDoor");
return (Entity*)s;
}
static void tick(void)

View File

@ -27,6 +27,7 @@ extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void setGameplayMessage(int type, char *format, ...);
extern int hasItem(char *name);
extern void removeItem(char *name);
extern Structure *createStructure(void);
extern Entity *self;
extern Dev dev;

View File

@ -25,7 +25,7 @@ static void action(void);
static void touch(Entity *other);
static SDL_Rect *getBounds(void);
void initExit(void)
Entity *initExit(void)
{
Structure *s;
@ -56,6 +56,8 @@ void initExit(void)
s->action = action;
s->touch = touch;
s->getBounds = getBounds;
return (Entity*)s;
}
static void tick(void)

View File

@ -20,32 +20,48 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "horizontalDoor.h"
void initHorizontalDoor(Entity *e)
Entity *initHorizontalDoor(void)
{
initDoor(e);
Structure *s;
e->type = ET_DOOR;
s = createStructure();
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSprite("HorizonalDoor");
s->type = ET_DOOR;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("HorizonalDoor");
return (Entity*)s;
}
void initBronzeHorizontalDoor(Entity *e)
Entity *initBronzeHorizontalDoor(void)
{
initHorizontalDoor(e);
Structure *s;
STRNCPY(((Structure*)e)->requiredItem, "Bronze Key", MAX_NAME_LENGTH);
s = (Structure*)initHorizontalDoor();
STRNCPY(s->requiredItem, "Bronze Key", MAX_NAME_LENGTH);
return (Entity*)s;
}
void initSilverHorizontalDoor(Entity *e)
Entity *initSilverHorizontalDoor(void)
{
initHorizontalDoor(e);
Structure *s;
STRNCPY(((Structure*)e)->requiredItem, "Silver Key", MAX_NAME_LENGTH);
s = (Structure*)initHorizontalDoor();
STRNCPY(s->requiredItem, "Silver Key", MAX_NAME_LENGTH);
return (Entity*)s;
}
void initGoldHorizontalDoor(Entity *e)
Entity *initGoldHorizontalDoor(void)
{
initHorizontalDoor(e);
Structure *s;
STRNCPY(((Structure*)e)->requiredItem, "Gold Key", MAX_NAME_LENGTH);
s = (Structure*)initHorizontalDoor();
STRNCPY(s->requiredItem, "Gold Key", MAX_NAME_LENGTH);
return (Entity*)s;
}

View File

@ -22,3 +22,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void initDoor(Entity *e);
extern Sprite *getSprite(char *name);
extern Structure *createStructure(void);

View File

@ -23,13 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void action(void);
static void activate(int active);
void initLift(Entity *e)
Entity *initLift(Entity *e)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_LIFT;
@ -49,6 +47,8 @@ void initLift(Entity *e)
s->action = action;
s->activate = activate;
return (Entity*)s;
}
static void action(void)

View File

@ -20,11 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern Sprite *getSprite(char *name);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void observeActivation(Entity *e);
extern int isOnScreen(Entity *e);
extern void setGameplayMessage(int type, char *format, ...);
extern Structure *createStructure(void);
extern Entity *self;

View File

@ -24,13 +24,11 @@ static void tick(void);
static void action(void);
static void touch(Entity *other);
void initPowerPoint(Entity *e)
Entity *initPowerPoint(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_POWER_POINT;
@ -45,6 +43,8 @@ void initPowerPoint(Entity *e)
s->tick = tick;
s->action = action;
s->touch = touch;
return (Entity*)s;
}
static void tick(void)

View File

@ -20,10 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern Sprite *getSprite(char *name);
extern void activateEntities(char *names, int activate);
extern void setGameplayMessage(int type, char *format, ...);
extern Structure *createStructure(void);
extern Dev dev;
extern Entity *self;

View File

@ -24,13 +24,11 @@ static void tick(void);
static void action(void);
static void touch(Entity *other);
void initPowerPool(Entity *e)
Entity *initPowerPool(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_POOL;
@ -45,6 +43,8 @@ void initPowerPool(Entity *e)
s->tick = tick;
s->action = action;
s->touch = touch;
return (Entity*)s;
}
static void tick(void)

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern Structure *createStructure(void);
extern Sprite *getSprite(char *name);
extern void initEntity(Entity *e);
extern Entity *self;
extern World world;

View File

@ -23,13 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void tick(void);
static void touch(Entity *other);
void initPressurePlate(Entity *e)
Entity *initPressurePlate(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_PRESSURE_PLATE;
@ -43,6 +41,8 @@ void initPressurePlate(Entity *e)
s->tick = tick;
s->touch = touch;
return (Entity*)s;
}
static void tick(void)

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern Structure *createStructure(void);
extern Sprite *getSprite(char *name);
extern void activateEntities(char *names, int activate);
extern void playSound(int snd, int ch);

View File

@ -22,13 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void activate(int active);
void initPushBlock(Entity *e)
Entity *initPushBlock(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_PUSHBLOCK;
@ -39,6 +37,8 @@ void initPushBlock(Entity *e)
s->flags |= EF_EXPLODES | EF_ALWAYS_PROCESS;
s->activate = activate;
return (Entity*)s;
}
static void activate(int active)

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern void playSound(int snd, int ch);
extern void addTeleportStars(Entity *e);
extern Structure *createStructure(void);
extern Entity *self;

View File

@ -29,5 +29,7 @@ Structure *createStructure(void)
world.entityTail->next = (Entity*)s;
world.entityTail = (Entity*)s;
initEntity((Entity*)s);
return s;
}

View File

@ -20,6 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern Structure *createStructure(void);
extern void initEntity(Entity *e);
extern World world;

View File

@ -24,23 +24,27 @@ static void action(void);
static void touch(Entity *other);
static void activate(int active);
void initTeleporter(Entity *e)
Entity *initTeleporter(void)
{
initEntity(e);
Structure *s;
e->type = ET_TELEPORTER;
s = createStructure();
e->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_IGNORE_BULLETS | EF_NO_TELEPORT;
e->plane = PLANE_FOREGROUND;
e->isStatic = 1;
e->active = 1;
s->type = ET_TELEPORTER;
e->action = action;
e->touch = touch;
e->activate = activate;
s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_IGNORE_BULLETS | EF_NO_TELEPORT;
s->plane = PLANE_FOREGROUND;
s->isStatic = 1;
s->active = 1;
s->action = action;
s->touch = touch;
s->activate = activate;
return (Entity*)s;
}
static void action(void)

View File

@ -20,12 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern void playSound(int snd, int ch);
extern void addTeleporterEffect(float x, float y);
extern void teleportEntity(Entity *e, float tx, float ty);
extern void observeActivation(Entity *e);
extern int isOnScreen(Entity *e);
extern void setGameplayMessage(int type, char *format, ...);
extern Structure *createStructure(void);
extern Entity *self;

View File

@ -95,7 +95,6 @@ struct Lookup {
struct EntityDef {
char name[MAX_NAME_LENGTH];
int type;
Entity *(*initFunc)(void);
EntityDef *next;
};

View File

@ -40,7 +40,7 @@ void initAtlasTest(void)
loadMapData("data/maps/raw/beachApproach.raw");
loadWorld("data/maps/underground2.json");
loadWorld("data/maps/beachApproach.json");
}
static void logic(void)

View File

@ -75,3 +75,8 @@ void throwFleshChunks(float x, float y, int amount)
chunk->sprite[0] = chunk->sprite[1] = chunk->sprite[2] = fleshChunk[i % 3];
}
}
void throwDebris(float x, float y, int amount)
{
}

View File

@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h"
extern Sprite *getSprite(char *name);
extern float wrap(float value, float low, float high);
extern int rrnd(int low, int high);
extern double randF(void);
extern int getDistance(int x1, int y1, int x2, int y2);