Added ECM and boost abilities to player.
This commit is contained in:
parent
0b459a9927
commit
d8ef183b5e
|
@ -223,6 +223,12 @@ static void huntTarget(Bullet *b)
|
||||||
faceTarget(b);
|
faceTarget(b);
|
||||||
|
|
||||||
applyMissileThrust(b);
|
applyMissileThrust(b);
|
||||||
|
|
||||||
|
if (b->target == player && battle.ecmTimer == ECM_RECHARGE_TIME)
|
||||||
|
{
|
||||||
|
b->life = 0;
|
||||||
|
addMissileExplosion(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
extern SDL_Texture *getTexture(char *filename);
|
extern SDL_Texture *getTexture(char *filename);
|
||||||
extern void doAI(void);
|
extern void doAI(void);
|
||||||
extern void doCivilianAI(void);
|
|
||||||
extern void blitRotated(SDL_Texture *t, int x, int y, int angle);
|
extern void blitRotated(SDL_Texture *t, int x, int y, int angle);
|
||||||
extern void blit(SDL_Texture *t, int x, int y, int center);
|
extern void blit(SDL_Texture *t, int x, int y, int center);
|
||||||
extern float getAngle(int x1, int y1, int x2, int y2);
|
extern float getAngle(int x1, int y1, int x2, int y2);
|
||||||
|
|
|
@ -29,6 +29,8 @@ static void drawObjectives(void);
|
||||||
static void drawDistancesInfo(void);
|
static void drawDistancesInfo(void);
|
||||||
static void drawHudMessages(void);
|
static void drawHudMessages(void);
|
||||||
static void drawPlayerSelect(void);
|
static void drawPlayerSelect(void);
|
||||||
|
static void drawAbilityBars(void);
|
||||||
|
static void drawBoostECMBar(int x, int y, int r, int g, int b, int available);
|
||||||
|
|
||||||
static HudMessage hudMessageHead;
|
static HudMessage hudMessageHead;
|
||||||
static HudMessage *hudMessageTail;
|
static HudMessage *hudMessageTail;
|
||||||
|
@ -124,6 +126,8 @@ void drawHud(void)
|
||||||
{
|
{
|
||||||
drawHealthBars();
|
drawHealthBars();
|
||||||
|
|
||||||
|
drawAbilityBars();
|
||||||
|
|
||||||
drawPlayerTargeter();
|
drawPlayerTargeter();
|
||||||
|
|
||||||
drawWeaponInfo();
|
drawWeaponInfo();
|
||||||
|
@ -210,10 +214,44 @@ static void drawHealthShieldBar(int current, int max, int x, int y, int r, int g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drawAbilityBars(void)
|
||||||
|
{
|
||||||
|
drawBoostECMBar(10, 50, 128, 128, 255, battle.boostTimer == 0);
|
||||||
|
|
||||||
|
drawBoostECMBar(160, 50, 255, 128, 0, battle.ecmTimer == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawBoostECMBar(int x, int y, int r, int g, int b, int available)
|
||||||
|
{
|
||||||
|
SDL_Rect rect;
|
||||||
|
|
||||||
|
rect.x = x;
|
||||||
|
rect.y = y;
|
||||||
|
rect.w = 100;
|
||||||
|
rect.h = 12;
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderFillRect(app.renderer, &rect);
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255);
|
||||||
|
SDL_RenderDrawRect(app.renderer, &rect);
|
||||||
|
|
||||||
|
if (available)
|
||||||
|
{
|
||||||
|
rect.x += 2;
|
||||||
|
rect.y += 2;
|
||||||
|
rect.w -= 4;
|
||||||
|
rect.h -= 4;
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, r, g, b, 255);
|
||||||
|
SDL_RenderFillRect(app.renderer, &rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void drawWeaponInfo(void)
|
static void drawWeaponInfo(void)
|
||||||
{
|
{
|
||||||
drawText(10, 50, 14, TA_LEFT, colors.white, gunName[player->selectedGunType]);
|
drawText(10, 70, 14, TA_LEFT, colors.white, gunName[player->selectedGunType]);
|
||||||
drawText(260, 50, 14, TA_RIGHT, colors.white, "Missiles (%d)", player->missiles.ammo);
|
drawText(260, 70, 14, TA_RIGHT, colors.white, "Missiles (%d)", player->missiles.ammo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawPlayerTargeter(void)
|
static void drawPlayerTargeter(void)
|
||||||
|
|
|
@ -25,6 +25,8 @@ static void switchGuns(void);
|
||||||
static void selectMissionTarget(void);
|
static void selectMissionTarget(void);
|
||||||
static void selectNewPlayer(int dir);
|
static void selectNewPlayer(int dir);
|
||||||
static void initPlayerSelect(void);
|
static void initPlayerSelect(void);
|
||||||
|
static void activateBoost(void);
|
||||||
|
static void activateECM(void);
|
||||||
|
|
||||||
static int selectedPlayerIndex;
|
static int selectedPlayerIndex;
|
||||||
static int availableGuns[BT_MAX];
|
static int availableGuns[BT_MAX];
|
||||||
|
@ -60,6 +62,14 @@ void initPlayer(void)
|
||||||
|
|
||||||
void doPlayer(void)
|
void doPlayer(void)
|
||||||
{
|
{
|
||||||
|
battle.boostTimer = MAX(battle.boostTimer - 1, 0);
|
||||||
|
battle.ecmTimer = MAX(battle.ecmTimer - 1, 0);
|
||||||
|
|
||||||
|
if (battle.boostTimer == BOOST_FINISHED_TIME)
|
||||||
|
{
|
||||||
|
applyFighterThrust();
|
||||||
|
}
|
||||||
|
|
||||||
if (player != NULL)
|
if (player != NULL)
|
||||||
{
|
{
|
||||||
self = player;
|
self = player;
|
||||||
|
@ -76,7 +86,7 @@ void doPlayer(void)
|
||||||
player->angle += 4;
|
player->angle += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_UP])
|
if (app.keyboard[SDL_SCANCODE_UP] && battle.boostTimer < BOOST_FINISHED_TIME)
|
||||||
{
|
{
|
||||||
applyFighterThrust();
|
applyFighterThrust();
|
||||||
}
|
}
|
||||||
|
@ -112,13 +122,23 @@ void doPlayer(void)
|
||||||
app.keyboard[SDL_SCANCODE_RETURN] = 0;
|
app.keyboard[SDL_SCANCODE_RETURN] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || app.keyboard[SDLK_t])
|
if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || app.keyboard[SDL_SCANCODE_T])
|
||||||
{
|
{
|
||||||
selectTarget();
|
selectTarget();
|
||||||
|
|
||||||
app.keyboard[SDLK_t] = 0;
|
app.keyboard[SDLK_t] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_SPACE] && !battle.boostTimer)
|
||||||
|
{
|
||||||
|
activateBoost();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_E] && !battle.ecmTimer)
|
||||||
|
{
|
||||||
|
activateECM();
|
||||||
|
}
|
||||||
|
|
||||||
if (!battle.missionTarget)
|
if (!battle.missionTarget)
|
||||||
{
|
{
|
||||||
selectMissionTarget();
|
selectMissionTarget();
|
||||||
|
@ -213,6 +233,20 @@ static void selectNewPlayer(int dir)
|
||||||
battle.camera.y = player->y - (SCREEN_HEIGHT / 2);
|
battle.camera.y = player->y - (SCREEN_HEIGHT / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void activateBoost(void)
|
||||||
|
{
|
||||||
|
self->dx += sin(TO_RAIDANS(self->angle)) * 10;
|
||||||
|
self->dy += -cos(TO_RAIDANS(self->angle)) * 10;
|
||||||
|
self->thrust = sqrt((self->dx * self->dx) + (self->dy * self->dy));
|
||||||
|
|
||||||
|
battle.boostTimer = BOOST_RECHARGE_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void activateECM(void)
|
||||||
|
{
|
||||||
|
battle.ecmTimer = ECM_RECHARGE_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
static void switchGuns(void)
|
static void switchGuns(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -74,6 +74,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define EF_HAS_ROPE (2 << 8)
|
#define EF_HAS_ROPE (2 << 8)
|
||||||
#define EF_ALWAYS_FLEES (2 << 9)
|
#define EF_ALWAYS_FLEES (2 << 9)
|
||||||
|
|
||||||
|
/* player abilities */
|
||||||
|
#define BOOST_RECHARGE_TIME (FPS * 5)
|
||||||
|
#define BOOST_FINISHED_TIME (BOOST_RECHARGE_TIME - FPS * 0.5)
|
||||||
|
#define ECM_RECHARGE_TIME (FPS * 5)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ET_FIGHTER,
|
ET_FIGHTER,
|
||||||
|
|
|
@ -241,6 +241,8 @@ typedef struct {
|
||||||
int epicFighterLimit;
|
int epicFighterLimit;
|
||||||
int playerSelect;
|
int playerSelect;
|
||||||
int missionFinishedTimer;
|
int missionFinishedTimer;
|
||||||
|
int boostTimer;
|
||||||
|
int ecmTimer;
|
||||||
int numObjectivesComplete, numObjectivesTotal;
|
int numObjectivesComplete, numObjectivesTotal;
|
||||||
Entity *missionTarget;
|
Entity *missionTarget;
|
||||||
Entity *extractionPoint;
|
Entity *extractionPoint;
|
||||||
|
|
Loading…
Reference in New Issue