Use sprite pointers, rather than ints.

This commit is contained in:
Steve 2018-01-29 23:00:14 +00:00
parent d999c14776
commit 21e50e51e7
87 changed files with 285 additions and 299 deletions

View File

@ -44,7 +44,7 @@ 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 += quadtree.o
OBJS += sound.o sprites.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
OBJS += unit.o util.o
OBJS += weapons.o weaponPickup.o widgets.o world.o worldLoader.o

View File

@ -22,43 +22,43 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Bullet *createBaseBullet(Unit *owner);
static int bulletSprite[2];
static int plasmaSprite[2];
static int aimedSprite;
static int spreadShotSprite;
static int alienSpreadShotSprite;
static int laserSprite[2];
static int grenadeSprite;
static int alienGrenadeSprite;
static int shotgunPelletSprite;
static int missileSprite[2];
static Sprite *bulletSprite[2];
static Sprite *plasmaSprite[2];
static Sprite *aimedSprite;
static Sprite *spreadShotSprite;
static Sprite *alienSpreadShotSprite;
static Sprite *laserSprite[2];
static Sprite *grenadeSprite;
static Sprite *alienGrenadeSprite;
static Sprite *shotgunPelletSprite;
static Sprite *missileSprite[2];
static void tick(void);
static void touch(Entity *other);
void initWeapons(void)
{
bulletSprite[0] = getSpriteIndex("BulletRight");
bulletSprite[1] = getSpriteIndex("BulletLeft");
bulletSprite[0] = getSprite("BulletRight");
bulletSprite[1] = getSprite("BulletLeft");
plasmaSprite[0] = getSpriteIndex("PlasmaRight");
plasmaSprite[1] = getSpriteIndex("PlasmaLeft");
plasmaSprite[0] = getSprite("PlasmaRight");
plasmaSprite[1] = getSprite("PlasmaLeft");
aimedSprite = getSpriteIndex("AimedShot");
aimedSprite = getSprite("AimedShot");
spreadShotSprite = getSpriteIndex("SpreadShot");
alienSpreadShotSprite = getSpriteIndex("AlienSpreadShot");
spreadShotSprite = getSprite("SpreadShot");
alienSpreadShotSprite = getSprite("AlienSpreadShot");
laserSprite[0] = getSpriteIndex("Laser");
laserSprite[1] = getSpriteIndex("AlienLaser");
laserSprite[0] = getSprite("Laser");
laserSprite[1] = getSprite("AlienLaser");
grenadeSprite = getSpriteIndex("Grenade");
alienGrenadeSprite = getSpriteIndex("AlienGrenade");
grenadeSprite = getSprite("Grenade");
alienGrenadeSprite = getSprite("AlienGrenade");
shotgunPelletSprite = getSpriteIndex("ShotgunPellet");
shotgunPelletSprite = getSprite("ShotgunPellet");
missileSprite[0] = getSpriteIndex("MissileRight");
missileSprite[1] = getSpriteIndex("MissileLeft");
missileSprite[0] = getSprite("MissileRight");
missileSprite[1] = getSprite("MissileLeft");
}
void firePistol(Unit *owner)

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h"
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void playSound(int snd, int ch);
extern int rrnd(int low, int high);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);

View File

@ -37,9 +37,9 @@ void initMIA(void)
m->tx = m->ty = -1;
m->sprite[FACING_LEFT] = getSpriteIndex("MIA");
m->sprite[FACING_RIGHT] = getSpriteIndex("MIA");
m->sprite[FACING_DIE] = getSpriteIndex("MIA");
m->sprite[FACING_LEFT] = getSprite("MIA");
m->sprite[FACING_RIGHT] = getSprite("MIA");
m->sprite[FACING_DIE] = getSprite("MIA");
m->flags |= EF_IGNORE_BULLETS;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void nothing(void);
extern void addMIATeleportStars(float x, float y);
extern void addTeleportStars(Entity *e);

View File

@ -26,7 +26,7 @@ static void preFire(void);
static void attack(void);
static Entity *target;
static int aimedSprite;
static Sprite *aimedSprite;
static int exitMission;
void initTeeka(void)
@ -43,15 +43,15 @@ void initTeeka(void)
u->weaponType = WPN_AIMED_PISTOL;
u->sprite[FACING_LEFT] = getSpriteIndex("TeekaLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("TeekaRight");
u->sprite[FACING_DIE] = getSpriteIndex("TeekaLeft");
u->sprite[FACING_LEFT] = getSprite("TeekaLeft");
u->sprite[FACING_RIGHT] = getSprite("TeekaRight");
u->sprite[FACING_DIE] = getSprite("TeekaLeft");
u->health = u->healthMax = 9999;
u->tick = tick;
aimedSprite = getSpriteIndex("AimedShot");
aimedSprite = getSprite("AimedShot");
}
static void tick(void)

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern Unit *createUnit(void);
extern void unitTick(void);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern int rrnd(int low, int high);
extern Bullet *createBaseBullet(Unit *owner);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);

