Draw jumpgate portal in jumpgate.c. Use systemPower instead of ALIVE_SLEEPING to determine status.
This commit is contained in:
parent
5267b7b559
commit
7118c10648
|
@ -421,7 +421,7 @@ static void loadComponents(Entity *parent, cJSON *components)
|
|||
e->aiFlags = flagsToLong(cJSON_GetObjectItem(component, "aiFlags")->valuestring, NULL);
|
||||
}
|
||||
|
||||
e->systemPower = 100;
|
||||
e->systemPower = MAX_SYSTEM_POWER;
|
||||
|
||||
e->die = componentDie;
|
||||
|
||||
|
@ -475,7 +475,7 @@ static void loadGuns(Entity *parent, cJSON *guns)
|
|||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
|
||||
e->systemPower = 100;
|
||||
e->systemPower = MAX_SYSTEM_POWER;
|
||||
|
||||
e->action = gunThink;
|
||||
e->die = gunDie;
|
||||
|
@ -518,7 +518,7 @@ static void loadEngines(Entity *parent, cJSON *engines)
|
|||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
|
||||
e->systemPower = 100;
|
||||
e->systemPower = MAX_SYSTEM_POWER;
|
||||
|
||||
e->action = engineThink;
|
||||
e->die = engineDie;
|
||||
|
|
|
@ -31,8 +31,6 @@ static int drawComparator(const void *a, const void *b);
|
|||
static void notifyNewArrivals(void);
|
||||
static int isCapitalShipComponent(Entity *e);
|
||||
|
||||
static SDL_Texture *jumpPortal;
|
||||
static float jumpPortAngle;
|
||||
static Entity deadHead;
|
||||
static Entity *deadTail;
|
||||
static int disabledGlow;
|
||||
|
@ -46,9 +44,6 @@ void initEntities(void)
|
|||
|
||||
disabledGlow = DISABLED_GLOW_MAX;
|
||||
disabledGlowDir = -DISABLED_GLOW_SPEED;
|
||||
|
||||
jumpPortal = getTexture("gfx/entities/portal.png");
|
||||
jumpPortAngle = 0;
|
||||
}
|
||||
|
||||
Entity *spawnEntity(void)
|
||||
|
@ -139,7 +134,7 @@ void doEntities(void)
|
|||
break;
|
||||
}
|
||||
|
||||
if (e->alive == ALIVE_ALIVE || e->alive == ALIVE_DYING || e->alive == ALIVE_SLEEPING)
|
||||
if (e->alive == ALIVE_ALIVE || e->alive == ALIVE_DYING)
|
||||
{
|
||||
if (e->action != NULL)
|
||||
{
|
||||
|
@ -257,12 +252,6 @@ void doEntities(void)
|
|||
{
|
||||
disabledGlowDir = -DISABLED_GLOW_SPEED;
|
||||
}
|
||||
|
||||
jumpPortAngle += 0.5;
|
||||
if (jumpPortAngle >= 360)
|
||||
{
|
||||
jumpPortAngle -= 360;
|
||||
}
|
||||
}
|
||||
|
||||
static void restrictToBattleArea(Entity *e)
|
||||
|
@ -378,7 +367,13 @@ void drawEntities(void)
|
|||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
{
|
||||
if (e->active)
|
||||
self = e;
|
||||
|
||||
if (e->draw)
|
||||
{
|
||||
e->draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
drawEntity(e);
|
||||
}
|
||||
|
@ -391,11 +386,6 @@ void drawEntities(void)
|
|||
|
||||
static void drawEntity(Entity *e)
|
||||
{
|
||||
if (e->type == ET_JUMPGATE && e->alive == ALIVE_ALIVE)
|
||||
{
|
||||
blitRotated(jumpPortal, e->x - battle.camera.x, e->y - battle.camera.y, jumpPortAngle);
|
||||
}
|
||||
|
||||
SDL_SetTextureColorMod(e->texture, 255, 255, 255);
|
||||
|
||||
if (e->armourHit > 0)
|
||||
|
@ -494,6 +484,11 @@ void activateEntityGroups(char *groupNames)
|
|||
if (strcmp(e->groupName, groupName) == 0)
|
||||
{
|
||||
e->active = 1;
|
||||
|
||||
if (e->type == ET_CAPITAL_SHIP)
|
||||
{
|
||||
updateCapitalShipComponentProperties(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -715,8 +715,7 @@ static void loadFighterDef(char *filename)
|
|||
|
||||
e->separationRadius = MAX(e->w, e->h) * 3;
|
||||
|
||||
/* all craft default to 100 system power */
|
||||
e->systemPower = 100;
|
||||
e->systemPower = MAX_SYSTEM_POWER;
|
||||
|
||||
cJSON_Delete(root);
|
||||
}
|
||||
|
|
|
@ -21,9 +21,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "jumpgate.h"
|
||||
|
||||
static void think(void);
|
||||
static void draw(void);
|
||||
static void handleFleeingEntities(void);
|
||||
static void addEscapeEffect(Entity *ent);
|
||||
|
||||
static SDL_Texture *portal;
|
||||
static float portalAngle;
|
||||
|
||||
Entity *spawnJumpgate(void)
|
||||
{
|
||||
Entity *jumpgate = spawnEntity();
|
||||
|
@ -32,8 +36,12 @@ Entity *spawnJumpgate(void)
|
|||
jumpgate->health = jumpgate->maxHealth = FPS;
|
||||
jumpgate->texture = getTexture("gfx/entities/jumpgate.png");
|
||||
jumpgate->action = think;
|
||||
jumpgate->draw = draw;
|
||||
jumpgate->flags |= EF_NO_MT_BOX;
|
||||
|
||||
portal = getTexture("gfx/entities/portal.png");
|
||||
portalAngle = 0;
|
||||
|
||||
return jumpgate;
|
||||
}
|
||||
|
||||
|
@ -47,12 +55,24 @@ static void think(void)
|
|||
self->angle -= 360;
|
||||
}
|
||||
|
||||
if (self->alive == ALIVE_ALIVE)
|
||||
if (self->systemPower)
|
||||
{
|
||||
handleFleeingEntities();
|
||||
}
|
||||
|
||||
if (!battle.jumpgate)
|
||||
{
|
||||
battle.jumpgate = self;
|
||||
}
|
||||
|
||||
if (battle.jumpgate == self)
|
||||
{
|
||||
portalAngle += 0.5;
|
||||
if (portalAngle >= 360)
|
||||
{
|
||||
portalAngle -= 360;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handleFleeingEntities(void)
|
||||
|
@ -105,3 +125,13 @@ static void addEscapeEffect(Entity *ent)
|
|||
e->health = speed;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw(void)
|
||||
{
|
||||
if (self->systemPower)
|
||||
{
|
||||
blitRotated(portal, self->x - battle.camera.x, self->y - battle.camera.y, portalAngle);
|
||||
}
|
||||
|
||||
blitRotated(self->texture, self->x - battle.camera.x, self->y - battle.camera.y, self->angle);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ extern Entity *spawnEntity(void);
|
|||
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
extern void playBattleSound(int id, int x, int y);
|
||||
extern void blitRotated(SDL_Texture *texture, int x, int y, float angle);
|
||||
|
||||
extern Battle battle;
|
||||
extern Entity *self;
|
||||
|
|
|
@ -143,7 +143,7 @@ static void executeNextLine(ScriptRunner *runner)
|
|||
}
|
||||
else if (strcmp(command, "ACTIVATE_JUMPGATE") == 0)
|
||||
{
|
||||
battle.jumpgate->alive = ALIVE_ALIVE;
|
||||
battle.jumpgate->systemPower = MAX_SYSTEM_POWER;
|
||||
}
|
||||
else if (strcmp(command, "MSG_BOX") == 0)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#define MAX_FIGHTER_GUNS 12
|
||||
#define MAX_TARGET_RANGE 65536
|
||||
#define MAX_SYSTEM_POWER 100
|
||||
|
||||
#define BATTLE_AREA_CELLS 50
|
||||
#define BATTLE_AREA_WIDTH (640 * BATTLE_AREA_CELLS)
|
||||
|
@ -165,8 +166,7 @@ enum
|
|||
ALIVE_ALIVE,
|
||||
ALIVE_DYING,
|
||||
ALIVE_DEAD,
|
||||
ALIVE_ESCAPED,
|
||||
ALIVE_SLEEPING /* used by jumpgate */
|
||||
ALIVE_ESCAPED
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
|
@ -567,7 +567,7 @@ static void loadEntities(cJSON *node)
|
|||
{
|
||||
Entity *e;
|
||||
char *name, *groupName;
|
||||
int i, type, scatter, number, active, sleeping;
|
||||
int i, type, scatter, number, active, systemPower;
|
||||
float x, y;
|
||||
|
||||
if (node)
|
||||
|
@ -588,7 +588,7 @@ static void loadEntities(cJSON *node)
|
|||
number = getJSONValue(node, "number", 1);
|
||||
active = getJSONValue(node, "active", 1);
|
||||
scatter = getJSONValue(node, "scatter", 1);
|
||||
sleeping = getJSONValue(node, "sleeping", 0);
|
||||
systemPower = getJSONValue(node, "systemPower", MAX_SYSTEM_POWER);
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
{
|
||||
|
@ -629,10 +629,7 @@ static void loadEntities(cJSON *node)
|
|||
|
||||
e->active = active;
|
||||
|
||||
if (sleeping)
|
||||
{
|
||||
e->alive = ALIVE_SLEEPING;
|
||||
}
|
||||
e->systemPower = systemPower;
|
||||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ struct Entity {
|
|||
Entity *leader;
|
||||
Entity *owner;
|
||||
void (*action)(void);
|
||||
void (*draw)(void);
|
||||
void (*die)(void);
|
||||
SDL_Texture *texture;
|
||||
Entity *next;
|
||||
|
|
Loading…
Reference in New Issue