2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
2015-03-01 21:37:32 +01:00
|
|
|
Copyright (C) 2011, 2012, 2013 Guus Sliepen
|
|
|
|
Copyright (C) 2015 Julian Marchant
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
as published by the Free Software Foundation; either version 3
|
2011-08-24 14:14:44 +02:00
|
|
|
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
|
2015-02-26 17:20:36 +01:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-24 14:14:44 +02:00
|
|
|
*/
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
#include "Starfighter.h"
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
void clearInfoLines()
|
|
|
|
{
|
|
|
|
for (int i = 0 ; i < 4 ; i++)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[i].life = 0;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// from a to b
|
2011-08-26 21:29:04 +02:00
|
|
|
static void copyInfoLine(int a, int b)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(b, textShape[a].text, -1, 0, textShape[a].fontColor);
|
|
|
|
textShape[b].life = textShape[a].life;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Sets one of the three information lines on the screen. The accepts the
|
|
|
|
string and colors. It will set the information to the first free infoline
|
|
|
|
it finds (top to bottom). If it doesn't find any free ones, it will push
|
|
|
|
all the other info lines down one and add itself to the top.
|
|
|
|
*/
|
2011-08-24 14:42:59 +02:00
|
|
|
void setInfoLine(const char *in, int color)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
int index = -1;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 3 ; i++)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
if ((textShape[i].life == 0) && (index == -1))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bump down
|
|
|
|
if (index == -1)
|
|
|
|
{
|
|
|
|
index = 2;
|
|
|
|
copyInfoLine(1, 0);
|
|
|
|
copyInfoLine(2, 1);
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(index, in, -1, 0, color);
|
|
|
|
textShape[index].life = 240;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Sets a radio message that appears at the top of the screen. Used for
|
|
|
|
script events, etc. We send a message priority too, since we don't want
|
|
|
|
Phoebe or Ursula's banter to interrupt an important message
|
|
|
|
*/
|
2011-08-24 14:42:59 +02:00
|
|
|
void setRadioMessage(signed char face, const char *in, int priority)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
if ((textShape[3].life > 0) && (priority == 0))
|
2011-08-24 14:14:44 +02:00
|
|
|
return;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(3, in, -1, 50, FONT_WHITE);
|
|
|
|
textShape[3].life = 240;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
SDL_Surface *faceShape = NULL;
|
|
|
|
if (face > -1)
|
2011-08-26 23:53:46 +02:00
|
|
|
faceShape = shape[face];
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
createMessageBox(faceShape, in, 1);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
/*
|
|
|
|
Draw an arrow at the edge of the screen for each enemy ship that is not visible.
|
|
|
|
*/
|
|
|
|
static void doArrow(int i)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-07 15:42:24 +01:00
|
|
|
if (i < 0 || !aliens[i].active || aliens[i].shield <= 0 || aliens[i].flags & FL_ISCLOAKED)
|
2011-08-24 14:14:44 +02:00
|
|
|
return;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
int x = aliens[i].x + aliens[i].image[0]->w / 2;
|
|
|
|
int y = aliens[i].y + aliens[i].image[0]->h / 2;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
float sx = fabsf((x - (screen->w / 2)) / (screen->w / 2.0));
|
|
|
|
float sy = fabsf((y - (screen->h / 2)) / (screen->h / 2.0));
|
2015-03-17 21:54:00 +01:00
|
|
|
float sxy = MAX(sx, sy);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
if (sxy < 1)
|
|
|
|
return;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
x = screen->w / 2 + (x - screen->w / 2) / sxy;
|
|
|
|
y = screen->h / 2 + (y - screen->h / 2) / sxy;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
int arrow;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
if (sxy == sx) {
|
|
|
|
arrow = x < screen->w / 2 ? 42 : 38;
|
|
|
|
x -= x > screen->w / 2 ? shape[arrow]->w : 0;
|
|
|
|
y -= shape[arrow]->h / 2;
|
|
|
|
} else {
|
|
|
|
arrow = y < screen->h / 2 ? 36 : 40;
|
|
|
|
x -= shape[arrow]->w / 2;
|
|
|
|
y -= y > screen->h / 2 ? shape[arrow]->h : 0;
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
blit(shape[arrow], x, y);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-02-27 00:46:45 +01:00
|
|
|
if (i != engine.targetIndex)
|
2012-12-14 16:08:46 +01:00
|
|
|
return;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-02-27 00:46:45 +01:00
|
|
|
if (textShape[3].life > 0)
|
2012-12-14 16:08:46 +01:00
|
|
|
return;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2012-12-14 16:08:46 +01:00
|
|
|
if (sxy == sx) {
|
|
|
|
x -= x > screen->w / 2 ? 5 + shape[44]->w : -5 - shape[arrow]->w;
|
|
|
|
y -= (shape[44]->h - shape[arrow]->h) / 2;
|
|
|
|
} else {
|
|
|
|
x -= (shape[44]->w - shape[arrow]->w) / 2;
|
|
|
|
y -= y > screen->h / 2 ? 5 + shape[44]->h : -5 - shape[arrow]->h;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
2012-12-14 16:08:46 +01:00
|
|
|
|
|
|
|
blit(shape[44], x, y);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fill in later...
|
|
|
|
*/
|
|
|
|
void doInfo()
|
|
|
|
{
|
|
|
|
int shieldColor = 0;
|
|
|
|
SDL_Rect bar;
|
|
|
|
signed char fontColor;
|
|
|
|
char text[25];
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
addBuffer(0, 20, 800, 25);
|
2011-09-11 21:57:57 +02:00
|
|
|
addBuffer(0, 550, 800, 34);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (engine.minutes > -1)
|
|
|
|
{
|
|
|
|
if ((engine.minutes == 0) && (engine.seconds <= 29))
|
|
|
|
fontColor = FONT_RED;
|
|
|
|
else if ((engine.minutes == 0) && (engine.seconds > 29))
|
|
|
|
fontColor = FONT_YELLOW;
|
|
|
|
else
|
|
|
|
fontColor = FONT_WHITE;
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(10); // time remaining
|
2011-08-24 14:14:44 +02:00
|
|
|
sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds);
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(30, text, 410, 21, fontColor);
|
|
|
|
blitText(30);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (currentGame.area != MAX_MISSIONS - 1)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(9); // mission objectives
|
2011-08-24 14:14:44 +02:00
|
|
|
sprintf(text, "%d", (currentMission.remainingObjectives1 + currentMission.remainingObjectives2));
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(39, text, 745, 21, FONT_WHITE);
|
|
|
|
blitText(39);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(8); // cash
|
2011-08-24 14:14:44 +02:00
|
|
|
sprintf(text, "%.6d", currentGame.cash);
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(38, text, 90, 21, FONT_WHITE);
|
|
|
|
blitText(38);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-09 01:59:33 +01:00
|
|
|
for (int i = 0; i < ALIEN_MAX; i++)
|
2015-02-27 00:46:45 +01:00
|
|
|
doArrow(i);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
fontColor = FONT_WHITE;
|
|
|
|
if (player.ammo[0] > 0)
|
|
|
|
{
|
|
|
|
if (player.ammo[0] <= 25) fontColor = FONT_YELLOW;
|
|
|
|
if (player.ammo[0] <= 10) fontColor = FONT_RED;
|
|
|
|
}
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(5); // plasma ammo
|
2011-08-24 14:14:44 +02:00
|
|
|
sprintf(text, "%.3d", player.ammo[0]);
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(35, text, 320, 551, fontColor);
|
|
|
|
blitText(35);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(6);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER))
|
|
|
|
{
|
|
|
|
if (player.ammo[1] == 1)
|
|
|
|
fontColor = FONT_RED;
|
|
|
|
else
|
|
|
|
fontColor = FONT_WHITE;
|
|
|
|
sprintf(text, "%.3d", player.ammo[1]); // rocket ammo
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(36, text, 465, 551, fontColor);
|
|
|
|
blitText(36);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER)) && (player.ammo[1] > 0))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
int c = white;
|
2011-08-24 14:14:44 +02:00
|
|
|
if (player.ammo[1] > 100)
|
2011-08-26 23:53:46 +02:00
|
|
|
c = red;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
bar.x = 450;
|
|
|
|
bar.y = 550;
|
|
|
|
bar.h = 12;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < (player.ammo[1] / 5) ; i++)
|
|
|
|
{
|
|
|
|
bar.w = 1;
|
2011-08-26 23:53:46 +02:00
|
|
|
SDL_FillRect(screen, &bar, c);
|
2011-08-24 14:14:44 +02:00
|
|
|
bar.x += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!allMissionsCompleted()) && (SDL_GetTicks() >= engine.counter2))
|
|
|
|
{
|
|
|
|
engine.timeTaken++;
|
|
|
|
engine.counter2 = SDL_GetTicks() + 1000;
|
|
|
|
if (engine.missionCompleteTimer == 0)
|
|
|
|
checkScriptEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((engine.timeMission) && (!engine.cheatTime) && (player.shield > 0))
|
|
|
|
{
|
|
|
|
if (SDL_GetTicks() >= engine.counter)
|
|
|
|
{
|
|
|
|
if ((engine.seconds > 1) && (engine.seconds <= 11) && (engine.minutes == 0))
|
|
|
|
{
|
2015-03-08 15:38:58 +01:00
|
|
|
audio_playSound(SFX_CLOCK, screen->w / 2);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (engine.seconds > 0)
|
|
|
|
{
|
|
|
|
engine.seconds--;
|
|
|
|
engine.counter = (SDL_GetTicks() + 1000);
|
|
|
|
}
|
|
|
|
else if ((engine.seconds == 0) && (engine.minutes > 0))
|
|
|
|
{
|
|
|
|
engine.minutes--;
|
|
|
|
engine.seconds = 59;
|
|
|
|
engine.counter = (SDL_GetTicks() + 1000);
|
|
|
|
for (int i = 0 ; i < 3 ; i++)
|
|
|
|
{
|
|
|
|
if (currentMission.timeLimit1[i] > -1)
|
|
|
|
currentMission.timeLimit1[i]--;
|
|
|
|
if (currentMission.timeLimit2[i] > -1)
|
|
|
|
currentMission.timeLimit2[i]--;
|
|
|
|
}
|
|
|
|
checkTimer();
|
|
|
|
checkScriptEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((engine.seconds == 0) && (engine.minutes == 0))
|
|
|
|
{
|
|
|
|
for (int i = 0 ; i < 3 ; i++)
|
|
|
|
{
|
|
|
|
if (currentMission.timeLimit1[i] > -1)
|
|
|
|
currentMission.timeLimit1[i]--;
|
|
|
|
if (currentMission.timeLimit2[i] > -1)
|
|
|
|
currentMission.timeLimit2[i]--;
|
|
|
|
}
|
|
|
|
checkTimer();
|
|
|
|
checkScriptEvents();
|
|
|
|
engine.counter = (SDL_GetTicks() + 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 3 ; i++)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
if (textShape[i].life > 0)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[i].y = (525 - (i * 20));
|
|
|
|
blitText(i);
|
|
|
|
textShape[i].life--;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
if (textShape[i].life == 0)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
copyInfoLine(i + 1, i);
|
|
|
|
copyInfoLine(i + 2, i + 1);
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[2].life = 0;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show the radio message if there is one
|
2011-08-26 23:53:46 +02:00
|
|
|
if (textShape[3].life > 0)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(messageBox, (800 - messageBox->w) / 2, 50);
|
|
|
|
textShape[3].life--;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Do the target's remaining shield (if required)
|
|
|
|
if (currentGame.area != 10)
|
|
|
|
{
|
2015-03-07 15:42:24 +01:00
|
|
|
if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) && (engine.targetIndex > 9))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(7);
|
2011-08-24 14:14:44 +02:00
|
|
|
bar.w = 1;
|
|
|
|
bar.h = 12;
|
|
|
|
bar.x = 620;
|
|
|
|
bar.y = 550;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
for (float i = 0 ; i < (engine.targetShield * aliens[engine.targetIndex].shield) ; i++)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (i > 50)
|
2011-08-26 23:53:46 +02:00
|
|
|
shieldColor = green;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if ((i >= 25) && (i <= 50))
|
2011-08-26 23:53:46 +02:00
|
|
|
shieldColor = yellow;
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
shieldColor = red;
|
|
|
|
SDL_FillRect(screen, &bar, shieldColor);
|
2011-08-24 14:14:44 +02:00
|
|
|
bar.x += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(11);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
bar.w = 25;
|
|
|
|
bar.h = 12;
|
|
|
|
bar.x = 80;
|
|
|
|
bar.y = 571;
|
|
|
|
|
2011-09-11 21:57:57 +02:00
|
|
|
for (int i = 1 ; i <= 5 ; i++)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-02-28 14:15:53 +01:00
|
|
|
if (weapon[W_PLAYER_WEAPON].damage >= i) {
|
2011-09-11 21:57:57 +02:00
|
|
|
if(i <= currentGame.maxPlasmaDamage || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
|
|
|
{
|
|
|
|
SDL_FillRect(screen, &bar, green);
|
|
|
|
}
|
|
|
|
} else if (i <= currentGame.maxPlasmaDamage)
|
2011-08-26 23:53:46 +02:00
|
|
|
SDL_FillRect(screen, &bar, darkGreen);
|
2011-09-11 21:57:57 +02:00
|
|
|
bar.x += 30;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(12);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
bar.w = 25;
|
|
|
|
bar.h = 12;
|
|
|
|
bar.x = 315;
|
|
|
|
bar.y = 571;
|
2011-08-26 23:53:46 +02:00
|
|
|
SDL_FillRect(screen, &bar, yellow);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-09-11 21:57:57 +02:00
|
|
|
for (int i = 1 ; i <= 5 ; i++)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-02-28 14:15:53 +01:00
|
|
|
if (weapon[W_PLAYER_WEAPON].ammo[0] >= i) {
|
2011-09-11 21:57:57 +02:00
|
|
|
if(i <= currentGame.maxPlasmaOutput || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
|
|
|
{
|
|
|
|
SDL_FillRect(screen, &bar, yellow);
|
|
|
|
}
|
|
|
|
}
|
2011-09-17 11:24:56 +02:00
|
|
|
else if (i <= currentGame.maxPlasmaOutput)
|
2011-08-26 23:53:46 +02:00
|
|
|
SDL_FillRect(screen, &bar, darkYellow);
|
2011-09-11 21:57:57 +02:00
|
|
|
bar.x += 30;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(13);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
bar.w = 25;
|
|
|
|
bar.h = 12;
|
|
|
|
bar.x = 550;
|
|
|
|
bar.y = 571;
|
|
|
|
|
2011-09-11 21:57:57 +02:00
|
|
|
for (int i = 1 ; i <= 5 ; i++)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-02-28 14:15:53 +01:00
|
|
|
if (weapon[W_PLAYER_WEAPON].reload[0] <= rate2reload[i]) {
|
2011-09-11 21:57:57 +02:00
|
|
|
if(i <= currentGame.maxPlasmaRate || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
|
|
|
{
|
|
|
|
SDL_FillRect(screen, &bar, blue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i <= currentGame.maxPlasmaRate)
|
2011-08-26 23:53:46 +02:00
|
|
|
SDL_FillRect(screen, &bar, darkerBlue);
|
2011-08-24 14:14:44 +02:00
|
|
|
bar.x += 30;
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(4);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (player.shield < 1)
|
|
|
|
return;
|
|
|
|
|
2013-09-30 16:52:43 +02:00
|
|
|
if ((!engine.keyState[KEY_ALTFIRE]) && (player.weaponType[1] == W_LASER) && (engine.eventTimer % 8 == 1))
|
2015-03-18 00:00:13 +01:00
|
|
|
LIMIT_ADD(player.ammo[1], -1, 1, 255);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if ((engine.eventTimer < 30) && (player.shield <= engine.lowShield))
|
|
|
|
return;
|
|
|
|
|
|
|
|
signed char blockSize = 1;
|
|
|
|
|
|
|
|
bar.w = blockSize;
|
|
|
|
bar.h = 12;
|
|
|
|
bar.x = 95;
|
|
|
|
bar.y = 550;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < player.shield ; i += blockSize)
|
|
|
|
{
|
|
|
|
if (i >= engine.averageShield)
|
2011-08-26 23:53:46 +02:00
|
|
|
shieldColor = green;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if ((i >= engine.lowShield) && (i < engine.averageShield))
|
2011-08-26 23:53:46 +02:00
|
|
|
shieldColor = yellow;
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
shieldColor = red;
|
|
|
|
SDL_FillRect(screen, &bar, shieldColor);
|
2011-08-24 14:14:44 +02:00
|
|
|
bar.x += blockSize;
|
|
|
|
if (player.maxShield < 75)
|
|
|
|
bar.x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-11 15:22:38 +01:00
|
|
|
static const char *faces[] = {
|
|
|
|
"FACE_CHRIS", "FACE_SID", "FACE_KRASS",
|
|
|
|
"FACE_KLINE", "FACE_PHOEBE", "FACE_URSULA",
|
|
|
|
"FACE_CREW"
|
|
|
|
};
|
|
|
|
|
2011-08-24 14:42:59 +02:00
|
|
|
int getFace(const char *face)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
for (int i = 0 ; i < 7 ; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(faces[i], face) == 0)
|
|
|
|
return 90 + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetLists()
|
|
|
|
{
|
|
|
|
object *ob, *ob2;
|
|
|
|
collectables *c1, *c2;
|
|
|
|
bRect *r1, *r2;
|
|
|
|
|
|
|
|
ob = engine.bulletHead->next;
|
|
|
|
while(ob != NULL)
|
|
|
|
{
|
|
|
|
ob2 = ob;
|
|
|
|
ob = ob->next;
|
|
|
|
delete ob2;
|
|
|
|
}
|
|
|
|
engine.bulletHead->next = NULL;
|
|
|
|
engine.bulletTail = engine.bulletHead;
|
|
|
|
|
|
|
|
ob = engine.explosionHead->next;
|
|
|
|
while(ob != NULL)
|
|
|
|
{
|
|
|
|
ob2 = ob;
|
|
|
|
ob = ob->next;
|
|
|
|
delete ob2;
|
|
|
|
}
|
|
|
|
engine.explosionHead->next = NULL;
|
|
|
|
engine.explosionTail = engine.explosionHead;
|
|
|
|
|
|
|
|
c1 = engine.collectableHead->next;
|
|
|
|
while (c1 != NULL)
|
|
|
|
{
|
|
|
|
c2 = c1;
|
|
|
|
c1 = c1->next;
|
|
|
|
delete c2;
|
|
|
|
}
|
|
|
|
|
|
|
|
engine.collectableHead->next = NULL;
|
|
|
|
engine.collectableTail = engine.collectableHead;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
r1 = bufferHead->next;
|
2011-08-24 14:14:44 +02:00
|
|
|
while (r1 != NULL)
|
|
|
|
{
|
|
|
|
r2 = r1;
|
|
|
|
r1 = r1->next;
|
|
|
|
delete r2;
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
bufferHead->next = NULL;
|
|
|
|
bufferTail = bufferHead;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
ob = engine.debrisHead->next;
|
|
|
|
while(ob != NULL)
|
|
|
|
{
|
|
|
|
ob2 = ob;
|
|
|
|
ob = ob->next;
|
|
|
|
delete ob2;
|
|
|
|
}
|
|
|
|
engine.debrisHead->next = NULL;
|
|
|
|
engine.debrisTail = engine.debrisHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
|