View File

@ -32,7 +32,7 @@ void initBlaze(Entity *e)
STRNCPY(b->name, "Blaze", MAX_NAME_LENGTH);
b->sprite[FACING_LEFT] = getSpriteIndex("BlazeLeft");
b->sprite[FACING_RIGHT] = getSpriteIndex("BlazeRight");
b->sprite[FACING_DIE] = getSpriteIndex("BlazeSpin");
b->sprite[FACING_LEFT] = getSprite("BlazeLeft");
b->sprite[FACING_RIGHT] = getSprite("BlazeRight");
b->sprite[FACING_DIE] = getSprite("BlazeSpin");
}

View File

@ -21,4 +21,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBlobBoss(Boss *b);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);

View File

@ -24,7 +24,7 @@ static void activate(int activate);
static void walk(void);
static void tick(void);
static void changeEnvironment(void);
static int getCurrentSprite(void);
static Sprite *getCurrentSprite(void);
static void animate(void);
static void applyDamage(int amount);
static void moveTowardsPlayer(void);
@ -34,7 +34,7 @@ static void attack(void);
static void die1(void);
static void die2(void);
static int aimedSprite;
static Sprite *aimedSprite;
void initBlobBoss(Entity *e)
{
@ -59,7 +59,7 @@ void initBlobBoss(Entity *e)
b->applyDamage = applyDamage;
b->die = die1;
aimedSprite = getSpriteIndex("AimedShot");
aimedSprite = getSprite("AimedShot");
}
static void activate(int activate)
@ -171,7 +171,7 @@ static void die1(void)
b->action = die2;
}
static int getCurrentSprite(void)
static Sprite *getCurrentSprite(void)
{
Boss *b;

View File

@ -30,7 +30,7 @@ extern double randF(void);
extern void playSound(int snd, int ch);
extern void animateEntity(Entity *e);
extern Bullet *createBaseBullet(Unit *owner);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern int getDistance(int x1, int y1, int x2, int y2);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern int enemyCanSeePlayer(Entity *e);

View File

@ -30,7 +30,7 @@ void initBoss(Entity *e)
b->type = ET_BOSS;
b->sprite[FACING_LEFT] = b->sprite[FACING_RIGHT] = b->sprite[FACING_DIE] = getSpriteIndex("Boss");
b->sprite[FACING_LEFT] = b->sprite[FACING_RIGHT] = b->sprite[FACING_DIE] = getSprite("Boss");
b->isMissionTarget = 1;

View File

@ -22,6 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void initEntity(Entity *e);
extern void lookForPlayer(void);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern World world;

View File

@ -33,12 +33,12 @@ static void attackMissile(void);
static void preFire(void);
static void attack(void);
static void applyDamage(int amount);
static int getCurrentSprite(void);
static Sprite *getCurrentSprite(void);
static int brakingTimer;
static int aimedSprite;
static int missileSprite[2];
static int plasmaSprite[2];
static Sprite *aimedSprite;
static Sprite *missileSprite[2];
static Sprite *plasmaSprite[2];
void initEyeDroidCommander(Entity *e)
{
@ -50,9 +50,9 @@ void initEyeDroidCommander(Entity *e)
STRNCPY(b->name, "EyeDroid Commander", MAX_NAME_LENGTH);
b->sprite[FACING_LEFT] = getSpriteIndex("DroidCommanderLeft");
b->sprite[FACING_RIGHT] = getSpriteIndex("DroidCommanderRight");
b->sprite[FACING_DIE] = getSpriteIndex("DroidCommanderDie");
b->sprite[FACING_LEFT] = getSprite("DroidCommanderLeft");
b->sprite[FACING_RIGHT] = getSprite("DroidCommanderRight");
b->sprite[FACING_DIE] = getSprite("DroidCommanderDie");
b->flags |= EF_WEIGHTLESS | EF_EXPLODES;
@ -66,13 +66,13 @@ void initEyeDroidCommander(Entity *e)
brakingTimer = 0;
aimedSprite = getSpriteIndex("AimedShot");
aimedSprite = getSprite("AimedShot");
missileSprite[0] = getSpriteIndex("MissileRight");
missileSprite[1] = getSpriteIndex("MissileLeft");
missileSprite[0] = getSprite("MissileRight");
missileSprite[1] = getSprite("MissileLeft");
plasmaSprite[0] = getSpriteIndex("PlasmaRight");
plasmaSprite[1] = getSpriteIndex("PlasmaLeft");
plasmaSprite[0] = getSprite("PlasmaRight");
plasmaSprite[1] = getSprite("PlasmaLeft");
}
static void activate(int activate)
@ -382,7 +382,7 @@ static void die2()
}
}
static int getCurrentSprite(void)
static Sprite *getCurrentSprite(void)
{
if (self->health <= 0)
{

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBoss(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void playMusic(char *filename, int loop);
extern void addTeleportStars(Entity *e);
extern float limit(float i, float a, float b);

View File

@ -32,7 +32,7 @@ void initFrost(Entity *e)
STRNCPY(b->name, "Frost", MAX_NAME_LENGTH);
b->sprite[FACING_LEFT] = getSpriteIndex("FrostLeft");
b->sprite[FACING_RIGHT] = getSpriteIndex("FrostRight");
b->sprite[FACING_DIE] = getSpriteIndex("FrostSpin");
b->sprite[FACING_LEFT] = getSprite("FrostLeft");
b->sprite[FACING_RIGHT] = getSprite("FrostRight");
b->sprite[FACING_DIE] = getSprite("FrostSpin");
}

View File

@ -21,4 +21,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBlobBoss(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);

View File

@ -36,8 +36,8 @@ static void moveTowardsPlayer(void);
static Entity *tankTrack;
static int brakingTimer;
static int missileSprite[2];
static int aimedSprite;
static Sprite *missileSprite[2];
static Sprite *aimedSprite;
void initTankCommander(Entity *e)
{
@ -49,9 +49,9 @@ void initTankCommander(Entity *e)
STRNCPY(e->name, "Tank Commander", MAX_NAME_LENGTH);
b->sprite[FACING_LEFT] = getSpriteIndex("TankCommanderLeft");
b->sprite[FACING_RIGHT] = getSpriteIndex("TankCommanderRight");
b->sprite[FACING_DIE] = getSpriteIndex("TankCommanderDie");
b->sprite[FACING_LEFT] = getSprite("TankCommanderLeft");
b->sprite[FACING_RIGHT] = getSprite("TankCommanderRight");
b->sprite[FACING_DIE] = getSprite("TankCommanderDie");
b->flags |= EF_EXPLODES;
@ -68,10 +68,10 @@ void initTankCommander(Entity *e)
world.boss = b;
aimedSprite = getSpriteIndex("AimedShot");
aimedSprite = getSprite("AimedShot");
missileSprite[0] = getSpriteIndex("MissileRight");
missileSprite[1] = getSpriteIndex("MissileLeft");
missileSprite[0] = getSprite("MissileRight");
missileSprite[1] = getSprite("MissileLeft");
initTankTrack(tankTrack);
}

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBoss(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void playMusic(char *filename, int loop);
extern void addTeleportStars(Entity *e);
extern float limit(float i, float a, float b);

View File

@ -37,9 +37,9 @@ void initTankTrack(Entity *e, Entity *tank)
e->isMissionTarget = 0;
e->sprite[FACING_LEFT] = getSpriteIndex("TankTrackLeft");
e->sprite[FACING_RIGHT] = getSpriteIndex("TankTrackRight");
e->sprite[FACING_DIE] = getSpriteIndex("TankTrackLeft");
e->sprite[FACING_LEFT] = getSprite("TankTrackLeft");
e->sprite[FACING_RIGHT] = getSprite("TankTrackRight");
e->sprite[FACING_DIE] = getSprite("TankTrackLeft");
e->tick = tick;
e->touch = touch;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBoss(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern int rrnd(int low, int high);
extern void playSound(int snd, int ch);

View File

@ -36,9 +36,9 @@ void initCannon(void)
u->type = ET_ENEMY;
u->sprite[FACING_LEFT] = getSpriteIndex("CannonLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("CannonRight");
u->sprite[FACING_DIE] = getSpriteIndex("CannonLeft");
u->sprite[FACING_LEFT] = getSprite("CannonLeft");
u->sprite[FACING_RIGHT] = getSprite("CannonRight");
u->sprite[FACING_DIE] = getSprite("CannonLeft");
u->weaponType = WPN_MISSILE;

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void addExplosion(float x, float y, int radius, Entity *owner);
extern int rrnd(int low, int high);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern int getDistance(int x1, int y1, int x2, int y2);
extern int enemyCanSeePlayer(Entity *e);
extern void updateObjective(char *targetName);

View File

@ -29,8 +29,6 @@ void initEntity(Entity *e)
{
e->uniqueId = world.entityCounter++;
e->sprite[0] = e->sprite[1] = e->sprite[2] = -1;
e->environment = ENV_AIR;
e->alive = ALIVE_ALIVE;
@ -66,16 +64,6 @@ static SDL_Rect *getBounds(void)
return &self->bounds;
}
int getCurrentEntitySprite(EntityExt *e)
{
if (e->alive == ALIVE_ALIVE)
{
return e->sprite[e->facing];
}
return e->sprite[FACING_DIE];
}
void animateEntity(void)
{
}

View File

@ -33,6 +33,8 @@ void initEntityFactory(void)
addEntityDef("AquaBlob", ET_ENEMY, initAquaBlob);
addEntityDef("Bob", ET_BOB, initBob);
addEntityDef("Exit", ET_EXIT, initExit);
}
Entity *createEntity(char *name)

View File

@ -22,3 +22,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern Entity *initAquaBlob(void);
extern Entity *initBob(void);
extern Entity *initExit(void);

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int canFire(Entity *target);
void initAquaBlob(void)
Entity *initAquaBlob(void)
{
Unit *u;
@ -30,9 +30,9 @@ void initAquaBlob(void)
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("AquaBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("AquaBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("AquaBlobSpin");
u->sprite[FACING_LEFT] = getSprite("AquaBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("AquaBlobRight");
u->sprite[FACING_DIE] = getSprite("AquaBlobSpin");
u->weaponType = WPN_AIMED_PISTOL;
@ -41,6 +41,8 @@ void initAquaBlob(void)
u->maxShotsToFire = 3;
u->canFire = canFire;
return (Entity*)u;
}
static int canFire(Entity *target)

View File

@ -22,4 +22,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern Unit *createUnit(void);
extern void initEvilBlob(Unit *u);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);

View File

@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void dropCarriedItem(void);
extern int getDistance(int x1, int y1, int x2, int y2);
extern double randF(void);
extern void throwFleshChunks(double x, double y, int amount);
extern void addRandomWeapon(double x, double y);
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);

View File

@ -27,9 +27,9 @@ void initGrenadeBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("GrenadeBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("GrenadeBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("GrenadeBlobSpin");
u->sprite[FACING_LEFT] = getSprite("GrenadeBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("GrenadeBlobRight");
u->sprite[FACING_DIE] = getSprite("GrenadeBlobSpin");
u->weaponType = WPN_GRENADES;

View File

@ -26,9 +26,9 @@ void initLaserBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("LaserBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("LaserBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("LaserBlobSpin");
u->sprite[FACING_LEFT] = getSprite("LaserBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("LaserBlobRight");
u->sprite[FACING_DIE] = getSprite("LaserBlobSpin");
u->weaponType = WPN_LASER;

View File

@ -26,9 +26,9 @@ void initMachineGunBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("MachineGunBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("MachineGunBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("MachineGunBlobSpin");
u->sprite[FACING_LEFT] = getSprite("MachineGunBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("MachineGunBlobRight");
u->sprite[FACING_DIE] = getSprite("MachineGunBlobSpin");
u->weaponType = WPN_MACHINE_GUN;

View File

@ -26,9 +26,9 @@ void initPistolBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("PistolBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("PistolBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("PistolBlobSpin");
u->sprite[FACING_LEFT] = getSprite("PistolBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("PistolBlobRight");
u->sprite[FACING_DIE] = getSprite("PistolBlobSpin");
u->weaponType = WPN_AIMED_PISTOL;

View File

@ -26,9 +26,9 @@ void initPlasmaBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("PlasmaBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("PlasmaBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("PlasmaBlobSpin");
u->sprite[FACING_LEFT] = getSprite("PlasmaBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("PlasmaBlobRight");
u->sprite[FACING_DIE] = getSprite("PlasmaBlobSpin");
u->weaponType = WPN_PLASMA;

View File

@ -26,9 +26,9 @@ void initShotgunBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("ShotgunBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("ShotgunBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("ShotgunBlobSpin");
u->sprite[FACING_LEFT] = getSprite("ShotgunBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("ShotgunBlobRight");
u->sprite[FACING_DIE] = getSprite("ShotgunBlobSpin");
u->weaponType = WPN_SHOTGUN;

View File

@ -26,9 +26,9 @@ void initSpreadGunBlob(Unit *u)
{
initEvilBlob(u);
u->sprite[FACING_LEFT] = getSpriteIndex("SpreadGunBlobLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("SpreadGunBlobRight");
u->sprite[FACING_DIE] = getSpriteIndex("SpreadGunBlobSpin");
u->sprite[FACING_LEFT] = getSprite("SpreadGunBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("SpreadGunBlobRight");
u->sprite[FACING_DIE] = getSprite("SpreadGunBlobSpin");
u->weaponType = WPN_SPREAD;

View File

@ -27,9 +27,9 @@ void initGrenadeDroid(Unit *u)
{
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSpriteIndex("GrenadeDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("GrenadeDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("GrenadeDroidDie");
u->sprite[FACING_LEFT] = getSprite("GrenadeDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("GrenadeDroidRight");
u->sprite[FACING_DIE] = getSprite("GrenadeDroidDie");
u->weaponType = WPN_GRENADES;

View File

@ -26,9 +26,9 @@ void initLaserDroid(Unit *u)
{
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSpriteIndex("LaserDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("LaserDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("LaserDroidDie");
u->sprite[FACING_LEFT] = getSprite("LaserDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("LaserDroidRight");
u->sprite[FACING_DIE] = getSprite("LaserDroidDie");
u->weaponType = WPN_LASER;

View File

@ -26,9 +26,9 @@ void initMachineGunDroid(Unit *u)
{
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSpriteIndex("MachineGunDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("MachineGunDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("MachineGunDroidDie");
u->sprite[FACING_LEFT] = getSprite("MachineGunDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("MachineGunDroidRight");
u->sprite[FACING_DIE] = getSprite("MachineGunDroidDie");
u->weaponType = WPN_MACHINE_GUN;

View File

@ -24,9 +24,9 @@ static int canFire(Entity *target);
void initPistolDroid(Unit *u)
{
u->sprite[FACING_LEFT] = getSpriteIndex("PistolDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("PistolDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("PistolDroidDie");
u->sprite[FACING_LEFT] = getSprite("PistolDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("PistolDroidRight");
u->sprite[FACING_DIE] = getSprite("PistolDroidDie");
u->weaponType = WPN_AIMED_PISTOL;

View File

@ -26,9 +26,9 @@ void initPlasmaDroid(Unit *u)
{
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSpriteIndex("PlasmaDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("PlasmaDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("PlasmaDroidDie");
u->sprite[FACING_LEFT] = getSprite("PlasmaDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("PlasmaDroidRight");
u->sprite[FACING_DIE] = getSprite("PlasmaDroidDie");
u->weaponType = WPN_PLASMA;

View File

@ -26,9 +26,9 @@ void initShotgunDroid(Unit *u)
{
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSpriteIndex("ShotgunDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("ShotgunDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("ShotgunDroidDie");
u->sprite[FACING_LEFT] = getSprite("ShotgunDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("ShotgunDroidRight");
u->sprite[FACING_DIE] = getSprite("ShotgunDroidDie");
u->weaponType = WPN_SHOTGUN;

View File

@ -26,9 +26,9 @@ void initSpreadGunDroid(Unit *u)
{
initEyeDroid(u);
u->sprite[FACING_LEFT] = getSpriteIndex("SpreadGunDroidLeft");
u->sprite[FACING_RIGHT] = getSpriteIndex("SpreadGunDroidRight");
u->sprite[FACING_DIE] = getSpriteIndex("SpreadGunDroidDie");
u->sprite[FACING_LEFT] = getSprite("SpreadGunDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("SpreadGunDroidRight");
u->sprite[FACING_DIE] = getSprite("SpreadGunDroidDie");
u->weaponType = WPN_SPREAD;

View File

@ -36,7 +36,7 @@ void initCell(Entity *e)
STRNCPY(i->spriteName, "Battery", MAX_NAME_LENGTH);
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSpriteIndex("Battery");
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSprite("Battery");
i->spriteFrame = 0;
i->spriteTime = -1;

View File

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

View File

@ -37,7 +37,7 @@ void initHeart(Entity *e)
STRNCPY(i->spriteName, "Heart", MAX_NAME_LENGTH);
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSpriteIndex("Heart");
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSprite("Heart");
i->spriteFrame = 0;
i->spriteTime = -1;

View File

@ -23,7 +23,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 int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void updateObjective(char *targetName);
extern int rrnd(int low, int high);

View File

@ -48,7 +48,7 @@ void initItem(Entity *e)
i->canBeCarried = 0;
i->collected = 0;
i->sprite[FACING_LEFT] = i->sprite[FACING_RIGHT] = i->sprite[FACING_DIE] = getSpriteIndex(i->spriteName);
i->sprite[FACING_LEFT] = i->sprite[FACING_RIGHT] = i->sprite[FACING_DIE] = getSprite(i->spriteName);
i->tick = tick;
i->touch = touch;

View File

@ -24,7 +24,7 @@ extern void playSound(int snd, int ch);
extern void setGameplayMessage(int type, char *format, ...);
extern void addTeleportStars(Entity *e);
extern void initEntity(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void addBobItem(Item *i);
extern int numCarriedItems(void);
extern void addKey(char *name);

View File

@ -42,7 +42,7 @@ void initWeaponPickup(Entity *e)
i->weaponType = WPN_PISTOL;
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSpriteIndex("Weapon");
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSprite("Weapon");
i->spriteFrame = i->weaponType;
i->spriteTime = -1;

View File

@ -23,7 +23,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 initConsumable(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void pickupItem(void);
extern void setEntitySize(Entity *e);
extern int touchedPlayer(Entity *e);

View File

@ -41,7 +41,7 @@ void initDestructable(Entity *e)
s->health = s->healthMax = 10;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex(s->spriteName);
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite(s->spriteName);
s->applyDamage = applyDamage;
s->action = action;

View File

@ -25,7 +25,7 @@ extern void dropCarriedItem(void);
extern int rrnd(int low, int high);
extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void addScorchDecal(int x, int y);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void updateObjective(char *targetName);
extern void initEntity(Entity *e);

View File

@ -33,7 +33,7 @@ void initInfoPoint(Entity *e)
s->type = ET_INFO_POINT;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSpriteIndex("InfoPoint");
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("InfoPoint");
s->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_CLIP | EF_NO_ENVIRONMENT;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void initEntity(Entity *e);
extern void showInfoMessage(char *message);

View File

@ -41,11 +41,11 @@ void initCardReader(Entity *e)
if (!s->active)
{
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("CardReaderIdle");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("CardReaderIdle");
}
else
{
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("CardReader");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("CardReader");
}
s->tick = tick;
@ -81,7 +81,7 @@ static void touch(Entity *other)
removeItem(s->requiredItem);
s->active = 1;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("CardReader");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("CardReader");
s->spriteTime = 0;
s->spriteFrame = 0;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void removeItem(char *name);
extern int hasItem(char *name);
extern void setGameplayMessage(int type, char *format, ...);

View File

@ -49,7 +49,7 @@ void initDoor(Entity *e)
s->isLocked = 1;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSpriteIndex("Door");
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("Door");
if (s->closedX == -1 && s->closedY == -1)
{
@ -73,7 +73,7 @@ void initBronzeDoor(Entity *e)
s->speed = 2;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSpriteIndex("BronzeDoor");
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("BronzeDoor");
}
void initSilverDoor(Entity *e)
@ -88,7 +88,7 @@ void initSilverDoor(Entity *e)
s->speed = 2;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSpriteIndex("SilverDoor");
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("SilverDoor");
}
void initGoldDoor(Entity *e)
@ -103,7 +103,7 @@ void initGoldDoor(Entity *e)
s->speed = 2;
s->sprite[0] = s->sprite[1] = e->sprite[2] = getSpriteIndex("GoldDoor");
s->sprite[0] = s->sprite[1] = e->sprite[2] = getSprite("GoldDoor");
}
static void tick(void)

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void playSound(int snd, int ch);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void setGameplayMessage(int type, char *format, ...);

View File

@ -25,17 +25,15 @@ static void action(void);
static void touch(Entity *other);
static SDL_Rect *getBounds(void);
void initExit(Entity *e)
void initExit(void)
{
Structure *s;
initEntity(e);
s = (Structure*)e;
s = createStructure();
s->type = ET_EXIT;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("Exit");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("Exit");
s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS;

View File

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

View File

@ -26,7 +26,7 @@ void initHorizontalDoor(Entity *e)
e->type = ET_DOOR;
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSpriteIndex("HorizonalDoor");
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSprite("HorizonalDoor");
}
void initBronzeHorizontalDoor(Entity *e)

View File

@ -21,4 +21,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initDoor(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);

View File

@ -37,11 +37,11 @@ void initItemPad(Entity *e)
if (!e->active)
{
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("ItemPadActive");
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSprite("ItemPadActive");
}
else
{
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("ItemPadInactive");
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSprite("ItemPadInactive");
}
e->tick = tick;
@ -83,7 +83,7 @@ static void touch(Entity *other)
setGameplayMessage(MSG_GAMEPLAY, _("%s removed"), s->requiredItem);
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("ItemPadActive");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("ItemPadActive");
s->spriteFrame = 0;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void updateObjective(char *targetName);
extern void setGameplayMessage(int type, char *format, ...);
extern void removeItem(char *name);

View File

@ -43,7 +43,7 @@ void initLift(Entity *e)
s->startX = s->startY = -1;
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSpriteIndex("Lift");
s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("Lift");
s->active = 1;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initEntity(Entity *e);
extern int getSpriteIndex(char *name);
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);

View File

@ -34,7 +34,7 @@ void initPowerPoint(Entity *e)
s->type = ET_POWER_POINT;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("PowerPoint");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("PowerPoint");
s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS;

View File

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

View File

@ -34,7 +34,7 @@ void initPowerPool(Entity *e)
s->type = ET_POOL;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("PowerPool");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("PowerPool");
s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_IGNORE_BULLETS;

View File

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

View File

@ -33,7 +33,7 @@ void initPressurePlate(Entity *e)
s->type = ET_PRESSURE_PLATE;
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSpriteIndex("PressurePlate");
s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("PressurePlate");
s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS;

View File

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

View File

@ -0,0 +1,33 @@
/*
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 "structures.h"
Structure *createStructure(void)
{
Structure *s;
s = malloc(sizeof(Structure));
memset(s, 0, sizeof(Structure));
world.entityTail->next = (Entity*)s;
world.entityTail = (Entity*)s;
return s;
}

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 Structure *createStructure(void);
extern World world;

View File

@ -26,5 +26,5 @@ void initHorizontalLaserTrap(Entity *e)
e->type = ET_TRAP;
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSpriteIndex("HorizontalLaserTrap");
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSprite("HorizontalLaserTrap");
}

View File

@ -21,4 +21,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initLaserTrap(Entity *e);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);

View File

@ -41,7 +41,7 @@ void initLaserTrap(Entity *e)
t->onTime = FPS * 2;
t->offTime = FPS * 2;
t->sprite[0] = t->sprite[1] = t->sprite[2] = getSpriteIndex("LaserTrap");
t->sprite[0] = t->sprite[1] = t->sprite[2] = getSprite("LaserTrap");
t->active = 1;

View File

@ -24,7 +24,7 @@ extern void initEntity(Entity *e);
extern void observeActivation(Entity *e);
extern int isOnScreen(Entity *e);
extern void setGameplayMessage(int type, char *format, ...);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern int rrnd(int low, int high);
extern void stunBob(void);
extern void addSparkParticles(float x, float y);

View File

@ -122,7 +122,7 @@ struct Entity {
int environment;
int thinkTime;
int facing;
int sprite[3];
Sprite *sprite[3];
int plane;
int isSolid;
int isStatic;
@ -144,7 +144,7 @@ struct Entity {
void (*activate)(int active);
void (*applyDamage)(int amount);
void (*changeEnvironment)(void);
int (*getCurrentSprite)(void);
Sprite *(*getCurrentSprite)(void);
int (*preSave)(void);
SDL_Rect *(*getBounds)(void);
Entity *next;
@ -355,7 +355,7 @@ typedef struct {
} Game;
struct Marker {
int sprite;
Sprite *sprite;
float value;
float y;
Marker *next;
@ -402,8 +402,8 @@ struct Particle {
float r;
float g;
float b;
int spriteIndex;
double spriteTime;
Sprite *spriteIndex;
float spriteTime;
int spriteFrame;
int destroyAfterAnim;
int onScreen;

View File

@ -25,7 +25,6 @@ static void loadGameSprites(void);
static void loadSpriteList(char *filename);
void loadSprite(cJSON *root);
static Tuple spriteMapHead;
static Sprite spriteHead;
static Sprite *spriteTail;
@ -37,42 +36,6 @@ void initSprites(void)
loadGameSprites();
}
int getSpriteIndex(char *key)
{
Tuple *t;
for (t = spriteMapHead.next ; t != NULL ; t = t->next)
{
if (strcmp(t->key, key) == 0)
{
return t->value.i;
}
}
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "No such sprite '%s'", key);
exit(1);
return -1;
}
Sprite *getSpriteByIndex(int x)
{
Sprite *s;
int i;
for (s = spriteHead.next ; s != NULL ; s = s->next)
{
if (i == x)
{
return s;
}
i++;
}
return NULL;
}
Sprite *getSprite(char *name)
{
Sprite *s;
@ -101,14 +64,6 @@ void animateSprites(void)
}
}
void addSpriteFrame(Sprite *s, SDL_Rect frame, int time)
{
s->frames[s->numFrames] = frame;
s->times[s->numFrames] = time;
s->numFrames++;
}
static void animateSprite(Sprite *s)
{
if (s->currentTime != -1)
@ -210,8 +165,3 @@ void loadSprite(cJSON *root)
void destroySprites(void)
{
}
void addSpriteFrames(Sprite *sprite, cJSON *root)
{
}

View File

@ -20,25 +20,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "effects.h"
static int fleshChunk[3];
static int debris[3];
static Sprite *fleshChunk[3];
static Sprite *debris[3];
void initEffects(void)
{
fleshChunk[0] = getSpriteIndex("FleshChunk1");
fleshChunk[1] = getSpriteIndex("FleshChunk2");
fleshChunk[2] = getSpriteIndex("FleshChunk3");
fleshChunk[0] = getSprite("FleshChunk1");
fleshChunk[1] = getSprite("FleshChunk2");
fleshChunk[2] = getSprite("FleshChunk3");
debris[0] = getSpriteIndex("Debris1");
debris[1] = getSpriteIndex("Debris2");
debris[2] = getSpriteIndex("Debris3");
debris[0] = getSprite("Debris1");
debris[1] = getSprite("Debris2");
debris[2] = getSprite("Debris3");
}
void addExplosionEffect(int x, int y, float dx, float dy)
{
}
void addSmallFleshChunk(double x, double y)
void addSmallFleshChunk(float x, float y)
{
Decoration *chunk;
@ -55,7 +55,7 @@ void addSmallFleshChunk(double x, double y)
chunk->sprite[0] = chunk->sprite[1] = chunk->sprite[2] = fleshChunk[0];
}
void throwFleshChunks(double x, double y, int amount)
void throwFleshChunks(float x, float y, int amount)
{
int i;
Decoration *chunk;

View File

@ -21,6 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h"
extern int rrnd(int low, int high);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern World world;

View File

@ -23,21 +23,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void throwItem(Item *i);
static int getRandomPlayerWeaponAt(int x, int y);
static int wpnIconSprite;
static int cherrySprite[3];
static int batterySprite;
static Sprite *wpnIconSprite;
static Sprite *cherrySprite[3];
static Sprite *batterySprite;
void initItems(void)
{
wpnIconSprite = getSpriteIndex("Weapon");
batterySprite = getSpriteIndex("Battery");
wpnIconSprite = getSprite("Weapon");
batterySprite = getSprite("Battery");
cherrySprite[0] = getSpriteIndex("Cherry");
cherrySprite[1] = getSpriteIndex("DualCherry");
cherrySprite[2] = getSpriteIndex("CherryBunch");
cherrySprite[0] = getSprite("Cherry");
cherrySprite[1] = getSprite("DualCherry");
cherrySprite[2] = getSprite("CherryBunch");
}
void addRandomWeapon(double x, double y)
void addRandomWeapon(float x, float y)
{
Item *wpn;
int type;
@ -87,10 +87,10 @@ static int getRandomPlayerWeaponAt(int x, int y)
return type;
}
void dropRandomCherry(double x, double y)
void dropRandomCherry(float x, float y)
{
Item *i;
double r;
int r;
i = malloc(sizeof(Item));
memset(i, 0, sizeof(Item));
@ -124,10 +124,10 @@ void dropRandomCherry(double x, double y)
throwItem(i);
}
void dropBattery(double x, double y)
void dropBattery(float x, float y)
{
Item *i;
double r;
int r;
i = malloc(sizeof(Item));
memset(i, 0, sizeof(Item));

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int rrnd(int low, int high);
extern int getRandomPlayerWeapon(int excludeGrenades);
extern int getSpriteIndex(char *name);
extern Sprite *getSprite(char *name);
extern void addRandomItems(float x, float y);
extern World world;

View File

@ -23,25 +23,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void animate(Particle *p);
static Particle *createParticle(void);
static int bloodSprite[3];
static int explosionSprite[2];
static int flameSprite;
static int smokeSprite;
static int teleportStarSprite;
static Sprite *bloodSprite[3];
static Sprite *explosionSprite[2];
static Sprite *flameSprite;
static Sprite *smokeSprite;
static Sprite *teleportStarSprite;
void initParticles(void)
{
bloodSprite[0] = getSpriteIndex("Blood1");
bloodSprite[1] = getSpriteIndex("Blood2");
bloodSprite[2] = getSpriteIndex("Blood3");
bloodSprite[0] = getSprite("Blood1");
bloodSprite[1] = getSprite("Blood2");
bloodSprite[2] = getSprite("Blood3");
explosionSprite[0] = getSpriteIndex("Explosion1");
explosionSprite[1] = getSpriteIndex("Explosion2");
explosionSprite[0] = getSprite("Explosion1");
explosionSprite[1] = getSprite("Explosion2");
flameSprite = getSpriteIndex("Flame");
smokeSprite = getSpriteIndex("Smoke");
flameSprite = getSprite("Flame");
smokeSprite = getSprite("Smoke");
teleportStarSprite = getSpriteIndex("TeleportStar");
teleportStarSprite = getSprite("TeleportStar");
}
void addBlood(float x, float y)
@ -239,19 +239,7 @@ void doParticles(void)
static void animate(Particle *p)
{
Sprite *s;
if (p->spriteTime != -1)
{
p->spriteTime--;
if (p->spriteTime <= 0)
{
s = getSprite(p->spriteIndex);
p->spriteFrame = (int) wrap(++p->spriteFrame, 0, s->numFrames);
p->spriteTime = s->times[p->spriteFrame];
}
}
}
static Particle *createParticle(void)

View File

@ -20,8 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h"
extern Sprite *getSprite(int i);
extern int getSpriteIndex(char *name);
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);