More cleanup
This commit is contained in:
parent
533d74447f
commit
c6735cd88b
|
@ -122,7 +122,7 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
|
||||
case 1:
|
||||
section = galaxyMap();
|
||||
section = intermission();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
|
|
@ -419,9 +419,11 @@ enum {
|
|||
DIFFICULTY_MAX
|
||||
};
|
||||
|
||||
extern const char *systemNames[];
|
||||
const char * const systemNames[] = {"Spirit", "Eyananth", "Mordor", "Sol"};
|
||||
|
||||
extern const char *systemBackground[];
|
||||
const char * const systemBackground[] = {
|
||||
"gfx/spirit.jpg", "gfx/eyananth.jpg", "gfx/mordor.jpg", "gfx/sol.jpg"
|
||||
};
|
||||
|
||||
const int rate2reload[6] = {15, 15, 13, 11, 9, 7};
|
||||
const int screenWidth = 800;
|
||||
|
|
331
src/game.cpp
331
src/game.cpp
|
@ -1507,6 +1507,335 @@ void game_doExplosions()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Draw an arrow at the edge of the screen for each enemy ship that is not visible.
|
||||
*/
|
||||
static void game_doArrow(int i)
|
||||
{
|
||||
if (i < 0 || !aliens[i].active || aliens[i].shield <= 0 || aliens[i].flags & FL_ISCLOAKED)
|
||||
return;
|
||||
|
||||
int x = aliens[i].x + aliens[i].image[0]->w / 2;
|
||||
int y = aliens[i].y + aliens[i].image[0]->h / 2;
|
||||
|
||||
float sx = fabsf((x - (screen->w / 2)) / (screen->w / 2.0));
|
||||
float sy = fabsf((y - (screen->h / 2)) / (screen->h / 2.0));
|
||||
float sxy = MAX(sx, sy);
|
||||
|
||||
if (sxy < 1)
|
||||
return;
|
||||
|
||||
x = screen->w / 2 + (x - screen->w / 2) / sxy;
|
||||
y = screen->h / 2 + (y - screen->h / 2) / sxy;
|
||||
|
||||
int arrow;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
blit(shape[arrow], x, y);
|
||||
|
||||
if (i != engine.targetIndex)
|
||||
return;
|
||||
|
||||
if (textShape[3].life > 0)
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
blit(shape[44], x, y);
|
||||
}
|
||||
|
||||
static void game_doHud()
|
||||
{
|
||||
int shieldColor = 0;
|
||||
SDL_Rect bar;
|
||||
signed char fontColor;
|
||||
char text[25];
|
||||
|
||||
addBuffer(0, 20, 800, 25);
|
||||
addBuffer(0, 550, 800, 34);
|
||||
|
||||
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;
|
||||
blitText(10); // time remaining
|
||||
sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds);
|
||||
textSurface(30, text, 410, 21, fontColor);
|
||||
blitText(30);
|
||||
}
|
||||
|
||||
if (game.area != MISN_INTERCEPTION)
|
||||
{
|
||||
blitText(9); // mission objectives
|
||||
sprintf(text, "%d", (currentMission.remainingObjectives1 + currentMission.remainingObjectives2));
|
||||
textSurface(39, text, 745, 21, FONT_WHITE);
|
||||
blitText(39);
|
||||
}
|
||||
|
||||
blitText(8); // cash
|
||||
sprintf(text, "%.6d", game.cash);
|
||||
textSurface(38, text, 90, 21, FONT_WHITE);
|
||||
blitText(38);
|
||||
|
||||
for (int i = 0; i < ALIEN_MAX; i++)
|
||||
game_doArrow(i);
|
||||
|
||||
fontColor = FONT_WHITE;
|
||||
if (player.ammo[0] > 0)
|
||||
{
|
||||
if (player.ammo[0] <= 25) fontColor = FONT_YELLOW;
|
||||
if (player.ammo[0] <= 10) fontColor = FONT_RED;
|
||||
}
|
||||
blitText(5); // plasma ammo
|
||||
sprintf(text, "%.3d", player.ammo[0]);
|
||||
textSurface(35, text, 320, 551, fontColor);
|
||||
blitText(35);
|
||||
|
||||
blitText(6);
|
||||
|
||||
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
|
||||
textSurface(36, text, 465, 551, fontColor);
|
||||
blitText(36);
|
||||
}
|
||||
|
||||
if (((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER)) && (player.ammo[1] > 0))
|
||||
{
|
||||
int c = white;
|
||||
if (player.ammo[1] > 100)
|
||||
c = red;
|
||||
|
||||
bar.x = 450;
|
||||
bar.y = 550;
|
||||
bar.h = 12;
|
||||
|
||||
for (int i = 0 ; i < (player.ammo[1] / 5) ; i++)
|
||||
{
|
||||
bar.w = 1;
|
||||
SDL_FillRect(screen, &bar, c);
|
||||
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))
|
||||
{
|
||||
audio_playSound(SFX_CLOCK, screen->w / 2);
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
if (textShape[i].life > 0)
|
||||
{
|
||||
textShape[i].y = (525 - (i * 20));
|
||||
blitText(i);
|
||||
textShape[i].life--;
|
||||
|
||||
if (textShape[i].life == 0)
|
||||
{
|
||||
copyInfoLine(i + 1, i);
|
||||
copyInfoLine(i + 2, i + 1);
|
||||
textShape[2].life = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show the radio message if there is one
|
||||
if (textShape[3].life > 0)
|
||||
{
|
||||
blit(messageBox, (800 - messageBox->w) / 2, 50);
|
||||
textShape[3].life--;
|
||||
}
|
||||
|
||||
// Do the target's remaining shield (if required)
|
||||
if (game.area != MISN_DORIM)
|
||||
{
|
||||
if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) && (engine.targetIndex > 9))
|
||||
{
|
||||
blitText(7);
|
||||
bar.w = 1;
|
||||
bar.h = 12;
|
||||
bar.x = 620;
|
||||
bar.y = 550;
|
||||
|
||||
for (float i = 0 ; i < (engine.targetShield * aliens[engine.targetIndex].shield) ; i++)
|
||||
{
|
||||
if (i > 50)
|
||||
shieldColor = green;
|
||||
else if ((i >= 25) && (i <= 50))
|
||||
shieldColor = yellow;
|
||||
else
|
||||
shieldColor = red;
|
||||
SDL_FillRect(screen, &bar, shieldColor);
|
||||
bar.x += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blitText(11);
|
||||
|
||||
bar.w = 25;
|
||||
bar.h = 12;
|
||||
bar.x = 80;
|
||||
bar.y = 571;
|
||||
|
||||
for (int i = 1 ; i <= 5 ; i++)
|
||||
{
|
||||
if (weapon[W_PLAYER_WEAPON].damage >= i) {
|
||||
if(i <= game.maxPlasmaDamage || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
||||
{
|
||||
SDL_FillRect(screen, &bar, green);
|
||||
}
|
||||
} else if (i <= game.maxPlasmaDamage)
|
||||
SDL_FillRect(screen, &bar, darkGreen);
|
||||
bar.x += 30;
|
||||
}
|
||||
|
||||
blitText(12);
|
||||
|
||||
bar.w = 25;
|
||||
bar.h = 12;
|
||||
bar.x = 315;
|
||||
bar.y = 571;
|
||||
SDL_FillRect(screen, &bar, yellow);
|
||||
|
||||
for (int i = 1 ; i <= 5 ; i++)
|
||||
{
|
||||
if (weapon[W_PLAYER_WEAPON].ammo[0] >= i) {
|
||||
if(i <= game.maxPlasmaOutput || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
||||
{
|
||||
SDL_FillRect(screen, &bar, yellow);
|
||||
}
|
||||
}
|
||||
else if (i <= game.maxPlasmaOutput)
|
||||
SDL_FillRect(screen, &bar, darkYellow);
|
||||
bar.x += 30;
|
||||
}
|
||||
|
||||
blitText(13);
|
||||
|
||||
bar.w = 25;
|
||||
bar.h = 12;
|
||||
bar.x = 550;
|
||||
bar.y = 571;
|
||||
|
||||
for (int i = 1 ; i <= 5 ; i++)
|
||||
{
|
||||
if (weapon[W_PLAYER_WEAPON].reload[0] <= rate2reload[i]) {
|
||||
if(i <= game.maxPlasmaRate || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
||||
{
|
||||
SDL_FillRect(screen, &bar, blue);
|
||||
}
|
||||
}
|
||||
else if (i <= game.maxPlasmaRate)
|
||||
SDL_FillRect(screen, &bar, darkerBlue);
|
||||
bar.x += 30;
|
||||
}
|
||||
|
||||
blitText(4);
|
||||
if (player.shield < 1)
|
||||
return;
|
||||
|
||||
if ((!engine.keyState[KEY_ALTFIRE]) && (player.weaponType[1] == W_LASER) && (engine.eventTimer % 8 == 1))
|
||||
LIMIT_ADD(player.ammo[1], -1, 1, 255);
|
||||
|
||||
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)
|
||||
shieldColor = green;
|
||||
else if ((i >= engine.lowShield) && (i < engine.averageShield))
|
||||
shieldColor = yellow;
|
||||
else
|
||||
shieldColor = red;
|
||||
SDL_FillRect(screen, &bar, shieldColor);
|
||||
bar.x += blockSize;
|
||||
if (player.maxShield < 75)
|
||||
bar.x++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Checked during the main game loop. When the game is paused
|
||||
it goes into a constant loop checking this routine. If escape is
|
||||
|
@ -1810,7 +2139,7 @@ int game_mainLoop()
|
|||
game_doCargo();
|
||||
game_doDebris();
|
||||
game_doExplosions();
|
||||
doInfo();
|
||||
game_doHud();
|
||||
|
||||
WRAP_ADD(engine.eventTimer, -1, 0, 60);
|
||||
|
||||
|
|
|
@ -19,17 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "Starfighter.h"
|
||||
|
||||
const char *systemNames[] = {"Spirit", "Eyananth", "Mordor", "Sol"};
|
||||
|
||||
const char *systemBackground[] = {
|
||||
"gfx/spirit.jpg", "gfx/eyananth.jpg",
|
||||
"gfx/mordor.jpg", "gfx/sol.jpg"
|
||||
};
|
||||
|
||||
/*
|
||||
Drives the cursor. Is used by some other screens too
|
||||
*/
|
||||
static void doCursor()
|
||||
static void intermission_doCursor()
|
||||
{
|
||||
getPlayerInput();
|
||||
|
||||
|
@ -43,7 +36,7 @@ Sets the player's current status information lines. These are the lines
|
|||
that are scrolled up the screen when the player clicks on Current Status
|
||||
These are set only once.
|
||||
*/
|
||||
static void setStatusLines()
|
||||
static void intermission_setStatusLines()
|
||||
{
|
||||
char string[50];
|
||||
|
||||
|
@ -171,9 +164,8 @@ static void setStatusLines()
|
|||
|
||||
/*
|
||||
Sets the names and stats of the planets within the current system.
|
||||
This will later be placed into a data file.
|
||||
*/
|
||||
static void setSystemPlanets()
|
||||
static void intermission_setSystemPlanets()
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
|
@ -244,10 +236,10 @@ static void setSystemPlanets()
|
|||
|
||||
/*
|
||||
Spins the planets around the sun, spaced according to their Y value
|
||||
as defined in setSystemPlanets(). Moving the cursor over the planet
|
||||
as defined in intermission_setSystemPlanets(). Moving the cursor over the planet
|
||||
will show their name and their current status
|
||||
*/
|
||||
static bool showSystem(float x, float y, bool selectable)
|
||||
static bool intermission_showSystem(float x, float y, bool selectable)
|
||||
{
|
||||
SDL_Rect r;
|
||||
signed char planet = 0;
|
||||
|
@ -315,7 +307,7 @@ the specified status line reaches a certain Y value, the entire
|
|||
list is reset and the information lines begin again from the bottom
|
||||
(in other words, they loop around).
|
||||
*/
|
||||
static void showStatus(SDL_Surface *infoSurface)
|
||||
static void intermission_showStatus(SDL_Surface *infoSurface)
|
||||
{
|
||||
float speed = 0.25;
|
||||
|
||||
|
@ -353,7 +345,7 @@ static void showStatus(SDL_Surface *infoSurface)
|
|||
blitText(27);
|
||||
}
|
||||
|
||||
static void updateCommsSurface(SDL_Surface *comms)
|
||||
static void intermission_updateCommsSurface(SDL_Surface *comms)
|
||||
{
|
||||
if (engine.commsSection == 1)
|
||||
return;
|
||||
|
@ -367,7 +359,7 @@ static void updateCommsSurface(SDL_Surface *comms)
|
|||
drawString(string, 80, 35, FONT_WHITE, comms);
|
||||
}
|
||||
|
||||
static void createCommsSurface(SDL_Surface *comms)
|
||||
static void intermission_createCommsSurface(SDL_Surface *comms)
|
||||
{
|
||||
engine.commsSection = 0;
|
||||
|
||||
|
@ -390,10 +382,10 @@ static void createCommsSurface(SDL_Surface *comms)
|
|||
}
|
||||
}
|
||||
|
||||
updateCommsSurface(comms);
|
||||
intermission_updateCommsSurface(comms);
|
||||
}
|
||||
|
||||
static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
|
||||
static void intermission_createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
|
||||
{
|
||||
char name[50];
|
||||
char string[2000];
|
||||
|
@ -454,7 +446,7 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
|
|||
engine.commsSection = 1;
|
||||
}
|
||||
|
||||
static void doComms(SDL_Surface *comms)
|
||||
static void intermission_doComms(SDL_Surface *comms)
|
||||
{
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -464,7 +456,7 @@ static void doComms(SDL_Surface *comms)
|
|||
{
|
||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 180 + (i * 60), 430, 50))
|
||||
{
|
||||
createMissionDetailSurface(comms, i);
|
||||
intermission_createMissionDetailSurface(comms, i);
|
||||
engine.keyState[KEY_FIRE] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -473,14 +465,14 @@ static void doComms(SDL_Surface *comms)
|
|||
{
|
||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 440, 160, 20))
|
||||
{
|
||||
createCommsSurface(comms);
|
||||
intermission_createCommsSurface(comms);
|
||||
engine.keyState[KEY_FIRE] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void createOptions(SDL_Surface *optionsSurface)
|
||||
static void intermission_createOptions(SDL_Surface *optionsSurface)
|
||||
{
|
||||
SDL_FillRect(optionsSurface, NULL, black);
|
||||
|
||||
|
@ -522,7 +514,7 @@ static void createOptions(SDL_Surface *optionsSurface)
|
|||
drawString("FULLSCREEN", 30, 150, FONT_WHITE, optionsSurface);
|
||||
}
|
||||
|
||||
static void showOptions(SDL_Surface *optionsSurface)
|
||||
static void intermission_doOptions(SDL_Surface *optionsSurface)
|
||||
{
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -563,17 +555,17 @@ static void showOptions(SDL_Surface *optionsSurface)
|
|||
}
|
||||
}
|
||||
|
||||
createOptions(optionsSurface);
|
||||
intermission_createOptions(optionsSurface);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Oddly named function that controls the entire intermission
|
||||
screen. This simply draws a background, stars, gridlines and the icons
|
||||
at the bottom of the screen. Will call (and continue to call) the specified
|
||||
functions when the player has selected an icon.
|
||||
Controls the entire intermission screen. This simply draws a background,
|
||||
stars, gridlines and the icons at the bottom of the screen. Will call
|
||||
(and continue to call) the specified functions when the player has
|
||||
selected an icon.
|
||||
*/
|
||||
int galaxyMap()
|
||||
int intermission()
|
||||
{
|
||||
freeGraphics();
|
||||
|
||||
|
@ -633,9 +625,9 @@ int galaxyMap()
|
|||
int distance = 0;
|
||||
int interceptionChance = 0;
|
||||
|
||||
setStatusLines();
|
||||
intermission_setStatusLines();
|
||||
initShop();
|
||||
setSystemPlanets();
|
||||
intermission_setSystemPlanets();
|
||||
|
||||
SDL_Surface *statsSurface = alphaRect(600, 330, 0x00, 0x00, 0x99);
|
||||
SDL_Surface *savesSurface = createSurface(350, 300);
|
||||
|
@ -643,8 +635,8 @@ int galaxyMap()
|
|||
SDL_Surface *commsSurface = createSurface(450, 400);
|
||||
|
||||
createSavesSurface(savesSurface, -1);
|
||||
createOptions(optionsSurface);
|
||||
createCommsSurface(commsSurface);
|
||||
intermission_createOptions(optionsSurface);
|
||||
intermission_createCommsSurface(commsSurface);
|
||||
|
||||
signed char section = 1;
|
||||
|
||||
|
@ -814,14 +806,14 @@ int galaxyMap()
|
|||
cosY += 0.01;
|
||||
}
|
||||
|
||||
if (showSystem(sinX, cosY, true))
|
||||
if (intermission_showSystem(sinX, cosY, true))
|
||||
{
|
||||
if (game.system == 0)
|
||||
{
|
||||
sprintf(string, "Stationed At: %s", systemPlanet[game.stationedPlanet].name);
|
||||
SDL_FreeSurface(iconInfo[9].image);
|
||||
iconInfo[9].image = textSurface(string, FONT_WHITE);
|
||||
updateCommsSurface(commsSurface);
|
||||
intermission_updateCommsSurface(commsSurface);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -837,7 +829,7 @@ int galaxyMap()
|
|||
break;
|
||||
|
||||
case 2:
|
||||
showStatus(statsSurface);
|
||||
intermission_showStatus(statsSurface);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
@ -851,12 +843,12 @@ int galaxyMap()
|
|||
|
||||
case 5:
|
||||
blit(commsSurface, 170, 70);
|
||||
doComms(commsSurface);
|
||||
intermission_doComms(commsSurface);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
blit(optionsSurface, 230, 130);
|
||||
showOptions(optionsSurface);
|
||||
intermission_doOptions(optionsSurface);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
|
@ -865,7 +857,7 @@ int galaxyMap()
|
|||
break;
|
||||
|
||||
case 8:
|
||||
showSystem(sinX, cosY, false);
|
||||
intermission_showSystem(sinX, cosY, false);
|
||||
|
||||
blit(systemPlanet[game.stationedPlanet].image, 150, 450);
|
||||
blit(iconInfo[9].image, 135, 480);
|
||||
|
@ -886,7 +878,7 @@ int galaxyMap()
|
|||
systemPlanet[game.stationedPlanet].name);
|
||||
SDL_FreeSurface(iconInfo[9].image);
|
||||
iconInfo[9].image = textSurface(string, FONT_WHITE);
|
||||
updateCommsSurface(commsSurface);
|
||||
intermission_updateCommsSurface(commsSurface);
|
||||
section = 1;
|
||||
redrawBackGround = true;
|
||||
saveGame(0);
|
||||
|
@ -953,7 +945,7 @@ int galaxyMap()
|
|||
}
|
||||
|
||||
engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
|
||||
doCursor();
|
||||
intermission_doCursor();
|
||||
|
||||
delayFrame();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifndef INTERMISSION_H
|
||||
#define INTERMISSION_H
|
||||
|
||||
extern int galaxyMap();
|
||||
int intermission();
|
||||
|
||||
#endif
|
||||
|
|
334
src/misc.cpp
334
src/misc.cpp
|
@ -28,7 +28,7 @@ void clearInfoLines()
|
|||
}
|
||||
|
||||
// from a to b
|
||||
static void copyInfoLine(int a, int b)
|
||||
void copyInfoLine(int a, int b)
|
||||
{
|
||||
textSurface(b, textShape[a].text, -1, 0, textShape[a].fontColor);
|
||||
textShape[b].life = textShape[a].life;
|
||||
|
@ -84,338 +84,6 @@ void setRadioMessage(signed char face, const char *in, int priority)
|
|||
createMessageBox(faceShape, in, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
Draw an arrow at the edge of the screen for each enemy ship that is not visible.
|
||||
*/
|
||||
static void doArrow(int i)
|
||||
{
|
||||
if (i < 0 || !aliens[i].active || aliens[i].shield <= 0 || aliens[i].flags & FL_ISCLOAKED)
|
||||
return;
|
||||
|
||||
int x = aliens[i].x + aliens[i].image[0]->w / 2;
|
||||
int y = aliens[i].y + aliens[i].image[0]->h / 2;
|
||||
|
||||
float sx = fabsf((x - (screen->w / 2)) / (screen->w / 2.0));
|
||||
float sy = fabsf((y - (screen->h / 2)) / (screen->h / 2.0));
|
||||
float sxy = MAX(sx, sy);
|
||||
|
||||
if (sxy < 1)
|
||||
return;
|
||||
|
||||
x = screen->w / 2 + (x - screen->w / 2) / sxy;
|
||||
y = screen->h / 2 + (y - screen->h / 2) / sxy;
|
||||
|
||||
int arrow;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
blit(shape[arrow], x, y);
|
||||
|
||||
if (i != engine.targetIndex)
|
||||
return;
|
||||
|
||||
if (textShape[3].life > 0)
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
blit(shape[44], x, y);
|
||||
}
|
||||
|
||||
/*
|
||||
Fill in later...
|
||||
*/
|
||||
void doInfo()
|
||||
{
|
||||
int shieldColor = 0;
|
||||
SDL_Rect bar;
|
||||
signed char fontColor;
|
||||
char text[25];
|
||||
|
||||
addBuffer(0, 20, 800, 25);
|
||||
addBuffer(0, 550, 800, 34);
|
||||
|
||||
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;
|
||||
blitText(10); // time remaining
|
||||
sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds);
|
||||
textSurface(30, text, 410, 21, fontColor);
|
||||
blitText(30);
|
||||
}
|
||||
|
||||
if (game.area != MISN_INTERCEPTION)
|
||||
{
|
||||
blitText(9); // mission objectives
|
||||
sprintf(text, "%d", (currentMission.remainingObjectives1 + currentMission.remainingObjectives2));
|
||||
textSurface(39, text, 745, 21, FONT_WHITE);
|
||||
blitText(39);
|
||||
}
|
||||
|
||||
blitText(8); // cash
|
||||
sprintf(text, "%.6d", game.cash);
|
||||
textSurface(38, text, 90, 21, FONT_WHITE);
|
||||
blitText(38);
|
||||
|
||||
for (int i = 0; i < ALIEN_MAX; i++)
|
||||
doArrow(i);
|
||||
|
||||
fontColor = FONT_WHITE;
|
||||
if (player.ammo[0] > 0)
|
||||
{
|
||||
if (player.ammo[0] <= 25) fontColor = FONT_YELLOW;
|
||||
if (player.ammo[0] <= 10) fontColor = FONT_RED;
|
||||
}
|
||||
blitText(5); // plasma ammo
|
||||
sprintf(text, "%.3d", player.ammo[0]);
|
||||
textSurface(35, text, 320, 551, fontColor);
|
||||
blitText(35);
|
||||
|
||||
blitText(6);
|
||||
|
||||
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
|
||||
textSurface(36, text, 465, 551, fontColor);
|
||||
blitText(36);
|
||||
}
|
||||
|
||||
if (((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER)) && (player.ammo[1] > 0))
|
||||
{
|
||||
int c = white;
|
||||
if (player.ammo[1] > 100)
|
||||
c = red;
|
||||
|
||||
bar.x = 450;
|
||||
bar.y = 550;
|
||||
bar.h = 12;
|
||||
|
||||
for (int i = 0 ; i < (player.ammo[1] / 5) ; i++)
|
||||
{
|
||||
bar.w = 1;
|
||||
SDL_FillRect(screen, &bar, c);
|
||||
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))
|
||||
{
|
||||
audio_playSound(SFX_CLOCK, screen->w / 2);
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
if (textShape[i].life > 0)
|
||||
{
|
||||
textShape[i].y = (525 - (i * 20));
|
||||
blitText(i);
|
||||
textShape[i].life--;
|
||||
|
||||
if (textShape[i].life == 0)
|
||||
{
|
||||
copyInfoLine(i + 1, i);
|
||||
copyInfoLine(i + 2, i + 1);
|
||||
textShape[2].life = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show the radio message if there is one
|
||||
if (textShape[3].life > 0)
|
||||
{
|
||||
blit(messageBox, (800 - messageBox->w) / 2, 50);
|
||||
textShape[3].life--;
|
||||
}
|
||||
|
||||
// Do the target's remaining shield (if required)
|
||||
if (game.area != MISN_DORIM)
|
||||
{
|
||||
if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) && (engine.targetIndex > 9))
|
||||
{
|
||||
blitText(7);
|
||||
bar.w = 1;
|
||||
bar.h = 12;
|
||||
bar.x = 620;
|
||||
bar.y = 550;
|
||||
|
||||
for (float i = 0 ; i < (engine.targetShield * aliens[engine.targetIndex].shield) ; i++)
|
||||
{
|
||||
if (i > 50)
|
||||
shieldColor = green;
|
||||
else if ((i >= 25) && (i <= 50))
|
||||
shieldColor = yellow;
|
||||
else
|
||||
shieldColor = red;
|
||||
SDL_FillRect(screen, &bar, shieldColor);
|
||||
bar.x += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blitText(11);
|
||||
|
||||
bar.w = 25;
|
||||
bar.h = 12;
|
||||
bar.x = 80;
|
||||
bar.y = 571;
|
||||
|
||||
for (int i = 1 ; i <= 5 ; i++)
|
||||
{
|
||||
if (weapon[W_PLAYER_WEAPON].damage >= i) {
|
||||
if(i <= game.maxPlasmaDamage || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
||||
{
|
||||
SDL_FillRect(screen, &bar, green);
|
||||
}
|
||||
} else if (i <= game.maxPlasmaDamage)
|
||||
SDL_FillRect(screen, &bar, darkGreen);
|
||||
bar.x += 30;
|
||||
}
|
||||
|
||||
blitText(12);
|
||||
|
||||
bar.w = 25;
|
||||
bar.h = 12;
|
||||
bar.x = 315;
|
||||
bar.y = 571;
|
||||
SDL_FillRect(screen, &bar, yellow);
|
||||
|
||||
for (int i = 1 ; i <= 5 ; i++)
|
||||
{
|
||||
if (weapon[W_PLAYER_WEAPON].ammo[0] >= i) {
|
||||
if(i <= game.maxPlasmaOutput || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
||||
{
|
||||
SDL_FillRect(screen, &bar, yellow);
|
||||
}
|
||||
}
|
||||
else if (i <= game.maxPlasmaOutput)
|
||||
SDL_FillRect(screen, &bar, darkYellow);
|
||||
bar.x += 30;
|
||||
}
|
||||
|
||||
blitText(13);
|
||||
|
||||
bar.w = 25;
|
||||
bar.h = 12;
|
||||
bar.x = 550;
|
||||
bar.y = 571;
|
||||
|
||||
for (int i = 1 ; i <= 5 ; i++)
|
||||
{
|
||||
if (weapon[W_PLAYER_WEAPON].reload[0] <= rate2reload[i]) {
|
||||
if(i <= game.maxPlasmaRate || (SDL_GetTicks() % 1000 > (unsigned)i * 100))
|
||||
{
|
||||
SDL_FillRect(screen, &bar, blue);
|
||||
}
|
||||
}
|
||||
else if (i <= game.maxPlasmaRate)
|
||||
SDL_FillRect(screen, &bar, darkerBlue);
|
||||
bar.x += 30;
|
||||
}
|
||||
|
||||
blitText(4);
|
||||
if (player.shield < 1)
|
||||
return;
|
||||
|
||||
if ((!engine.keyState[KEY_ALTFIRE]) && (player.weaponType[1] == W_LASER) && (engine.eventTimer % 8 == 1))
|
||||
LIMIT_ADD(player.ammo[1], -1, 1, 255);
|
||||
|
||||
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)
|
||||
shieldColor = green;
|
||||
else if ((i >= engine.lowShield) && (i < engine.averageShield))
|
||||
shieldColor = yellow;
|
||||
else
|
||||
shieldColor = red;
|
||||
SDL_FillRect(screen, &bar, shieldColor);
|
||||
bar.x += blockSize;
|
||||
if (player.maxShield < 75)
|
||||
bar.x++;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *faces[] = {
|
||||
"FACE_CHRIS", "FACE_SID", "FACE_KRASS",
|
||||
"FACE_KLINE", "FACE_PHOEBE", "FACE_URSULA",
|
||||
|
|
|
@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define MISC_H
|
||||
|
||||
extern void clearInfoLines();
|
||||
void copyInfoLine(int a, int b);
|
||||
extern void setInfoLine(const char *in, int color);
|
||||
extern void setRadioMessage(signed char face, const char *in, int priority);
|
||||
extern void doInfo();
|
||||
extern int getFace(const char *face);
|
||||
extern void resetLists();
|
||||
|
||||
|
|
Loading…
Reference in New Issue