Removed Fighter struct and replaced with Entity.

This commit is contained in:
Steve 2015-10-26 19:16:12 +00:00
parent 73eb5517bf
commit 705a2cebe9
29 changed files with 357 additions and 359 deletions

View File

@ -29,8 +29,8 @@ static int aggression[][5] =
{5, 10, 15, 20, 25}
};
static void faceTarget(Fighter *f);
static int isInFOV(Fighter *f, int fov);
static void faceTarget(Entity *f);
static int isInFOV(Entity *f, int fov);
static void preAttack(void);
static void huntTarget(void);
static void huntAndAttackTarget(void);
@ -43,7 +43,7 @@ static void boost(void);
static void slow(void);
static int targetOutOfRange(void);
static void moveToPlayer(void);
static int canAttack(Fighter *f);
static int canAttack(Entity *f);
static int selectWeapon(int type);
void doAI(void)
@ -142,13 +142,13 @@ static void huntAndAttackTarget(void)
static void findTarget(void)
{
Fighter *f;
Entity *f;
int closest = 2000;
int dist = 2000;
self->target = NULL;
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (f->side != self->side && f->health > 0 && canAttack(f))
{
@ -162,11 +162,11 @@ static void findTarget(void)
}
}
static int canAttack(Fighter *f)
static int canAttack(Entity *f)
{
self->selectedGunType = self->guns[0].type;
if (f->flags & FF_DISABLE)
if (f->flags & EF_DISABLE)
{
if (f->systemPower > 0)
{
@ -176,7 +176,7 @@ static int canAttack(Fighter *f)
return 0;
}
if (f->flags & FF_NO_KILL)
if (f->flags & EF_NO_KILL)
{
return selectWeapon(BT_LASER) || selectWeapon(BT_MAG);
}
@ -200,7 +200,7 @@ static int selectWeapon(int type)
return 0;
}
static void faceTarget(Fighter *f)
static void faceTarget(Entity *f)
{
int dir;
int wantedAngle = getAngle(self->x, self->y, f->x, f->y);
@ -209,7 +209,7 @@ static void faceTarget(Fighter *f)
if (fabs(wantedAngle - self->angle) > TURN_THRESHOLD)
{
dir = (wantedAngle - self->angle + 360) % 360 > 180 ? -1 : 1;
dir = ((int)(wantedAngle - self->angle + 360)) % 360 > 180 ? -1 : 1;
self->angle += dir * TURN_SPEED;
@ -219,7 +219,7 @@ static void faceTarget(Fighter *f)
}
}
static int isInFOV(Fighter *f, int fov)
static int isInFOV(Entity *f, int fov)
{
int angle, a, b;
@ -249,13 +249,13 @@ static void slow(void)
static int hasClearShot(void)
{
int dist;
Fighter *f;
Entity *f;
if (isInFOV(self->target, 4))
{
dist = getDistance(self->x, self->y, self->target->x, self->target->y);
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (f != self && f != self->target && (getDistance(self->x, self->y, f->x, f->y) < dist))
{
@ -296,7 +296,7 @@ static void dodge(void)
if (fabs(wantedAngle - self->angle) > TURN_THRESHOLD)
{
dir = (wantedAngle - self->angle + 360) % 360 > 180 ? -1 : 1;
dir = ((int)(wantedAngle - self->angle + 360)) % 360 > 180 ? -1 : 1;
self->angle += dir * TURN_SPEED;

View File

@ -28,11 +28,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int mod(int n, int x);
extern int getDistance(int x1, int y1, int x2, int y2);
extern void fireGuns(Fighter *owner);
extern void fireGuns(Entity *owner);
extern float getAngle(int x1, int y1, int x2, int y2);
extern void applyFighterThrust(void);
extern void applyFighterBrakes(void);
extern Battle battle;
extern Fighter *self;
extern Fighter *player;
extern Entity *self;
extern Entity *player;

View File

@ -42,7 +42,6 @@ void initBattle(void)
memset(&battle, 0, sizeof(Battle));
battle.bulletTail = &battle.bulletHead;
battle.entityTail = &battle.entityHead;
battle.fighterTail = &battle.fighterHead;
battle.effectTail = &battle.effectHead;
battle.objectiveTail = &battle.objectiveHead;
battle.triggerTail = &battle.triggerHead;
@ -118,8 +117,6 @@ static void doBattle(void)
doBullets();
doFighters();
doEntities();
doEffects();
@ -162,8 +159,6 @@ static void draw(void)
drawBullets();
drawFighters();
drawEntities();
drawEffects();
@ -320,21 +315,12 @@ static void postBattle(void)
void destroyBattle(void)
{
Fighter *f;
Entity *ent;
Bullet *b;
Effect *e;
Objective *o;
Trigger *t;
while (battle.fighterHead.next)
{
f = battle.fighterHead.next;
battle.fighterHead.next = f->next;
free(f);
}
battle.fighterTail = &battle.fighterHead;
while (battle.entityHead.next)
{
ent = battle.entityHead.next;

View File

@ -34,10 +34,8 @@ extern void doBullets(void);
extern void drawBullets(void);
extern void doStars(float dx, float dy);
extern void drawStars(void);
extern void doFighters(void);
extern void doEntities(void);
extern void drawEntities(void);
extern void drawFighters(void);
extern void initStars(void);
extern void doPlayer(void);
extern void drawHud(void);
@ -66,5 +64,5 @@ extern void checkTrigger(char *name, int type);
extern App app;
extern Battle battle;
extern Fighter *player;
extern Entity *player;
extern Game game;

View File

@ -94,12 +94,14 @@ void doBullets(void)
static void checkCollisions(Bullet *b)
{
Fighter *f;
Entity *f;
int bw, bh, ew, eh;
SDL_QueryTexture(b->texture, NULL, NULL, &bw, &bh);
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (f->type == ET_FIGHTER)
{
SDL_QueryTexture(f->texture, NULL, NULL, &ew, &eh);
@ -137,6 +139,7 @@ static void checkCollisions(Bullet *b)
return;
}
}
}
}
void drawBullets(void)
@ -213,7 +216,7 @@ static void huntTarget(Bullet *b)
}
}
Bullet *createBullet(int type, int x, int y, Fighter *owner)
Bullet *createBullet(int type, int x, int y, Entity *owner)
{
Bullet *b;
@ -238,7 +241,7 @@ Bullet *createBullet(int type, int x, int y, Fighter *owner)
return b;
}
void fireGuns(Fighter *owner)
void fireGuns(Entity *owner)
{
Bullet *b;
int i;
@ -272,7 +275,7 @@ void fireGuns(Fighter *owner)
playBattleSound(b->sound, owner->x, owner->y);
}
void fireMissile(Fighter *owner)
void fireMissile(Entity *owner)
{
Bullet *b;

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern SDL_Texture *getTexture(char *filename);
extern void blitRotated(SDL_Texture *texture, int x, int y, int angle);
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
extern void damageFighter(Fighter *f, int damage, long flags);
extern void damageFighter(Entity *f, int damage, long flags);
extern void playBattleSound(int id, int x, int y);
extern long flagsToLong(char *flags);
extern long lookup(char *name);
@ -41,4 +41,4 @@ extern int mod(int n, int x);
extern void addMissileExplosion(Bullet *b);
extern Battle battle;
extern Fighter *player;
extern Entity *player;

View File

@ -24,5 +24,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../structs.h"
extern Battle battle;
extern Fighter *player;
extern Entity *player;
extern Game game;

View File

@ -28,4 +28,4 @@ extern SDL_Texture *getTexture(char *name);
extern App app;
extern Battle battle;
extern Fighter *self;
extern Entity *self;

View File

@ -20,14 +20,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "entities.h"
static void drawEntity(Entity *e);
static void doEntity(Entity *e, Entity *prev);
void doEntities(void)
{
Entity *e, *prev;
prev = &battle.entityHead;
battle.numAllies = battle.numEnemies = 0;
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
self = e;
switch (e->type)
{
case ET_FIGHTER:
doFighter(e, prev);
break;
default:
doEntity(e, prev);
break;
}
}
}
static void doEntity(Entity *e, Entity *prev)
{
e->x += e->dx;
e->y += e->dy;
@ -44,13 +66,17 @@ void doEntities(void)
if (e->health <= 0)
{
if (e == battle.entityTail)
{
battle.entityTail = prev;
}
prev->next = e->next;
free(e);
e = prev;
}
prev = e;
}
}
void drawEntities(void)
@ -59,6 +85,20 @@ void drawEntities(void)
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
blitRotated(e->texture, e->x, e->y, e->angle);
switch (e->type)
{
case ET_FIGHTER:
drawFighter(e);
break;
default:
drawEntity(e);
break;
}
}
}
static void drawEntity(Entity *e)
{
blitRotated(e->texture, e->x, e->y, e->angle);
}

View File

@ -24,5 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../structs.h"
extern void blitRotated(SDL_Texture *t, int x, int y, int angle);
extern void drawFighter(Entity *e);
extern void doFighter(Entity *e, Entity *prev);
extern Battle battle;
extern Entity *self;

View File

@ -22,11 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void loadFighterDef(char *filename);
static Fighter defHead, *defTail;
static Entity defHead, *defTail;
Fighter *getFighterDef(char *name)
Entity *getFighterDef(char *name)
{
Fighter *f;
Entity *f;
for (f = defHead.next ; f != NULL ; f = f->next)
{
@ -48,7 +48,7 @@ void loadFighterDefs(void)
text = readFile("data/fighters/list.json");
root = cJSON_Parse(text);
memset(&defHead, 0, sizeof(Fighter));
memset(&defHead, 0, sizeof(Entity));
defTail = &defHead;
for (node = root->child ; node != NULL ; node = node->next)
@ -64,15 +64,15 @@ static void loadFighterDef(char *filename)
{
cJSON *root, *node;
char *text;
Fighter *f;
Entity *f;
int i, w, h;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
text = readFile(filename);
f = malloc(sizeof(Fighter));
memset(f, 0, sizeof(Fighter));
f = malloc(sizeof(Entity));
memset(f, 0, sizeof(Entity));
defTail->next = f;
defTail = f;
@ -127,7 +127,7 @@ static void loadFighterDef(char *filename)
void destroyFighterDefs(void)
{
Fighter *f;
Entity *f;
while (defHead.next)
{

View File

@ -25,24 +25,24 @@ static void die(void);
static void immediateDie(void);
static void spinDie(void);
static void straightDie(void);
static void randomizeDart(Fighter *dart);
static void randomizeDartGuns(Fighter *dart);
static void randomizeDart(Entity *dart);
static void randomizeDartGuns(Entity *dart);
Fighter *spawnFighter(char *name, int x, int y, int side)
Entity *spawnFighter(char *name, int x, int y, int side)
{
Fighter *f, *def;
Entity *f, *def;
f = malloc(sizeof(Fighter));
memset(f, 0, sizeof(Fighter));
f = malloc(sizeof(Entity));
memset(f, 0, sizeof(Entity));
def = getFighterDef(name);
memcpy(f, def, sizeof(Fighter));
memcpy(f, def, sizeof(Entity));
f->next = NULL;
battle.fighterTail->next = f;
battle.fighterTail = f;
battle.entityTail->next = f;
battle.entityTail = f;
f->x = x;
f->y = y;
@ -79,7 +79,7 @@ Fighter *spawnFighter(char *name, int x, int y, int side)
return f;
}
static void randomizeDart(Fighter *dart)
static void randomizeDart(Entity *dart)
{
char textureName[MAX_DESCRIPTION_LENGTH];
@ -111,7 +111,7 @@ static void randomizeDart(Fighter *dart)
dart->texture = getTexture(textureName);
}
static void randomizeDartGuns(Fighter *dart)
static void randomizeDartGuns(Entity *dart)
{
int i;
@ -153,18 +153,8 @@ static void randomizeDartGuns(Fighter *dart)
}
}
void doFighters(void)
void doFighter(Entity *f, Entity *prev)
{
Fighter *f, *prev;
battle.numAllies = battle.numEnemies = 0;
prev = &battle.fighterHead;
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
{
self = f;
if (player != NULL)
{
if (f != player && f->health > 0)
@ -188,7 +178,7 @@ void doFighters(void)
self->target = NULL;
}
if (!battle.missionTarget && f->flags & FF_MISSION_TARGET && f->health > 0)
if (!battle.missionTarget && f->flags & EF_MISSION_TARGET && f->health > 0)
{
battle.missionTarget = f;
}
@ -294,9 +284,9 @@ void doFighters(void)
checkTrigger(f->name, TRIGGER_KILLS);
}
if (f == battle.fighterTail)
if (f == battle.entityTail)
{
battle.fighterTail = prev;
battle.entityTail = prev;
}
if (f == player)
@ -308,9 +298,6 @@ void doFighters(void)
free(f);
f = prev;
}
prev = f;
}
}
static void separate(void)
@ -319,13 +306,13 @@ static void separate(void)
int distance;
float dx, dy, force;
int count;
Fighter *f;
Entity *f;
dx = dy = 0;
count = 0;
force = 0;
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (f != self)
{
@ -357,41 +344,38 @@ static void separate(void)
}
}
void drawFighters(void)
void drawFighter(Entity *e)
{
Fighter *f;
SDL_Rect r;
SDL_Texture *shieldHitTexture = getTexture("gfx/battle/shieldHit.png");
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
{
SDL_SetTextureColorMod(f->texture, 255, 255, 255);
SDL_SetTextureColorMod(e->texture, 255, 255, 255);
if (f->armourHit > 0)
if (e->armourHit > 0)
{
SDL_SetTextureColorMod(f->texture, 255, 255 - f->armourHit, 255 - f->armourHit);
SDL_SetTextureColorMod(e->texture, 255, 255 - e->armourHit, 255 - e->armourHit);
}
if (f->systemHit > 0)
if (e->systemHit > 0)
{
SDL_SetTextureColorMod(f->texture, 255 - f->systemHit, 255, 255);
SDL_SetTextureColorMod(e->texture, 255 - e->systemHit, 255, 255);
}
blitRotated(f->texture, f->x, f->y, f->angle);
blitRotated(e->texture, e->x, e->y, e->angle);
if (f->shieldHit > 0)
if (e->shieldHit > 0)
{
SDL_SetTextureBlendMode(shieldHitTexture, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(shieldHitTexture, f->shieldHit);
blit(shieldHitTexture, f->x, f->y, 1);
SDL_SetTextureAlphaMod(shieldHitTexture, e->shieldHit);
blit(shieldHitTexture, e->x, e->y, 1);
}
if (player != NULL)
{
if (f == player->target)
if (e == player->target)
{
r.x = f->x - 32;
r.y = f->y - 32;
r.x = e->x - 32;
r.y = e->y - 32;
r.w = 64;
r.h = 64;
@ -399,10 +383,10 @@ void drawFighters(void)
SDL_RenderDrawRect(app.renderer, &r);
}
if (f == battle.missionTarget)
if (e == battle.missionTarget)
{
r.x = f->x - 28;
r.y = f->y - 28;
r.x = e->x - 28;
r.y = e->y - 28;
r.w = 56;
r.h = 56;
@ -410,7 +394,6 @@ void drawFighters(void)
SDL_RenderDrawRect(app.renderer, &r);
}
}
}
}
void applyFighterThrust(void)
@ -437,7 +420,7 @@ void applyFighterBrakes(void)
self->thrust = sqrt((self->dx * self->dx) + (self->dy * self->dy));
}
void damageFighter(Fighter *f, int amount, long flags)
void damageFighter(Entity *f, int amount, long flags)
{
if (flags & BF_SYSTEM_DAMAGE)
{

View File

@ -35,12 +35,12 @@ extern void addSmallFighterExplosion(void);
extern void playBattleSound(int id, int x, int y);
extern void updateObjective(char *name, int type);
extern void updateCondition(char *name, int type);
extern Fighter *getFighterDef(char *name);
extern Entity *getFighterDef(char *name);
extern void addHudMessage(SDL_Color c, char *format, ...);
extern void checkTrigger(char *name, int type);
extern App app;
extern Battle battle;
extern Colors colors;
extern Fighter *player;
extern Fighter *self;
extern Entity *player;
extern Entity *self;

View File

@ -36,4 +36,4 @@ extern void drawRadar(void);
extern App app;
extern Battle battle;
extern Colors colors;
extern Fighter *player;
extern Entity *player;

View File

@ -102,7 +102,7 @@ void doPlayer(void)
}
}
player->angle = player->angle % 360;
player->angle = ((int)player->angle) % 360;
player->x = SCREEN_WIDTH / 2;
player->y = SCREEN_HEIGHT / 2;
@ -136,13 +136,13 @@ static void selectTarget(void)
{
unsigned int closest = 65535;
unsigned int dist = 65535;
Fighter *f;
Entity *f;
player->target = NULL;
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (f != player && f->side != player->side && f->alive == ALIVE_ALIVE)
if (f != player && f->side != SIDE_NONE && f->side != player->side && f->alive == ALIVE_ALIVE)
{
dist = getDistance(self->x, self->y, f->x, f->y);
if (dist < closest)

View File

@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../defs.h"
#include "../structs.h"
extern void fireGuns(Fighter *owner);
extern void fireMissile(Fighter *owner);
extern void fireGuns(Entity *owner);
extern void fireMissile(Entity *owner);
extern void applyFighterThrust(void);
extern void applyFighterBrakes(void);
extern int getDistance(int x1, int y1, int x2, int y2);
@ -32,5 +32,5 @@ extern void failIncompleteObjectives(void);
extern App app;
extern Battle battle;
extern Fighter *player;
extern Fighter *self;
extern Entity *player;
extern Entity *self;

View File

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void drawRadar(void)
{
SDL_Rect r;
Fighter *f;
Entity *f;
drawFilledCircle(SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 75, 0, 128, 0, 32);
@ -34,7 +34,7 @@ void drawRadar(void)
r.w = r.h = 3;
for (f = battle.fighterHead.next ; f != NULL ; f = f->next)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (getDistance(f->x, f->y, player->x, player->y) / RADAR_RANGE < 70)
{

View File

@ -29,4 +29,4 @@ extern int getDistance(int x1, int y1, int x2, int y2);
extern App app;
extern Battle battle;
extern Fighter *player;
extern Entity *player;

View File

@ -29,6 +29,7 @@ Entity *spawnWaypoint(void)
battle.entityTail->next = waypoint;
battle.entityTail = waypoint;
waypoint->type = ET_WAYPOINT;
waypoint->health = waypoint->maxHealth = FPS;
waypoint->texture = getTexture("gfx/entities/waypoint.png");
waypoint->action = rotate;
@ -38,5 +39,9 @@ Entity *spawnWaypoint(void)
static void rotate(void)
{
self->angle += 0.1;
if (self->angle >= 360)
{
self -= 360;
}
}

View File

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../defs.h"
#include "../structs.h"
extern Battle battle;
extern SDL_Texture *getTexture(char *filename);
extern Battle battle;
extern Entity *self;

View File

@ -51,14 +51,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define BF_SYSTEM_DAMAGE (2 << 1)
#define BF_EXPLODES (2 << 2)
#define FF_NONE 0
#define FF_NO_KILL (2 << 0)
#define FF_DISABLE (2 << 1)
#define FF_IMMORTAL (2 << 2)
#define FF_MISSION_TARGET (2 << 3)
#define EF_NONE 0
#define EF_NO_KILL (2 << 0)
#define EF_DISABLE (2 << 1)
#define EF_IMMORTAL (2 << 2)
#define EF_MISSION_TARGET (2 << 3)
enum
{
ET_FIGHTER,
ET_WAYPOINT
};

View File

@ -174,7 +174,7 @@ static void loadPlayer(cJSON *node)
static void loadFighters(cJSON *node)
{
Fighter *f;
Entity *f;
char *type;
int side, x, y;
@ -205,7 +205,7 @@ static void loadFighters(cJSON *node)
static void loadFighterGroups(cJSON *node)
{
Fighter *f;
Entity *f;
char **types, *name, *type;
int side, x, y, scatter, number;
int i, numTypes;

View File

@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern long lookup(char *name);
extern char *readFile(char *filename);
extern SDL_Texture *getTexture(char *filename);
extern Fighter *spawnFighter(char *name, int x, int y, int side);
extern Entity *spawnFighter(char *name, int x, int y, int side);
extern void startSectionTransition(void);
extern void endSectionTransition(void);
extern void playMusic(char *filename);
@ -38,5 +38,5 @@ extern long flagsToLong(char *flags);
extern Entity *spawnWaypoint(void);
extern Battle battle;
extern Fighter *player;
extern Entity *player;
extern Game game;

View File

@ -37,7 +37,7 @@ static SDL_Texture *logo;
static SDL_Texture *pandoranWar;
static SDL_Texture *earthTexture;
static PointF earth;
static Fighter fighters[NUM_FIGHTERS];
static Entity fighters[NUM_FIGHTERS];
static const char *fighterTextures[] = {"gfx/fighters/firefly.png", "gfx/fighters/hammerhead.png", "gfx/fighters/hyena.png", "gfx/fighters/khepri.png", "gfx/fighters/kingfisher.png", "gfx/fighters/leopard.png", "gfx/fighters/nymph.png", "gfx/fighters/ray.png", "gfx/fighters/rook.png", "gfx/fighters/taf.png"};
static int showingOptions;
@ -99,7 +99,7 @@ static void initFighters(void)
numTextures = sizeof(fighterTextures) / sizeof(char*);
memset(&fighters, 0, sizeof(Fighter) * NUM_FIGHTERS);
memset(&fighters, 0, sizeof(Entity) * NUM_FIGHTERS);
for (i = 0 ; i < NUM_FIGHTERS ; i++)
{

View File

@ -60,4 +60,4 @@ extern App app;
extern Battle battle;
extern Colors colors;
extern Game game;
extern Fighter *self;
extern Entity *self;

View File

@ -35,6 +35,6 @@ extern void saveScreenshot(void);
App app;
Colors colors;
Battle battle;
Fighter *self;
Fighter *player;
Entity *self;
Entity *player;
Game game;

View File

@ -22,7 +22,6 @@ typedef struct SDL_Texture SDL_Texture;
typedef struct Texture Texture;
typedef struct Lookup Lookup;
typedef struct Weapon Weapon;
typedef struct Fighter Fighter;
typedef struct Entity Entity;
typedef struct Bullet Bullet;
typedef struct Effect Effect;
@ -71,26 +70,6 @@ struct Weapon {
struct Entity {
int type;
char name[MAX_NAME_LENGTH];
int side;
float x;
float y;
float dx;
float dy;
int angle;
int health;
int maxHealth;
int shield;
int thinkTime;
long flags;
void (*action)(void);
void (*defaultAction)(void);
void (*die)(void);
SDL_Texture *texture;
Entity *next;
};
struct Fighter {
char name[MAX_NAME_LENGTH];
int active;
int side;
@ -100,7 +79,7 @@ struct Fighter {
float dy;
float thrust;
float speed;
int angle;
float angle;
int alive;
int health;
int maxHealth;
@ -122,12 +101,12 @@ struct Fighter {
Weapon guns[MAX_FIGHTER_GUNS];
Weapon missiles;
long flags;
Fighter *target;
Entity *target;
void (*action)(void);
void (*defaultAction)(void);
void (*die)(void);
SDL_Texture *texture;
Fighter *next;
Entity *next;
};
struct Bullet {
@ -142,8 +121,8 @@ struct Bullet {
int angle;
long flags;
SDL_Texture *texture;
Fighter *owner;
Fighter *target;
Entity *owner;
Entity *target;
Bullet *next;
};
@ -241,10 +220,9 @@ typedef struct {
int status;
int missionFinishedTimer;
int numObjectivesComplete, numObjectivesTotal;
Fighter *missionTarget;
Entity *missionTarget;
SDL_Texture *background, *planetTexture;
PointF planet;
Fighter fighterHead, *fighterTail;
Entity entityHead, *entityTail;
Bullet bulletHead, *bulletTail;
Effect effectHead, *effectTail;

View File

@ -32,10 +32,10 @@ void initLookups(void)
addLookup("ET_WAYPOINT", ET_WAYPOINT);
addLookup("FF_NO_KILL", FF_NO_KILL);
addLookup("FF_DISABLE", FF_DISABLE);
addLookup("FF_IMMORTAL", FF_IMMORTAL);
addLookup("FF_MISSION_TARGET", FF_MISSION_TARGET);
addLookup("EF_NO_KILL", EF_NO_KILL);
addLookup("EF_DISABLE", EF_DISABLE);
addLookup("EF_IMMORTAL", EF_IMMORTAL);
addLookup("EF_MISSION_TARGET", EF_MISSION_TARGET);
addLookup("TT_DESTROY", TT_DESTROY);
addLookup("TT_DISABLE", TT_DISABLE);

View File

@ -29,4 +29,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int getDistance(int x1, int y1, int x2, int y2);
extern Fighter *player;
extern Entity *player;