Flatten Graphics object.

All functions and variables are now defined in graphics.cpp.
Before, the functions would be compiled again and again for every source
file, now it is compiled only once, halving the size of the stripped
starfighter binary.
This commit is contained in:
Guus Sliepen 2011-08-26 23:53:46 +02:00
parent 878e559b6a
commit d7d6dc37bc
24 changed files with 1272 additions and 1242 deletions

View File

@ -62,22 +62,23 @@ int main(int argc, char *argv[])
atexit(cleanUp);
initGraphics();
initSystem(); // Opens video mode and sound
loadFont();
if (cheatAttempt)
{
graphics.clearScreen(graphics.black);
graphics.drawString("That doesn't work anymore", -1, 285, FONT_WHITE);
graphics.drawString("Try harder...", -1, 315, FONT_WHITE);
graphics.updateScreen();
clearScreen(black);
drawString("That doesn't work anymore", -1, 285, FONT_WHITE);
drawString("Try harder...", -1, 315, FONT_WHITE);
updateScreen();
SDL_Delay(2000);
graphics.clearScreen(graphics.black);
graphics.updateScreen();
clearScreen(black);
updateScreen();
SDL_Delay(500);
}
graphics.freeGraphics();
freeGraphics();
loadSound();
initWeapons();
@ -85,7 +86,7 @@ int main(int argc, char *argv[])
initVars();
defineAliens();
graphics.setColorIndexes();
setColorIndexes();
setAllyMessages();

View File

@ -35,7 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "defs.h"
#include "structs.h"
#include "classes.h"
#include "ai.h"
#include "aliens.h"

View File

@ -114,8 +114,8 @@ static void addSmallAsteroid(object *host)
{
enemy[index] = defEnemy[CD_ASTEROID2];
enemy[index].imageIndex[0] = enemy[index].imageIndex[1] = 39 + rand() % 2;
enemy[index].image[0] = graphics.shipShape[enemy[index].imageIndex[0]];
enemy[index].image[1] = graphics.shipShape[enemy[index].imageIndex[1]];
enemy[index].image[0] = shipShape[enemy[index].imageIndex[0]];
enemy[index].image[1] = shipShape[enemy[index].imageIndex[1]];
}
else
{
@ -444,8 +444,8 @@ static void getPreDefinedAliens()
enemy[i].imageIndex[0] += 15;
enemy[i].imageIndex[1] += 15;
enemy[i].image[0] = graphics.shipShape[enemy[i].imageIndex[0]];
enemy[i].image[1] = graphics.shipShape[enemy[i].imageIndex[1]];
enemy[i].image[0] = shipShape[enemy[i].imageIndex[0]];
enemy[i].image[1] = shipShape[enemy[i].imageIndex[1]];
}
}
}
@ -1195,7 +1195,7 @@ void doAliens()
if ((!(theEnemy->flags & FL_DISABLED)) && (theEnemy->classDef != CD_ASTEROID) && (theEnemy->classDef != CD_ASTEROID2))
addEngine(theEnemy);
if ((!(theEnemy->flags & FL_ISCLOAKED)) || (theEnemy->hit > 0))
graphics.blit(graphics.shipShape[shapeToUse], (int)theEnemy->x, (int)theEnemy->y);
blit(shipShape[shapeToUse], (int)theEnemy->x, (int)theEnemy->y);
if (theEnemy->flags & FL_DISABLED)
{
if ((rand() % 10) == 0)
@ -1211,7 +1211,7 @@ void doAliens()
theEnemy->shield--;
if ((theEnemy->x > 0) && (theEnemy->x < 800) && (theEnemy->y > 0) && (theEnemy->y < 600))
{
graphics.blit(theEnemy->image[theEnemy->face], (int)theEnemy->x, (int)theEnemy->y);
blit(theEnemy->image[theEnemy->face], (int)theEnemy->x, (int)theEnemy->y);
addExplosion(theEnemy->x + (rand() % theEnemy->image[0]->w), theEnemy->y + (rand() % theEnemy->image[0]->h), E_BIG_EXPLOSION);
}
if (theEnemy->shield < theEnemy->deathCounter)
@ -1249,10 +1249,10 @@ void setAlienShapes()
{
for (int i = 0 ; i < MAX_DEFALIENS ; i++)
{
if (graphics.shipShape[defEnemy[i].imageIndex[0]] != NULL)
if (shipShape[defEnemy[i].imageIndex[0]] != NULL)
{
defEnemy[i].image[0] = graphics.shipShape[defEnemy[i].imageIndex[0]];
defEnemy[i].image[1] = graphics.shipShape[defEnemy[i].imageIndex[1]];
defEnemy[i].image[0] = shipShape[defEnemy[i].imageIndex[0]];
defEnemy[i].image[1] = shipShape[defEnemy[i].imageIndex[1]];
defEnemy[i].engineX = defEnemy[i].image[0]->w;
defEnemy[i].engineY = (defEnemy[i].image[0]->h / 2);
}

View File

@ -129,7 +129,7 @@ void addBullet(object *theWeapon, object *attacker, int y, int dy)
{
bullet->dx = rrand(-20, 20);
bullet->dy = rrand(-20, 20);
bullet->image[0] = graphics.shape[4];
bullet->image[0] = shape[4];
}
engine.bulletTail->next = bullet;
@ -433,9 +433,9 @@ void fireRay(object *attacker)
ray.h = 3;
ray.w = 800;
int red = SDL_MapRGB(graphics.screen->format, rand() % 256, 0x00, 0x00);
SDL_FillRect(graphics.screen, &ray, red);
graphics.addBuffer(ray.x, ray.y, ray.w, ray.h);
int red = SDL_MapRGB(screen->format, rand() % 256, 0x00, 0x00);
SDL_FillRect(screen, &ray, red);
addBuffer(ray.x, ray.y, ray.w, ray.h);
if (attacker != &player)
{
@ -541,16 +541,16 @@ void doBullets()
if ((bullet->flags & WF_AIMED) || (bullet->flags & WF_THIN_SPREAD))
{
graphics.blit(bullet->image[0], (int)(bullet->x - bullet->dx), (int)(bullet->y - bullet->dy));
blit(bullet->image[0], (int)(bullet->x - bullet->dx), (int)(bullet->y - bullet->dy));
}
if (bullet->id == WT_CHARGER)
{
for (int i = 0 ; i < bullet->damage ; i++)
graphics.blit(bullet->image[0], (int)(bullet->x - rrand(-(bullet->damage / 3), 0)), (int)(bullet->y + rrand(-3, 3)));
blit(bullet->image[0], (int)(bullet->x - rrand(-(bullet->damage / 3), 0)), (int)(bullet->y + rrand(-3, 3)));
}
graphics.blit(bullet->image[0], (int)bullet->x, (int)bullet->y);
blit(bullet->image[0], (int)bullet->x, (int)bullet->y);
bullet->x += bullet->dx;
bullet->y += bullet->dy;

View File

@ -59,9 +59,9 @@ object *addCargo(object *owner, int cargoType)
cargo[index].dx = 0;
cargo[index].dy = 0;
cargo[index].collectType = cargoType;
cargo[index].image[0] = graphics.shape[32];
cargo[index].image[0] = shape[32];
if (cargoType == P_PHOEBE)
cargo[index].image[0] = graphics.shipShape[20];
cargo[index].image[0] = shipShape[20];
return &cargo[index];
}
@ -97,7 +97,7 @@ void doCargo()
continue;
}
graphics.blit(cargo[i].image[0], (int)cargo[i].x, (int)cargo[i].y);
blit(cargo[i].image[0], (int)cargo[i].x, (int)cargo[i].y);
cargo[i].x += engine.ssx;
cargo[i].y += engine.ssy;
@ -113,7 +113,7 @@ void doCargo()
// draw the chain link line
for (int j = 0 ; j < 10 ; j++)
{
graphics.blit(graphics.shape[30], (int)chainX, (int)chainY);
blit(shape[30], (int)chainX, (int)chainY);
chainX -= dx;
chainY -= dy;
}

View File

@ -1,610 +0,0 @@
/*
Copyright (C) 2003 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
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
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
extern void showErrorAndExit(int errorId, const char *name);
class Graphics {
unsigned long frameLimit;
int thirds;
public:
Uint32 red;
Uint32 darkRed;
Uint32 yellow;
Uint32 darkYellow;
Uint32 green;
Uint32 darkGreen;
Uint32 blue;
Uint32 darkBlue;
Uint32 darkerBlue;
Uint32 black;
Uint32 white;
Uint32 lightGrey;
Uint32 darkGrey;
SDL_Surface *screen, *background;
SDL_Surface *shape[MAX_SHAPES];
SDL_Surface *shipShape[MAX_SHIPSHAPES];
SDL_Surface *fontShape[MAX_FONTSHAPES];
SDL_Surface *shopSurface[MAX_SHOPSHAPES];
bRect *bufferHead;
bRect *bufferTail;
textObject textShape[MAX_TEXTSHAPES];
SDL_Rect blitRect;
SDL_Surface *messageBox;
Graphics()
{
bufferHead = new bRect;
bufferHead->next = NULL;
bufferTail = bufferHead;
for (int i = 0 ; i < MAX_SHAPES ; i++)
shape[i] = NULL;
for (int i = 0 ; i < MAX_SHIPSHAPES ; i++)
shipShape[i] = NULL;
for (int i = 0 ; i < MAX_TEXTSHAPES ; i++)
textShape[i].image = NULL;
for (int i = 0 ; i < MAX_SHOPSHAPES ; i++)
shopSurface[i] = NULL;
for (int i = 0 ; i < MAX_FONTSHAPES ; i++)
fontShape[i] = NULL;
background = NULL;
messageBox = NULL;
frameLimit = 0;
thirds = 0;
screen = NULL;
}
SDL_Surface *setTransparent(SDL_Surface *sprite)
{
SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(sprite->format, 0, 0, 0));
return sprite;
}
void addBuffer(int x, int y, int w, int h)
{
bRect *rect = new bRect;
rect->next = NULL;
rect->x = x;
rect->y = y;
rect->w = w;
rect->h = h;
bufferTail->next = rect;
bufferTail = rect;
}
void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest)
{
// Exit early if image is not on dest at all
if(x + image->w < 0 || x >= dest->w || y + image->h < 0 || y >= dest->h)
return;
// Set up a rectangle to draw to
blitRect.x = x;
blitRect.y = y;
blitRect.w = image->w;
blitRect.h = image->h;
/* Blit onto the destination surface */
if(SDL_BlitSurface(image, NULL, dest, &blitRect) < 0)
{
printf("BlitSurface error: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
// Only ff it is to the screen, mark the region as damaged
if(dest == screen)
addBuffer(blitRect.x, blitRect.y, blitRect.w, blitRect.h);
}
void blit(SDL_Surface *image, int x, int y)
{
blit(image, x, y, screen);
}
void blitText(int i)
{
blit(textShape[i].image, (int)textShape[i].x, (int)textShape[i].y, screen);
}
void flushBuffer()
{
bRect *prevRect = bufferHead;
bRect *rect = bufferHead;
bufferTail = bufferHead;
while (rect->next != NULL)
{
rect = rect->next;
prevRect->next = rect->next;
delete rect;
rect = prevRect;
}
bufferHead->next = NULL;
}
void unBuffer()
{
bRect *prevRect = bufferHead;
bRect *rect = bufferHead;
bufferTail = bufferHead;
while (rect->next != NULL)
{
rect = rect->next;
blitRect.x = rect->x;
blitRect.y = rect->y;
blitRect.w = rect->w;
blitRect.h = rect->h;
if (SDL_BlitSurface(background, &blitRect, screen, &blitRect) < 0)
{
printf("BlitSurface error: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
prevRect->next = rect->next;
delete rect;
rect = prevRect;
}
bufferHead->next = NULL;
}
/*
In 16 bit mode this is slow. VERY slow. Don't write directly to a surface
that constantly needs updating (eg - the main game screen)
*/
int renderString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest)
{
SDL_Rect area;
area.x = x;
area.y = y;
area.w = 8;
area.h = 14;
SDL_Rect letter;
letter.y = 0;
letter.w = 8;
letter.h = 14;
while (*in != '\0')
{
if (*in != 32)
{
letter.x = (*in - 33);
letter.x *= 8;
letter.x--; // Temp fix
/* Blit onto the screen surface */
if(SDL_BlitSurface(fontShape[fontColor], &letter, dest, &area) < 0)
{
printf("BlitSurface error: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
}
area.x += 9;
if (wrap)
{
if ((area.x > (dest->w - 70)) && (*in == 32))
{
area.y += 16;
area.x = x;
}
}
in++;
}
return area.y;
}
int drawString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest)
{
renderString(in, x, y - 1, FONT_OUTLINE, wrap, dest);
renderString(in, x, y + 1, FONT_OUTLINE, wrap, dest);
renderString(in, x, y + 2, FONT_OUTLINE, wrap, dest);
renderString(in, x - 1, y, FONT_OUTLINE, wrap, dest);
renderString(in, x - 2, y, FONT_OUTLINE, wrap, dest);
renderString(in, x + 1, y, FONT_OUTLINE, wrap, dest);
return renderString(in, x, y, fontColor, wrap, dest);
}
int drawString(const char *in, int x, int y, int fontColor, SDL_Surface *dest)
{
if (x == -1)
x = (dest->w - (strlen(in) * 9)) / 2;
return drawString(in, x, y, fontColor, 0, dest);
}
int drawString(const char *in, int x, int y, int fontColor)
{
if (x == -1)
x = (800 - (strlen(in) * 9)) / 2;
return drawString(in, x, y, fontColor, 0, screen);
}
/*
Finds the location of the requested color within the palette and returns
it's number. This colors are used for drawing rectangles, circle, etc in
the correct colors.
*/
void setColorIndexes()
{
red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00);
darkRed = SDL_MapRGB(screen->format, 0x66, 0x00, 0x00);
yellow = SDL_MapRGB(screen->format, 0xff, 0xff, 0x00);
darkYellow = SDL_MapRGB(screen->format, 0x66, 0x66, 0x00);
green = SDL_MapRGB(screen->format, 0x00, 0xff, 0x00);
darkGreen = SDL_MapRGB(screen->format, 0x00, 0x66, 0x00);
blue = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff);
darkBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x99);
darkerBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x44);
black = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
white = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff);
lightGrey = SDL_MapRGB(screen->format, 0xcc, 0xcc, 0xcc);
darkGrey = SDL_MapRGB(screen->format, 0x99, 0x99, 0x99);
}
/*
Draws the background surface that has been loaded
*/
void drawBackGround()
{
blit(background, 0, 0, screen);
}
void clearScreen(Uint32 color)
{
SDL_FillRect(screen, NULL, color);
}
void updateScreen()
{
SDL_Flip(screen);
}
/*
* Delay until the next 60 Hz frame
*/
void delayFrame()
{
unsigned long now = SDL_GetTicks();
// Add 16 2/3 to frameLimit
frameLimit += 16;
if(thirds >= 2) {
thirds = 0;
} else {
thirds++;
frameLimit++;
}
if(now < frameLimit)
SDL_Delay(frameLimit - now);
else
frameLimit = now;
}
/*
* Set the pixel at (x, y) to the given value
* NOTE: The surface must be locked before calling this!
*/
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to set */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *)p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
} else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}
void drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col)
{
int counter = 0;
if ( SDL_MUSTLOCK(dest) ) {
if ( SDL_LockSurface(dest) < 0 ) {
printf("Can't lock screen: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
}
while(1)
{
putpixel(dest, x1, y1, col);
if (x1 > x2) x1--;
if (x1 < x2) x1++;
if (y1 > y2) y1--;
if (y1 < y2) y1++;
if ((x1 == x2) && (y1 == y2))
{break;}
if (counter == 1000)
{printf("Loop Error!\n"); break;}
counter++;
}
if ( SDL_MUSTLOCK(dest) ) {
SDL_UnlockSurface(dest);
}
}
void drawLine(int x1, int y1, int x2, int y2, int col)
{
drawLine(screen, x1, y1, x2, y2, col);
}
/*
A quick(?) circle draw function. This code was posted to the SDL
mailing list... I didn't write it myself.
*/
void circle(int xc, int yc, int R, SDL_Surface *PIX, int col)
{
int x = 0, xx = 0;
int y = R, yy = R+R;
int p = 1-R;
putpixel(PIX, xc, yc - y, col);
putpixel(PIX, xc, yc + y, col);
putpixel(PIX, xc - y, yc, col);
putpixel(PIX, xc + y, yc, col);
while(x < y)
{
xx += 2;
++x;
if (p >= 0)
{
yy -= 2;
--y;
p -= yy;
}
p += xx + 1;
putpixel(PIX, xc - x, yc - y, col);
putpixel(PIX, xc + x, yc - y, col);
putpixel(PIX, xc - x, yc + y, col);
putpixel(PIX, xc + x, yc + y, col);
putpixel(PIX, xc - y, yc - x, col);
putpixel(PIX, xc + y, yc - x, col);
putpixel(PIX, xc - y, yc + x, col);
putpixel(PIX, xc + y, yc + x, col);
}
if ((x = y))
{
putpixel(PIX, xc - x, yc - y, col);
putpixel(PIX, xc + x, yc - y, col);
putpixel(PIX, xc - x, yc + y, col);
putpixel(PIX, xc + x, yc + y, col);
}
}
void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Rect r = {x, y, w, h};
SDL_FillRect(dest, &r, SDL_MapRGB(screen->format, red, green, blue));
drawLine(dest, x, y, x + w, y, SDL_MapRGB(screen->format, 255, 255, 255));
drawLine(dest, x, y, x, y + h, SDL_MapRGB(screen->format, 255, 255, 255));
drawLine(dest, x, y + h, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128));
drawLine(dest, x + w, y + 1, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128));
}
void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
{
blevelRect(screen, x, y, w, h, red, green, blue);
}
SDL_Surface *createSurface(int width, int height)
{
SDL_Surface *surface, *newImage;
Uint32 rmask, gmask, bmask, amask;
/* SDL interprets each pixel as a 32-bit number, so our masks must depend
on the endianness (byte order) of the machine */
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask);
if (surface == NULL) {
printf("CreateRGBSurface failed: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
newImage = SDL_DisplayFormat(surface);
SDL_FreeSurface(surface);
return newImage;
}
SDL_Surface *textSurface(const char *inString, int color)
{
SDL_Surface *surface = createSurface(strlen(inString) * 9, 16);
drawString(inString, 1, 1, color, surface);
return setTransparent(surface);
}
void textSurface(int index, const char *inString, int x, int y, int fontColor)
{
/* Shortcut: if we already rendered the same string in the same color, don't render it again. */
if(textShape[index].text && textShape[index].image && textShape[index].fontColor == fontColor && !strcmp(textShape[index].text, inString)) {
textShape[index].x = x;
textShape[index].y = y;
if (x == -1)
textShape[index].x = (800 - textShape[index].image->w) / 2;
return;
}
strcpy(textShape[index].text, inString);
textShape[index].x = x;
textShape[index].y = y;
textShape[index].fontColor = fontColor;
if (textShape[index].image != NULL)
{
SDL_FreeSurface(textShape[index].image);
}
textShape[index].image = textSurface(inString, fontColor);
if (x == -1)
textShape[index].x = (800 - textShape[index].image->w) / 2;
}
SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Surface *surface = createSurface(width, height);
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue));
SDL_SetAlpha(surface, SDL_SRCALPHA|SDL_RLEACCEL, 128);
return surface;
}
void createMessageBox(SDL_Surface *face, const char *message, signed char transparent)
{
if (messageBox != NULL)
{
SDL_FreeSurface(messageBox);
messageBox = NULL;
}
if (transparent)
messageBox = alphaRect(550, 60, 0x00, 0x00, 0x00);
else
messageBox = createSurface(550, 60);
signed char x = 60;
if (face != NULL)
{
blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0xaa);
blit(face, 5, 5, messageBox);
}
else
{
blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0x00);
x = 10;
}
drawString(message, x, 5, FONT_WHITE, 1, messageBox);
}
void freeGraphics()
{
for (int i = 0 ; i < MAX_SHAPES ; i++)
{
if (shape[i] != NULL)
{
SDL_FreeSurface(shape[i]);
shape[i] = NULL;
}
}
for (int i = 0 ; i < MAX_SHIPSHAPES ; i++)
{
if (shipShape[i] != NULL)
{
SDL_FreeSurface(shipShape[i]);
shipShape[i] = NULL;
}
}
for (int i = 0 ; i < MAX_TEXTSHAPES ; i++)
{
if (textShape[i].image != NULL)
{
SDL_FreeSurface(textShape[i].image);
textShape[i].image = NULL;
}
}
for (int i = 0 ; i < MAX_SHOPSHAPES ; i++)
{
if (shopSurface[i] != NULL)
{
SDL_FreeSurface(shopSurface[i]);
shopSurface[i] = NULL;
}
}
if (messageBox != NULL)
{
SDL_FreeSurface(messageBox);
messageBox = NULL;
}
}
};

View File

@ -108,52 +108,52 @@ void addCollectable(float x, float y, int type, int value, int life)
switch(type)
{
case P_CASH:
collectable->image = graphics.shape[24];
collectable->image = shape[24];
break;
case P_ROCKET:
collectable->image = graphics.shape[49];
collectable->image = shape[49];
break;
case P_PLASMA_AMMO:
collectable->image = graphics.shape[25];
collectable->image = shape[25];
break;
case P_SHIELD:
collectable->image = graphics.shape[26];
collectable->image = shape[26];
break;
case P_PLASMA_SHOT:
collectable->image = graphics.shape[27];
collectable->image = shape[27];
break;
case P_PLASMA_RATE:
collectable->image = graphics.shape[28];
collectable->image = shape[28];
break;
case P_PLASMA_DAMAGE:
collectable->image = graphics.shape[29];
collectable->image = shape[29];
break;
case P_CARGO:
collectable->image = graphics.shape[32];
collectable->image = shape[32];
break;
case P_SUPER:
collectable->image = graphics.shape[50];
collectable->image = shape[50];
break;
case P_MINE:
collectable->image = graphics.shape[31];
collectable->image = shape[31];
break;
case P_SLAVES:
case P_ESCAPEPOD:
collectable->image = graphics.shape[45];
collectable->image = shape[45];
break;
case P_ORE:
collectable->image = graphics.shape[46 + rand() % 3];
collectable->image = shape[46 + rand() % 3];
break;
}
@ -243,7 +243,7 @@ void doCollectables()
if (collectable->active)
{
if ((collectable->x + collectable->image->w > 0) && (collectable->x < 800) && (collectable->y + collectable->image->h > 0) && (collectable->y < 600))
graphics.blit(collectable->image, (int)collectable->x, (int)collectable->y);
blit(collectable->image, (int)collectable->x, (int)collectable->y);
collectable->x += engine.ssx;
collectable->y += engine.ssy;

View File

@ -27,20 +27,20 @@ void updateCommsSurface(SDL_Surface *comms)
char string[255];
graphics.blevelRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00);
graphics.blit(graphics.shape[FACE_CHRIS], 20, 15, comms);
graphics.drawString("Chris Bainfield", 80, 15, FONT_WHITE, comms);
blevelRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00);
blit(shape[FACE_CHRIS], 20, 15, comms);
drawString("Chris Bainfield", 80, 15, FONT_WHITE, comms);
sprintf(string, "Current Location: %s", systemPlanet[currentGame.stationedPlanet].name);
graphics.drawString(string, 80, 35, FONT_WHITE, comms);
drawString(string, 80, 35, FONT_WHITE, comms);
}
void createCommsSurface(SDL_Surface *comms)
{
engine.commsSection = 0;
graphics.blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
graphics.drawString("+++ RECIEVED MESSAGES +++", 115, 80, FONT_GREEN, comms);
drawString("+++ RECIEVED MESSAGES +++", 115, 80, FONT_GREEN, comms);
int yOffset;
@ -49,11 +49,11 @@ void createCommsSurface(SDL_Surface *comms)
if ((systemPlanet[i].messageSlot != -1) && (systemPlanet[i].missionCompleted == 0))
{
yOffset = systemPlanet[i].messageSlot * 60;
graphics.blevelRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77);
graphics.blit(graphics.shape[systemPlanet[i].faceImage], 20, 110 + yOffset, comms);
graphics.drawString(systemPlanet[i].from, 80, 110 + yOffset, FONT_WHITE, comms);
graphics.drawString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, comms);
graphics.drawString("INCOMPLETE", 350, 110 + yOffset, FONT_RED, comms);
blevelRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77);
blit(shape[systemPlanet[i].faceImage], 20, 110 + yOffset, comms);
drawString(systemPlanet[i].from, 80, 110 + yOffset, FONT_WHITE, comms);
drawString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, comms);
drawString("INCOMPLETE", 350, 110 + yOffset, FONT_RED, comms);
}
}
@ -83,7 +83,7 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
if (mission == -1)
return;
graphics.blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
strcpy(string, "");
sprintf(string, "data/brief%d.txt", mission);
@ -98,7 +98,7 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
fscanf(fp, "%[^\n]%*c", name);
sprintf(string, "+++ Communication with %s +++", name);
graphics.drawString(string, -1, 20, FONT_GREEN, comms);
drawString(string, -1, 20, FONT_GREEN, comms);
fscanf(fp, "%d%*c", &lines);
@ -108,12 +108,12 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
faceNumber = getFace(string);
if (faceNumber > -1)
{
graphics.blit(graphics.shape[faceNumber], 10, y, comms);
blit(shape[faceNumber], 10, y, comms);
col = FONT_WHITE;
}
else
{
newY = graphics.drawString(string, 80, y, col, 1, comms) + 25;
newY = drawString(string, 80, y, col, 1, comms) + 25;
if (newY < y + 60)
newY += (60 - (newY - y));
y = newY;
@ -122,8 +122,8 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
fclose(fp);
graphics.blevelRect(comms, 5, comms->h - 28, 180, 20, 0x25, 0x00, 0x00);
graphics.drawString("RETURN TO MESSAGES", 15, comms->h - 25, FONT_WHITE, 1, comms);
blevelRect(comms, 5, comms->h - 28, 180, 20, 0x25, 0x00, 0x00);
drawString("RETURN TO MESSAGES", 15, comms->h - 25, FONT_WHITE, 1, comms);
engine.commsSection = 1;
}

View File

@ -36,7 +36,7 @@ void addExplosion(float x, float y, int type)
explosion->y = y;
explosion->thinktime = 28;
explosion->face = type;
explosion->image[0] = graphics.shape[type];
explosion->image[0] = shape[type];
engine.explosionTail->next = explosion;
engine.explosionTail = explosion;
@ -80,7 +80,7 @@ void doExplosions()
explosion->y += engine.ssy;
if (isOnScreen((int)explosion->x, (int)explosion->y, explosion->image[0]->w, explosion->image[0]->h))
graphics.blit(explosion->image[0], (int)explosion->x, (int)explosion->y);
blit(explosion->image[0], (int)explosion->x, (int)explosion->y);
if(rand() % 7 == 0)
{
@ -93,7 +93,7 @@ void doExplosions()
else
{
explosion->face++;
explosion->image[0] = graphics.shape[explosion->face];
explosion->image[0] = shape[explosion->face];
}
}
}

View File

@ -127,8 +127,8 @@ int mainGameLoop()
}
}
graphics.drawBackGround();
graphics.flushBuffer();
drawBackGround();
flushBuffer();
// Default to no aliens dead...
engine.allAliensDead = 0;
@ -138,7 +138,7 @@ int mainGameLoop()
while (engine.done != 1)
{
graphics.updateScreen();
updateScreen();
if ((allMissionsCompleted()) && (engine.missionCompleteTimer == 0))
{
@ -215,7 +215,7 @@ int mainGameLoop()
getPlayerInput();
}
graphics.unBuffer();
unBuffer();
doStarfield();
doCollectables();
doBullets();
@ -231,7 +231,7 @@ int mainGameLoop()
while (engine.paused)
{
engine.done = checkPauseRequest();
graphics.delayFrame();
delayFrame();
}
if ((currentGame.area == 24) && (engine.addAliens > -1))
@ -256,8 +256,8 @@ int mainGameLoop()
if ((currentGame.area == 5) && (enemy[WC_BOSS].flags & FL_ESCAPED))
{
playSound(SFX_DEATH);
graphics.clearScreen(graphics.white);
graphics.updateScreen();
clearScreen(white);
updateScreen();
for (int i = 0 ; i < 300 ; i++)
{
SDL_Delay(10);
@ -268,10 +268,10 @@ int mainGameLoop()
break;
}
graphics.delayFrame();
delayFrame();
}
graphics.flushBuffer();
flushBuffer();
if ((player.shield > 0) && (!missionFailed()))
{

View File

@ -20,9 +20,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Starfighter.h"
Graphics graphics;
Star star[200];
static unsigned long frameLimit;
static int thirds;
Uint32 red;
Uint32 darkRed;
Uint32 yellow;
Uint32 darkYellow;
Uint32 green;
Uint32 darkGreen;
Uint32 blue;
Uint32 darkBlue;
Uint32 darkerBlue;
Uint32 black;
Uint32 white;
Uint32 lightGrey;
Uint32 darkGrey;
SDL_Surface *screen, *background;
SDL_Surface *shape[MAX_SHAPES];
SDL_Surface *shipShape[MAX_SHIPSHAPES];
SDL_Surface *fontShape[MAX_FONTSHAPES];
SDL_Surface *shopSurface[MAX_SHOPSHAPES];
bRect *bufferHead;
bRect *bufferTail;
textObject textShape[MAX_TEXTSHAPES];
SDL_Surface *messageBox;
bool collision(float x0, float y0, int w0, int h0, float x2, float y2, int w1, int h1)
{
float x1 = x0 + w0;
@ -76,44 +101,607 @@ bool collision(collectables *object1, object *object2)
return !(x1<x2 || x3<x0 || y1<y2 || y3<y0);
}
void initGraphics()
{
bufferHead = new bRect;
bufferHead->next = NULL;
bufferTail = bufferHead;
for (int i = 0 ; i < MAX_SHAPES ; i++)
shape[i] = NULL;
for (int i = 0 ; i < MAX_SHIPSHAPES ; i++)
shipShape[i] = NULL;
for (int i = 0 ; i < MAX_TEXTSHAPES ; i++)
textShape[i].image = NULL;
for (int i = 0 ; i < MAX_SHOPSHAPES ; i++)
shopSurface[i] = NULL;
for (int i = 0 ; i < MAX_FONTSHAPES ; i++)
fontShape[i] = NULL;
background = NULL;
messageBox = NULL;
frameLimit = 0;
thirds = 0;
screen = NULL;
}
SDL_Surface *setTransparent(SDL_Surface *sprite)
{
SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(sprite->format, 0, 0, 0));
return sprite;
}
void addBuffer(int x, int y, int w, int h)
{
bRect *rect = new bRect;
rect->next = NULL;
rect->x = x;
rect->y = y;
rect->w = w;
rect->h = h;
bufferTail->next = rect;
bufferTail = rect;
}
void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest)
{
// Exit early if image is not on dest at all
if(x + image->w < 0 || x >= dest->w || y + image->h < 0 || y >= dest->h)
return;
// Set up a rectangle to draw to
SDL_Rect blitRect;
blitRect.x = x;
blitRect.y = y;
blitRect.w = image->w;
blitRect.h = image->h;
/* Blit onto the destination surface */
if(SDL_BlitSurface(image, NULL, dest, &blitRect) < 0)
{
printf("BlitSurface error: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
// Only ff it is to the screen, mark the region as damaged
if(dest == screen)
addBuffer(blitRect.x, blitRect.y, blitRect.w, blitRect.h);
}
void blit(SDL_Surface *image, int x, int y)
{
blit(image, x, y, screen);
}
void blitText(int i)
{
blit(textShape[i].image, (int)textShape[i].x, (int)textShape[i].y, screen);
}
void flushBuffer()
{
bRect *prevRect = bufferHead;
bRect *rect = bufferHead;
bufferTail = bufferHead;
while (rect->next != NULL)
{
rect = rect->next;
prevRect->next = rect->next;
delete rect;
rect = prevRect;
}
bufferHead->next = NULL;
}
void unBuffer()
{
bRect *prevRect = bufferHead;
bRect *rect = bufferHead;
bufferTail = bufferHead;
while (rect->next != NULL)
{
rect = rect->next;
SDL_Rect blitRect;
blitRect.x = rect->x;
blitRect.y = rect->y;
blitRect.w = rect->w;
blitRect.h = rect->h;
if (SDL_BlitSurface(background, &blitRect, screen, &blitRect) < 0)
{
printf("BlitSurface error: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
prevRect->next = rect->next;
delete rect;
rect = prevRect;
}
bufferHead->next = NULL;
}
/*
In 16 bit mode this is slow. VERY slow. Don't write directly to a surface
that constantly needs updating (eg - the main game screen)
*/
static int renderString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest)
{
SDL_Rect area;
area.x = x;
area.y = y;
area.w = 8;
area.h = 14;
SDL_Rect letter;
letter.y = 0;
letter.w = 8;
letter.h = 14;
while (*in != '\0')
{
if (*in != 32)
{
letter.x = (*in - 33);
letter.x *= 8;
letter.x--; // Temp fix
/* Blit onto the screen surface */
if(SDL_BlitSurface(fontShape[fontColor], &letter, dest, &area) < 0)
{
printf("BlitSurface error: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
}
area.x += 9;
if (wrap)
{
if ((area.x > (dest->w - 70)) && (*in == 32))
{
area.y += 16;
area.x = x;
}
}
in++;
}
return area.y;
}
int drawString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest)
{
renderString(in, x, y - 1, FONT_OUTLINE, wrap, dest);
renderString(in, x, y + 1, FONT_OUTLINE, wrap, dest);
renderString(in, x, y + 2, FONT_OUTLINE, wrap, dest);
renderString(in, x - 1, y, FONT_OUTLINE, wrap, dest);
renderString(in, x - 2, y, FONT_OUTLINE, wrap, dest);
renderString(in, x + 1, y, FONT_OUTLINE, wrap, dest);
return renderString(in, x, y, fontColor, wrap, dest);
}
int drawString(const char *in, int x, int y, int fontColor, SDL_Surface *dest)
{
if (x == -1)
x = (dest->w - (strlen(in) * 9)) / 2;
return drawString(in, x, y, fontColor, 0, dest);
}
int drawString(const char *in, int x, int y, int fontColor)
{
if (x == -1)
x = (800 - (strlen(in) * 9)) / 2;
return drawString(in, x, y, fontColor, 0, screen);
}
/*
Finds the location of the requested color within the palette and returns
it's number. This colors are used for drawing rectangles, circle, etc in
the correct colors.
*/
void setColorIndexes()
{
red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00);
darkRed = SDL_MapRGB(screen->format, 0x66, 0x00, 0x00);
yellow = SDL_MapRGB(screen->format, 0xff, 0xff, 0x00);
darkYellow = SDL_MapRGB(screen->format, 0x66, 0x66, 0x00);
green = SDL_MapRGB(screen->format, 0x00, 0xff, 0x00);
darkGreen = SDL_MapRGB(screen->format, 0x00, 0x66, 0x00);
blue = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff);
darkBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x99);
darkerBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x44);
black = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
white = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff);
lightGrey = SDL_MapRGB(screen->format, 0xcc, 0xcc, 0xcc);
darkGrey = SDL_MapRGB(screen->format, 0x99, 0x99, 0x99);
}
/*
Draws the background surface that has been loaded
*/
void drawBackGround()
{
blit(background, 0, 0, screen);
}
void clearScreen(Uint32 color)
{
SDL_FillRect(screen, NULL, color);
}
void updateScreen()
{
SDL_Flip(screen);
}
/*
* Delay until the next 60 Hz frame
*/
void delayFrame()
{
unsigned long now = SDL_GetTicks();
// Add 16 2/3 to frameLimit
frameLimit += 16;
if(thirds >= 2) {
thirds = 0;
} else {
thirds++;
frameLimit++;
}
if(now < frameLimit)
SDL_Delay(frameLimit - now);
else
frameLimit = now;
}
/*
* Set the pixel at (x, y) to the given value
* NOTE: The surface must be locked before calling this!
*/
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to set */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *)p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
} else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}
void drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col)
{
int counter = 0;
if ( SDL_MUSTLOCK(dest) ) {
if ( SDL_LockSurface(dest) < 0 ) {
printf("Can't lock screen: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
}
while(1)
{
putpixel(dest, x1, y1, col);
if (x1 > x2) x1--;
if (x1 < x2) x1++;
if (y1 > y2) y1--;
if (y1 < y2) y1++;
if ((x1 == x2) && (y1 == y2))
{break;}
if (counter == 1000)
{printf("Loop Error!\n"); break;}
counter++;
}
if ( SDL_MUSTLOCK(dest) ) {
SDL_UnlockSurface(dest);
}
}
void drawLine(int x1, int y1, int x2, int y2, int col)
{
drawLine(screen, x1, y1, x2, y2, col);
}
/*
A quick(?) circle draw function. This code was posted to the SDL
mailing list... I didn't write it myself.
*/
void circle(int xc, int yc, int R, SDL_Surface *PIX, int col)
{
int x = 0, xx = 0;
int y = R, yy = R+R;
int p = 1-R;
putpixel(PIX, xc, yc - y, col);
putpixel(PIX, xc, yc + y, col);
putpixel(PIX, xc - y, yc, col);
putpixel(PIX, xc + y, yc, col);
while(x < y)
{
xx += 2;
++x;
if (p >= 0)
{
yy -= 2;
--y;
p -= yy;
}
p += xx + 1;
putpixel(PIX, xc - x, yc - y, col);
putpixel(PIX, xc + x, yc - y, col);
putpixel(PIX, xc - x, yc + y, col);
putpixel(PIX, xc + x, yc + y, col);
putpixel(PIX, xc - y, yc - x, col);
putpixel(PIX, xc + y, yc - x, col);
putpixel(PIX, xc - y, yc + x, col);
putpixel(PIX, xc + y, yc + x, col);
}
if ((x = y))
{
putpixel(PIX, xc - x, yc - y, col);
putpixel(PIX, xc + x, yc - y, col);
putpixel(PIX, xc - x, yc + y, col);
putpixel(PIX, xc + x, yc + y, col);
}
}
void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Rect r = {x, y, w, h};
SDL_FillRect(dest, &r, SDL_MapRGB(screen->format, red, green, blue));
drawLine(dest, x, y, x + w, y, SDL_MapRGB(screen->format, 255, 255, 255));
drawLine(dest, x, y, x, y + h, SDL_MapRGB(screen->format, 255, 255, 255));
drawLine(dest, x, y + h, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128));
drawLine(dest, x + w, y + 1, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128));
}
void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
{
blevelRect(screen, x, y, w, h, red, green, blue);
}
SDL_Surface *createSurface(int width, int height)
{
SDL_Surface *surface, *newImage;
Uint32 rmask, gmask, bmask, amask;
/* SDL interprets each pixel as a 32-bit number, so our masks must depend
on the endianness (byte order) of the machine */
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask);
if (surface == NULL) {
printf("CreateRGBSurface failed: %s\n", SDL_GetError());
showErrorAndExit(2, "");
}
newImage = SDL_DisplayFormat(surface);
SDL_FreeSurface(surface);
return newImage;
}
SDL_Surface *textSurface(const char *inString, int color)
{
SDL_Surface *surface = createSurface(strlen(inString) * 9, 16);
drawString(inString, 1, 1, color, surface);
return setTransparent(surface);
}
void textSurface(int index, const char *inString, int x, int y, int fontColor)
{
/* Shortcut: if we already rendered the same string in the same color, don't render it again. */
if(textShape[index].text && textShape[index].image && textShape[index].fontColor == fontColor && !strcmp(textShape[index].text, inString)) {
textShape[index].x = x;
textShape[index].y = y;
if (x == -1)
textShape[index].x = (800 - textShape[index].image->w) / 2;
return;
}
strcpy(textShape[index].text, inString);
textShape[index].x = x;
textShape[index].y = y;
textShape[index].fontColor = fontColor;
if (textShape[index].image != NULL)
{
SDL_FreeSurface(textShape[index].image);
}
textShape[index].image = textSurface(inString, fontColor);
if (x == -1)
textShape[index].x = (800 - textShape[index].image->w) / 2;
}
SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Surface *surface = createSurface(width, height);
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue));
SDL_SetAlpha(surface, SDL_SRCALPHA|SDL_RLEACCEL, 128);
return surface;
}
void createMessageBox(SDL_Surface *face, const char *message, signed char transparent)
{
if (messageBox != NULL)
{
SDL_FreeSurface(messageBox);
messageBox = NULL;
}
if (transparent)
messageBox = alphaRect(550, 60, 0x00, 0x00, 0x00);
else
messageBox = createSurface(550, 60);
signed char x = 60;
if (face != NULL)
{
blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0xaa);
blit(face, 5, 5, messageBox);
}
else
{
blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0x00);
x = 10;
}
drawString(message, x, 5, FONT_WHITE, 1, messageBox);
}
void freeGraphics()
{
for (int i = 0 ; i < MAX_SHAPES ; i++)
{
if (shape[i] != NULL)
{
SDL_FreeSurface(shape[i]);
shape[i] = NULL;
}
}
for (int i = 0 ; i < MAX_SHIPSHAPES ; i++)
{
if (shipShape[i] != NULL)
{
SDL_FreeSurface(shipShape[i]);
shipShape[i] = NULL;
}
}
for (int i = 0 ; i < MAX_TEXTSHAPES ; i++)
{
if (textShape[i].image != NULL)
{
SDL_FreeSurface(textShape[i].image);
textShape[i].image = NULL;
}
}
for (int i = 0 ; i < MAX_SHOPSHAPES ; i++)
{
if (shopSurface[i] != NULL)
{
SDL_FreeSurface(shopSurface[i]);
shopSurface[i] = NULL;
}
}
if (messageBox != NULL)
{
SDL_FreeSurface(messageBox);
messageBox = NULL;
}
}
SDL_Surface *loadImage(const char *filename)
{
SDL_Surface *image, *newImage;
SDL_Surface *image, *newImage;
#if USEPACK
unpack(filename, PAK_IMG);
image = IMG_Load_RW(engine.sdlrw, 1);
#else
image = IMG_Load(filename);
#endif
#if USEPACK
unpack(filename, PAK_IMG);
image = IMG_Load_RW(engine.sdlrw, 1);
#else
image = IMG_Load(filename);
#endif
if (image == NULL) {
printf("Couldn't load %s: %s\n", filename, SDL_GetError());
showErrorAndExit(0, filename);
}
if (image == NULL) {
printf("Couldn't load %s: %s\n", filename, SDL_GetError());
showErrorAndExit(0, filename);
}
newImage = SDL_DisplayFormat(image);
if ( newImage ) {
SDL_FreeSurface(image);
} else {
// This happens when we are loading the window icon image
newImage = image;
}
newImage = SDL_DisplayFormat(image);
if ( newImage ) {
SDL_FreeSurface(image);
} else {
// This happens when we are loading the window icon image
newImage = image;
}
return graphics.setTransparent(newImage);
return setTransparent(newImage);
}
/*
Simply draws the stars in their positions on screen and moves
them around. They are wrapped around using the wrapFloat()
function, as defined above, and putpixel as defined in graphics.cpp
function, as defined above, and putpixel as defined in cpp
*/
void doStarfield()
{
/* Lock the screen for direct access to the pixels */
if (SDL_MUSTLOCK(graphics.screen))
if (SDL_MUSTLOCK(screen))
{
if (SDL_LockSurface(graphics.screen) < 0 )
if (SDL_LockSurface(screen) < 0 )
{
showErrorAndExit(2, "");
}
@ -126,27 +714,27 @@ void doStarfield()
for (int i = 0 ; i < 200 ; i++)
{
if (star[i].speed == 3)
color = graphics.white;
color = white;
else if (star[i].speed == 2)
color = graphics.lightGrey;
color = lightGrey;
else if (star[i].speed == 1)
color = graphics.darkGrey;
color = darkGrey;
wrapFloat(&(star[i].x += (engine.ssx * star[i].speed)), 0, 799);
wrapFloat(&(star[i].y += (engine.ssy * star[i].speed)), 0, 599);
graphics.putpixel(graphics.screen, (int)star[i].x, (int)star[i].y, color);
putpixel(screen, (int)star[i].x, (int)star[i].y, color);
r.x = (int)star[i].x;
r.y = (int)star[i].y;
r.w = 1;
r.h = 1;
graphics.addBuffer(r.x, r.y, r.w, r.h);
addBuffer(r.x, r.y, r.w, r.h);
}
if (SDL_MUSTLOCK(graphics.screen))
if (SDL_MUSTLOCK(screen))
{
SDL_UnlockSurface(graphics.screen);
SDL_UnlockSurface(screen);
}
}

View File

@ -18,13 +18,65 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
extern Graphics graphics;
extern Star star[200];
extern Uint32 red;
extern Uint32 darkRed;
extern Uint32 yellow;
extern Uint32 darkYellow;
extern Uint32 green;
extern Uint32 darkGreen;
extern Uint32 blue;
extern Uint32 darkBlue;
extern Uint32 darkerBlue;
extern Uint32 black;
extern Uint32 white;
extern Uint32 lightGrey;
extern Uint32 darkGrey;
extern SDL_Surface *screen, *background;
extern SDL_Surface *shape[MAX_SHAPES];
extern SDL_Surface *shipShape[MAX_SHIPSHAPES];
extern SDL_Surface *fontShape[MAX_FONTSHAPES];
extern SDL_Surface *shopSurface[MAX_SHOPSHAPES];
extern bRect *bufferHead;
extern bRect *bufferTail;
extern textObject textShape[MAX_TEXTSHAPES];
extern SDL_Surface *messageBox;
extern bool collision(float x0, float y0, int w0, int h0, float x2, float y2, int w1, int h1);
extern bool collision(object *object1, object *object2);
extern bool collision(collectables *object1, object *object2);
extern void initGraphics();
extern SDL_Surface *setTransparent(SDL_Surface *sprite);
extern void addBuffer(int x, int y, int w, int h);
extern void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest);
extern void blit(SDL_Surface *image, int x, int y);
extern void blitText(int i);
extern void flushBuffer();
extern void unBuffer();
extern int drawString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest);
extern int drawString(const char *in, int x, int y, int fontColor, SDL_Surface *dest);
extern int drawString(const char *in, int x, int y, int fontColor);
extern void setColorIndexes();
extern void drawBackGround();
extern void clearScreen(Uint32 color);
extern void updateScreen();
extern void delayFrame();
extern void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
extern void drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col);
extern void drawLine(int x1, int y1, int x2, int y2, int col);
extern void circle(int xc, int yc, int R, SDL_Surface *PIX, int col);
extern void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue);
extern void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue);
extern SDL_Surface *createSurface(int width, int height);
extern SDL_Surface *textSurface(const char *inString, int color);
extern void textSurface(int index, const char *inString, int x, int y, int fontColor);
extern SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue);
extern void createMessageBox(SDL_Surface *face, const char *message, signed char transparent);
extern void freeGraphics();
extern SDL_Surface *loadImage(const char *filename);
extern void doStarfield();
extern int isOnScreen(int x, int y, int w, int h);

View File

@ -57,11 +57,11 @@ be seen by people unless something really stoopid happens!
*/
void showErrorAndExit(int errorId, const char *name)
{
graphics.clearScreen(graphics.black);
clearScreen(black);
if (errorId != 2)
{
graphics.drawString("A file error has occurred", -1, 200, FONT_RED);
drawString("A file error has occurred", -1, 200, FONT_RED);
}
else
{
@ -76,31 +76,31 @@ void showErrorAndExit(int errorId, const char *name)
case 0:
strcpy(string, "");
sprintf(string, "%s was not found in the Starfighter data package", name);
graphics.drawString(string, -1, 250, FONT_WHITE);
graphics.drawString("Please try again. If this error persists, contact Parallel Realities", -1, 275, FONT_WHITE);
graphics.drawString("or reinstall the game", -1, 300, FONT_WHITE);
drawString(string, -1, 250, FONT_WHITE);
drawString("Please try again. If this error persists, contact Parallel Realities", -1, 275, FONT_WHITE);
drawString("or reinstall the game", -1, 300, FONT_WHITE);
break;
case 1:
graphics.drawString("Project: Starfighter encountered an error whilst", -1, 250, FONT_WHITE);
graphics.drawString("attempting to load game data. Please try running", -1, 275, FONT_WHITE);
graphics.drawString("the game again. If the errors persist, reinstall the game", -1, 300, FONT_WHITE);
drawString("Project: Starfighter encountered an error whilst", -1, 250, FONT_WHITE);
drawString("attempting to load game data. Please try running", -1, 275, FONT_WHITE);
drawString("the game again. If the errors persist, reinstall the game", -1, 300, FONT_WHITE);
break;
case 2:
graphics.drawString("Project: Starfighter encountered a critical error", -1, 250, FONT_WHITE);
graphics.drawString("while attempting to perform a required program function.", -1, 275, FONT_WHITE);
graphics.drawString("Please contact Parallel Realities with details", -1, 300, FONT_WHITE);
drawString("Project: Starfighter encountered a critical error", -1, 250, FONT_WHITE);
drawString("while attempting to perform a required program function.", -1, 275, FONT_WHITE);
drawString("Please contact Parallel Realities with details", -1, 300, FONT_WHITE);
break;
}
graphics.drawString("Project: Starfighter will now exit", -1, 450, FONT_WHITE);
graphics.drawString("Press Space to continue", -1, 475, FONT_WHITE);
drawString("Project: Starfighter will now exit", -1, 450, FONT_WHITE);
drawString("Press Space to continue", -1, 475, FONT_WHITE);
engine.keyState[SDLK_SPACE] = 0;
while (!engine.keyState[SDLK_SPACE])
{
getPlayerInput();
graphics.delayFrame();
delayFrame();
}
exit(1);
@ -187,11 +187,11 @@ void initSystem()
SDL_WM_SetIcon(loadImage("gfx/alienDevice.png"), NULL);
if (engine.fullScreen)
graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
else
graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
if (graphics.screen == NULL) {
if (screen == NULL) {
printf("Couldn't set 800x600x16 video mode: %s\n", SDL_GetError());
exit(1);
}
@ -219,9 +219,9 @@ void cleanUp()
{
printf("Cleaning Up...\n");
printf("Freeing Graphics\n");
graphics.freeGraphics();
freeGraphics();
printf("Freeing Background\n");
SDL_FreeSurface(graphics.background);
SDL_FreeSurface(background);
printf("Freeing Sounds\n");
freeSound();
printf("Resetting Lists\n");
@ -229,13 +229,13 @@ void cleanUp()
delete(engine.bulletHead);
delete(engine.explosionHead);
delete(engine.collectableHead);
delete(graphics.bufferHead);
delete(bufferHead);
printf("Freeing Font\n");
for (int i = 0 ; i < MAX_FONTSHAPES ; i++)
{
if (graphics.fontShape[i] != NULL)
SDL_FreeSurface(graphics.fontShape[i]);
if (fontShape[i] != NULL)
SDL_FreeSurface(fontShape[i]);
}
printf("Removing Mod\n");

View File

@ -29,7 +29,7 @@ static void doCursor()
limitInt(&engine.cursor_x, 10, 790);
limitInt(&engine.cursor_y, 10, 590);
graphics.blit(graphics.shape[0], engine.cursor_x, engine.cursor_y);
blit(shape[0], engine.cursor_x, engine.cursor_y);
}
/*
@ -43,7 +43,7 @@ static void setStatusLines()
sprintf(string, "System : %s", systemNames[currentGame.system]);
graphics.textSurface(0, string, 0, 0, FONT_WHITE);
textSurface(0, string, 0, 0, FONT_WHITE);
signed char total = 0;
signed char completed = 0;
@ -66,101 +66,101 @@ static void setStatusLines()
}
for (int i = 0 ; i < 30 ; i++)
graphics.textSurface(i, "", 0, 0, FONT_WHITE);
textSurface(i, "", 0, 0, FONT_WHITE);
sprintf(string, "Missions Completed : %d/%d", completed, total);
graphics.textSurface(1, string, 0, 0, FONT_WHITE);
textSurface(1, string, 0, 0, FONT_WHITE);
sprintf(string, "Shots Fired : %d", currentGame.shots);
graphics.textSurface(2, string, 0, 0, FONT_WHITE);
textSurface(2, string, 0, 0, FONT_WHITE);
sprintf(string, "Hits Scored : %d", currentGame.hits);
graphics.textSurface(3, string, 0, 0, FONT_WHITE);
textSurface(3, string, 0, 0, FONT_WHITE);
sprintf(string, "Accuracy : %d%%", currentGame.accuracy);
graphics.textSurface(4, string, 0, 0, FONT_WHITE);
textSurface(4, string, 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed by Others : %d", currentGame.totalOtherKills);
graphics.textSurface(5, string, 0, 0, FONT_WHITE);
textSurface(5, string, 0, 0, FONT_WHITE);
sprintf(string, "Total Cash Earned : %d", currentGame.cashEarned);
graphics.textSurface(6, string, 0, 0, FONT_WHITE);
textSurface(6, string, 0, 0, FONT_WHITE);
graphics.textSurface(7, "*** Chris ***", 0, 0, FONT_WHITE);
textSurface(7, "*** Chris ***", 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed : %d", currentGame.totalKills);
graphics.textSurface(8, string, 0, 0, FONT_WHITE);
textSurface(8, string, 0, 0, FONT_WHITE);
sprintf(string, "Shield Restores Picked Up : %d", currentGame.shieldPickups);
graphics.textSurface(9, string, 0, 0, FONT_WHITE);
textSurface(9, string, 0, 0, FONT_WHITE);
sprintf(string, "Plasma Cells Picked Up : %d", currentGame.cellPickups);
graphics.textSurface(10, string, 0, 0, FONT_WHITE);
textSurface(10, string, 0, 0, FONT_WHITE);
sprintf(string, "Rockets Picked Up : %d", currentGame.rocketPickups);
graphics.textSurface(11, string, 0, 0, FONT_WHITE);
textSurface(11, string, 0, 0, FONT_WHITE);
sprintf(string, "Powerups Picked Up : %d", currentGame.rocketPickups);
graphics.textSurface(12, string, 0, 0, FONT_WHITE);
textSurface(12, string, 0, 0, FONT_WHITE);
sprintf(string, "Mines Destroyed : %d", currentGame.minesKilled);
graphics.textSurface(13, string, 0, 0, FONT_WHITE);
textSurface(13, string, 0, 0, FONT_WHITE);
sprintf(string, "Slaves Rescued : %d", currentGame.slavesRescued);
graphics.textSurface(14, string, 0, 0, FONT_WHITE);
textSurface(14, string, 0, 0, FONT_WHITE);
sprintf(string, "Cargo Picked Up : %d", currentGame.cargoPickups);
graphics.textSurface(15, string, 0, 0, FONT_WHITE);
textSurface(15, string, 0, 0, FONT_WHITE);
if (currentGame.hasWingMate1)
{
graphics.textSurface(16, "*** Phoebe ***", 0, 0, FONT_WHITE);
textSurface(16, "*** Phoebe ***", 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed : %d", currentGame.wingMate1Kills);
graphics.textSurface(17, string, 0, 0, FONT_WHITE);
textSurface(17, string, 0, 0, FONT_WHITE);
sprintf(string, "Ejections : %d", currentGame.wingMate1Ejects);
graphics.textSurface(18, string, 0, 0, FONT_WHITE);
textSurface(18, string, 0, 0, FONT_WHITE);
}
if (currentGame.hasWingMate2)
{
graphics.textSurface(19, "*** Ursula ***", 0, 0, FONT_WHITE);
textSurface(19, "*** Ursula ***", 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed : %d", currentGame.wingMate2Kills);
graphics.textSurface(20, string, 0, 0, FONT_WHITE);
textSurface(20, string, 0, 0, FONT_WHITE);
sprintf(string, "Ejections : %d", currentGame.wingMate2Ejects);
graphics.textSurface(21, string, 0, 0, FONT_WHITE);
textSurface(21, string, 0, 0, FONT_WHITE);
}
signed char percentage = 0;
if ((currentGame.secondaryMissions > 0) && (currentGame.secondaryMissionsCompleted > 0))
percentage = (currentGame.secondaryMissionsCompleted / currentGame.secondaryMissions) * 100;
sprintf(string, "Seconday Missions Completed : %d / %d (%d%%)", currentGame.secondaryMissionsCompleted, currentGame.secondaryMissions, percentage);
graphics.textSurface(24, string, 0, 0, FONT_WHITE);
textSurface(24, string, 0, 0, FONT_WHITE);
int timeTaken = currentGame.timeTaken;
snprintf(string, sizeof string, "Total Time : %2d:%02d:%02d", timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60);
graphics.textSurface(26, string, -1, 0, FONT_WHITE);
graphics.textSurface(27, "Current Status", -1, 0, FONT_WHITE);
textSurface(26, string, -1, 0, FONT_WHITE);
textSurface(27, "Current Status", -1, 0, FONT_WHITE);
graphics.textShape[0].y = 400;
graphics.textShape[0].x = 150;
textShape[0].y = 400;
textShape[0].x = 150;
for (int i = 1 ; i < 25 ; i++)
{
graphics.textShape[i].y = graphics.textShape[i - 1].y + 20;
textShape[i].y = textShape[i - 1].y + 20;
if ((i == 7) || (i == 16) || (i == 19))
graphics.textShape[i].y += 25;
textShape[i].y += 25;
graphics.textShape[i].x = 150;
textShape[i].x = 150;
}
graphics.textShape[26].y = 404;
graphics.textShape[27].y = 83;
textShape[26].y = 404;
textShape[27].y = 83;
}
/*
@ -208,7 +208,7 @@ static void setSystemPlanets()
systemPlanet[i].y = distance;
strcpy(systemPlanet[i].name, name);
systemPlanet[i].image = graphics.shape[image];
systemPlanet[i].image = shape[image];
}
int messageMission;
@ -247,14 +247,14 @@ static bool showSystem(float x, float y)
bool rtn = false;
// Blit the sun
graphics.blit(graphics.shape[30], 370, 220);
blit(shape[30], 370, 220);
for (int i = 50 ; i < 300 ; i+= planetSpace)
{
x *= 0.75;
y *= 0.75;
graphics.circle(400, 250, i, graphics.screen, graphics.darkGrey);
circle(400, 250, i, screen, darkGrey);
r.x = int(400 + (sinf(x) * i));
r.y = int(250 + (cosf(y) * i));
@ -263,11 +263,11 @@ static bool showSystem(float x, float y)
r.x -= (systemPlanet[planet].image->w / 2);
r.y -= (systemPlanet[planet].image->h / 2);
graphics.blit(systemPlanet[planet].image, r.x, r.y);
blit(systemPlanet[planet].image, r.x, r.y);
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, r.x, r.y, systemPlanet[planet].image->w, systemPlanet[planet].image->h))
{
graphics.drawString(systemPlanet[planet].name, -1, 545, FONT_WHITE);
drawString(systemPlanet[planet].name, -1, 545, FONT_WHITE);
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
{
if (currentGame.system == 0)
@ -305,90 +305,90 @@ list is reset and the information lines begin again from the bottom
*/
static void showStatus(SDL_Surface *infoSurface)
{
graphics.blit(infoSurface, 100, 80);
blit(infoSurface, 100, 80);
for (int i = 0 ; i < 22 ; i++)
{
graphics.textShape[i].y -= 0.25;
if ((graphics.textShape[i].y > 80) && (graphics.textShape[i].y < 400))
graphics.blitText(i);
textShape[i].y -= 0.25;
if ((textShape[i].y > 80) && (textShape[i].y < 400))
blitText(i);
}
if (graphics.textShape[21].y < 65)
if (textShape[21].y < 65)
{
graphics.textShape[0].y = 400;
textShape[0].y = 400;
for (int i = 1 ; i < 25 ; i++)
{
graphics.textShape[i].y = graphics.textShape[i - 1].y + 20;
textShape[i].y = textShape[i - 1].y + 20;
if ((i == 7) || (i == 16) || (i == 19))
graphics.textShape[i].y += 25;
textShape[i].y += 25;
}
}
graphics.blevelRect(100, 80, 600, 20, 0x00, 0x00, 0x99);
blevelRect(100, 80, 600, 20, 0x00, 0x00, 0x99);
graphics.blevelRect(100, 400, 600, 20, 0x00, 0x00, 0x99);
blevelRect(100, 400, 600, 20, 0x00, 0x00, 0x99);
graphics.blitText(26);
graphics.blitText(27);
blitText(26);
blitText(27);
}
static void createOptions(SDL_Surface *optionsSurface)
{
SDL_FillRect(optionsSurface, NULL, graphics.black);
SDL_FillRect(optionsSurface, NULL, black);
graphics.blevelRect(optionsSurface, 0, 0, optionsSurface->w - 2, optionsSurface->h - 2, 0x00, 0x00, 0x44);
blevelRect(optionsSurface, 0, 0, optionsSurface->w - 2, optionsSurface->h - 2, 0x00, 0x00, 0x44);
graphics.drawString("++ OPTIONS ++", 105, 8, FONT_WHITE, optionsSurface);
drawString("++ OPTIONS ++", 105, 8, FONT_WHITE, optionsSurface);
graphics.blevelRect(optionsSurface, 190, 45, 50, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 250, 45, 50, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 20, 45, 150, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 190, 45, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 45, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 45, 150, 22, 0x00, 0x00, 0x00);
if (engine.useSound)
graphics.blevelRect(optionsSurface, 190, 45, 50, 22, 0xff, 0x00, 0x00);
blevelRect(optionsSurface, 190, 45, 50, 22, 0xff, 0x00, 0x00);
else
graphics.blevelRect(optionsSurface, 250, 45, 50, 22, 0xff, 0x00, 0x00);
graphics.drawString("ON", 207, 50, FONT_WHITE, optionsSurface);
graphics.drawString("OFF", 263, 50, FONT_WHITE, optionsSurface);
graphics.drawString("SOUND", 30, 50, FONT_WHITE, optionsSurface);
blevelRect(optionsSurface, 250, 45, 50, 22, 0xff, 0x00, 0x00);
drawString("ON", 207, 50, FONT_WHITE, optionsSurface);
drawString("OFF", 263, 50, FONT_WHITE, optionsSurface);
drawString("SOUND", 30, 50, FONT_WHITE, optionsSurface);
graphics.blevelRect(optionsSurface, 190, 95, 50, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 250, 95, 50, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 20, 95, 150, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 190, 95, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 95, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 95, 150, 22, 0x00, 0x00, 0x00);
if (engine.useMusic)
graphics.blevelRect(optionsSurface, 190, 95, 50, 22, 0xff, 0x00, 0x00);
blevelRect(optionsSurface, 190, 95, 50, 22, 0xff, 0x00, 0x00);
else
graphics.blevelRect(optionsSurface, 250, 95, 50, 22, 0xff, 0x00, 0x00);
graphics.drawString("ON", 207, 100, FONT_WHITE, optionsSurface);
graphics.drawString("OFF", 263, 100, FONT_WHITE, optionsSurface);
graphics.drawString("MUSIC", 30, 100, FONT_WHITE, optionsSurface);
blevelRect(optionsSurface, 250, 95, 50, 22, 0xff, 0x00, 0x00);
drawString("ON", 207, 100, FONT_WHITE, optionsSurface);
drawString("OFF", 263, 100, FONT_WHITE, optionsSurface);
drawString("MUSIC", 30, 100, FONT_WHITE, optionsSurface);
graphics.blevelRect(optionsSurface, 190, 145, 50, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 250, 145, 50, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 20, 145, 150, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 190, 145, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 145, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 145, 150, 22, 0x00, 0x00, 0x00);
if (engine.fullScreen)
graphics.blevelRect(optionsSurface, 190, 145, 50, 22, 0xff, 0x00, 0x00);
blevelRect(optionsSurface, 190, 145, 50, 22, 0xff, 0x00, 0x00);
else
graphics.blevelRect(optionsSurface, 250, 145, 50, 22, 0xff, 0x00, 0x00);
graphics.drawString("ON", 207, 150, FONT_WHITE, optionsSurface);
graphics.drawString("OFF", 263, 150, FONT_WHITE, optionsSurface);
graphics.drawString("FULLSCREEN", 30, 150, FONT_WHITE, optionsSurface);
blevelRect(optionsSurface, 250, 145, 50, 22, 0xff, 0x00, 0x00);
drawString("ON", 207, 150, FONT_WHITE, optionsSurface);
drawString("OFF", 263, 150, FONT_WHITE, optionsSurface);
drawString("FULLSCREEN", 30, 150, FONT_WHITE, optionsSurface);
graphics.blevelRect(optionsSurface, 20, 195, 150, 22, 0x00, 0x00, 0x00);
graphics.blevelRect(optionsSurface, 190, 195, 110, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 195, 150, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 190, 195, 110, 22, 0x00, 0x00, 0x00);
if (currentGame.autoSaveSlot == -1)
{
graphics.drawString("NONE", 225, 200, FONT_WHITE, optionsSurface);
drawString("NONE", 225, 200, FONT_WHITE, optionsSurface);
}
else
{
char string[] = "Slot %d";
sprintf(string, "Slot %d", currentGame.autoSaveSlot + 1);
graphics.blevelRect(optionsSurface, 190, 195, 110, 22, 0xff, 0x00, 0x00);
graphics.drawString(string, 225, 200, FONT_WHITE, optionsSurface);
blevelRect(optionsSurface, 190, 195, 110, 22, 0xff, 0x00, 0x00);
drawString(string, 225, 200, FONT_WHITE, optionsSurface);
}
graphics.drawString("AUTOSAVE SLOT", 30, 200, FONT_WHITE, optionsSurface);
drawString("AUTOSAVE SLOT", 30, 200, FONT_WHITE, optionsSurface);
}
static void showOptions(SDL_Surface *optionsSurface)
@ -426,10 +426,10 @@ static void showOptions(SDL_Surface *optionsSurface)
if (!engine.fullScreen)
{
#if LINUX
SDL_WM_ToggleFullScreen(graphics.screen);
SDL_WM_ToggleFullScreen(screen);
#else
graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
graphics.drawBackground();
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
drawBackground();
flushBuffer();
#endif
engine.fullScreen = true;
@ -441,10 +441,10 @@ static void showOptions(SDL_Surface *optionsSurface)
if (engine.fullScreen)
{
#if LINUX
SDL_WM_ToggleFullScreen(graphics.screen);
SDL_WM_ToggleFullScreen(screen);
#else
graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
graphics.drawBackground();
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
drawBackground();
flushBuffer();
#endif
engine.fullScreen = false;
@ -469,7 +469,7 @@ functions when the player has selected an icon.
*/
int galaxyMap()
{
graphics.freeGraphics();
freeGraphics();
checkForBossMission(); // double check just to make sure!
@ -477,9 +477,9 @@ int galaxyMap()
// do not perform certain keyboard actions
engine.gameSection = SECTION_INTERMISSION;
graphics.clearScreen(graphics.black);
graphics.updateScreen();
graphics.clearScreen(graphics.black);
clearScreen(black);
updateScreen();
clearScreen(black);
initSaveSlots();
@ -490,33 +490,33 @@ int galaxyMap()
char string[25];
engine.cursor_x = engine.cursor_y = 500;
graphics.shape[0] = loadImage("gfx/cursor.bmp");
shape[0] = loadImage("gfx/cursor.bmp");
// Icons 1 - 29
for (int i = 0 ; i < 26 ; i++)
{
sprintf(string, "gfx/icon%d.bmp", (i + 1));
graphics.shape[i + 1] = loadImage(string);
shape[i + 1] = loadImage(string);
}
graphics.shape[27] = loadImage("gfx/buyIcon.bmp");
graphics.shape[28] = loadImage("gfx/sellIcon.bmp");
graphics.shape[29] = loadImage("gfx/firefly1.png");
shape[27] = loadImage("gfx/buyIcon.bmp");
shape[28] = loadImage("gfx/sellIcon.bmp");
shape[29] = loadImage("gfx/firefly1.png");
// Planets 30 - 39
graphics.shape[30] = loadImage("gfx/planet_sun.gif");
graphics.shape[31] = loadImage("gfx/planet_green.gif");
graphics.shape[32] = loadImage("gfx/planet_blue.gif");
graphics.shape[33] = loadImage("gfx/planet_red.gif");
graphics.shape[34] = loadImage("gfx/planet_orange.gif");
shape[30] = loadImage("gfx/planet_sun.gif");
shape[31] = loadImage("gfx/planet_green.gif");
shape[32] = loadImage("gfx/planet_blue.gif");
shape[33] = loadImage("gfx/planet_red.gif");
shape[34] = loadImage("gfx/planet_orange.gif");
// Faces (as defines)
graphics.shape[FACE_CHRIS] = loadImage("gfx/face_chris.png");
graphics.shape[FACE_SID] = loadImage("gfx/face_sid.png");
graphics.shape[FACE_KRASS] = loadImage("gfx/face_krass.png");
graphics.shape[FACE_PHOEBE] = loadImage("gfx/face_phoebe.png");
graphics.shape[FACE_URSULA] = loadImage("gfx/face_ursula.png");
graphics.shape[FACE_KLINE] = loadImage("gfx/face_kline.png");
shape[FACE_CHRIS] = loadImage("gfx/face_chris.png");
shape[FACE_SID] = loadImage("gfx/face_sid.png");
shape[FACE_KRASS] = loadImage("gfx/face_krass.png");
shape[FACE_PHOEBE] = loadImage("gfx/face_phoebe.png");
shape[FACE_URSULA] = loadImage("gfx/face_ursula.png");
shape[FACE_KLINE] = loadImage("gfx/face_kline.png");
engine.done = 0;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0;
@ -531,10 +531,10 @@ int galaxyMap()
initShop();
setSystemPlanets();
SDL_Surface *statsSurface = graphics.alphaRect(600, 330, 0x00, 0x00, 0x99);
SDL_Surface *savesSurface = graphics.createSurface(350, 300);
SDL_Surface *optionsSurface = graphics.createSurface(320, 240);
SDL_Surface *commsSurface = graphics.createSurface(450, 400);
SDL_Surface *statsSurface = alphaRect(600, 330, 0x00, 0x00, 0x99);
SDL_Surface *savesSurface = createSurface(350, 300);
SDL_Surface *optionsSurface = createSurface(320, 240);
SDL_Surface *commsSurface = createSurface(450, 400);
createSavesSurface(savesSurface, -1);
createOptions(optionsSurface);
@ -561,29 +561,29 @@ int galaxyMap()
textObject iconInfo[12];
iconInfo[0].image = graphics.textSurface("Start Next Mission", FONT_WHITE);
iconInfo[1].image = graphics.textSurface("View System Map", FONT_WHITE);
iconInfo[2].image = graphics.textSurface("Current Status", FONT_WHITE);
iconInfo[3].image = graphics.textSurface("Save Game", FONT_WHITE);
iconInfo[4].image = graphics.textSurface("Upgrade FIREFLY", FONT_WHITE);
iconInfo[5].image = graphics.textSurface("Comms", FONT_WHITE);
iconInfo[6].image = graphics.textSurface("Options", FONT_WHITE);
iconInfo[7].image = graphics.textSurface("Exit to Title Screen", FONT_WHITE);
iconInfo[0].image = textSurface("Start Next Mission", FONT_WHITE);
iconInfo[1].image = textSurface("View System Map", FONT_WHITE);
iconInfo[2].image = textSurface("Current Status", FONT_WHITE);
iconInfo[3].image = textSurface("Save Game", FONT_WHITE);
iconInfo[4].image = textSurface("Upgrade FIREFLY", FONT_WHITE);
iconInfo[5].image = textSurface("Comms", FONT_WHITE);
iconInfo[6].image = textSurface("Options", FONT_WHITE);
iconInfo[7].image = textSurface("Exit to Title Screen", FONT_WHITE);
sprintf(string, "System : %s", systemNames[currentGame.system]);
iconInfo[8].image = graphics.textSurface(string, FONT_WHITE);
iconInfo[8].image = textSurface(string, FONT_WHITE);
sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name);
iconInfo[9].image = graphics.textSurface(string, FONT_WHITE);
iconInfo[9].image = textSurface(string, FONT_WHITE);
strcpy(string, "Destination: None");
if (currentGame.destinationPlanet > -1)
sprintf(string, "Destination: %s", systemPlanet[currentGame.destinationPlanet].name);
iconInfo[10].image = graphics.textSurface(string, FONT_WHITE);
iconInfo[10].image = textSurface(string, FONT_WHITE);
for (int i = 0 ; i < 9 ; i++)
iconInfo[i].x = (800 - iconInfo[i].image->w) / 2;
iconInfo[11].image = graphics.textSurface("Go to Destination Planet", FONT_WHITE);
iconInfo[11].image = textSurface("Go to Destination Planet", FONT_WHITE);
bool redrawBackGround = true;
@ -600,16 +600,16 @@ int galaxyMap()
while (!engine.done)
{
graphics.updateScreen();
updateScreen();
if (redrawBackGround)
{
graphics.drawBackGround();
drawBackGround();
redrawBackGround = false;
}
else
{
graphics.unBuffer();
unBuffer();
}
doStarfield();
@ -621,7 +621,7 @@ int galaxyMap()
for (int i = 40 ; i < 800 ; i+= 40)
{
r.x = i;
SDL_FillRect(graphics.screen, &r, graphics.darkerBlue);
SDL_FillRect(screen, &r, darkerBlue);
}
r.x = 0;
@ -631,7 +631,7 @@ int galaxyMap()
for (int i = 40 ; i < 600 ; i+= 40)
{
r.y = i;
SDL_FillRect(graphics.screen, &r, graphics.darkerBlue);
SDL_FillRect(screen, &r, darkerBlue);
}
@ -643,7 +643,7 @@ int galaxyMap()
engine.ssy /= 100;
}
graphics.blit(iconInfo[8].image, (int)iconInfo[8].x, 15);
blit(iconInfo[8].image, (int)iconInfo[8].x, 15);
switch(section)
{
@ -662,10 +662,10 @@ int galaxyMap()
distance = 1;
SDL_FreeSurface(iconInfo[9].image);
iconInfo[9].image = graphics.textSurface(systemPlanet[currentGame.stationedPlanet].name, FONT_WHITE);
iconInfo[9].image = textSurface(systemPlanet[currentGame.stationedPlanet].name, FONT_WHITE);
SDL_FreeSurface(iconInfo[10].image);
iconInfo[10].image = graphics.textSurface(systemPlanet[currentGame.destinationPlanet].name, FONT_WHITE);
iconInfo[10].image = textSurface(systemPlanet[currentGame.destinationPlanet].name, FONT_WHITE);
section = 8;
@ -697,20 +697,20 @@ int galaxyMap()
{
sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name);
SDL_FreeSurface(iconInfo[9].image);
iconInfo[9].image = graphics.textSurface(string, FONT_WHITE);
iconInfo[9].image = textSurface(string, FONT_WHITE);
updateCommsSurface(commsSurface);
}
else
{
sprintf(string, "Destination: %s", systemPlanet[currentGame.destinationPlanet].name);
SDL_FreeSurface(iconInfo[10].image);
iconInfo[10].image = graphics.textSurface(string, FONT_WHITE);
iconInfo[10].image = textSurface(string, FONT_WHITE);
}
}
graphics.blit(iconInfo[9].image, 90, 450);
blit(iconInfo[9].image, 90, 450);
if ((currentGame.system > 0) && (currentGame.stationedPlanet != currentGame.destinationPlanet))
graphics.blit(iconInfo[10].image, 550, 450);
blit(iconInfo[10].image, 550, 450);
break;
case 2:
@ -718,7 +718,7 @@ int galaxyMap()
break;
case 3:
graphics.blit(savesSurface, 200, 100);
blit(savesSurface, 200, 100);
saveSlot = showSaveSlots(savesSurface, saveSlot);
break;
@ -727,12 +727,12 @@ int galaxyMap()
break;
case 5:
graphics.blit(commsSurface, 170, 70);
blit(commsSurface, 170, 70);
doComms(commsSurface);
break;
case 6:
graphics.blit(optionsSurface, 230, 130);
blit(optionsSurface, 230, 130);
showOptions(optionsSurface);
break;
@ -744,13 +744,13 @@ int galaxyMap()
case 8:
showSystem(sinX, cosY);
graphics.blit(systemPlanet[currentGame.stationedPlanet].image, 150, 450);
graphics.blit(iconInfo[9].image, 135, 480);
graphics.blit(systemPlanet[currentGame.destinationPlanet].image, 650, 450);
graphics.blit(iconInfo[10].image, 635, 480);
blit(systemPlanet[currentGame.stationedPlanet].image, 150, 450);
blit(iconInfo[9].image, 135, 480);
blit(systemPlanet[currentGame.destinationPlanet].image, 650, 450);
blit(iconInfo[10].image, 635, 480);
destRect.w += distance;
SDL_FillRect(graphics.screen, &destRect, graphics.red);
SDL_FillRect(screen, &destRect, red);
if (destRect.w >= 450)
{
@ -760,7 +760,7 @@ int galaxyMap()
sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name);
strcpy(currentGame.stationedName, systemPlanet[currentGame.stationedPlanet].name);
SDL_FreeSurface(iconInfo[9].image);
iconInfo[9].image = graphics.textSurface(string, FONT_WHITE);
iconInfo[9].image = textSurface(string, FONT_WHITE);
updateCommsSurface(commsSurface);
section = 1;
redrawBackGround = true;
@ -780,7 +780,7 @@ int galaxyMap()
break;
}
graphics.addBuffer(300, 545, 200, 15);
addBuffer(300, 545, 200, 15);
if (section != 8)
{
@ -792,27 +792,27 @@ int galaxyMap()
if ((currentGame.stationedPlanet == currentGame.destinationPlanet) && (systemPlanet[currentGame.stationedPlanet].missionCompleted != 0))
continue;
else if (currentGame.stationedPlanet == currentGame.destinationPlanet)
graphics.blit(graphics.shape[1], 80 + (i * 90), 500);
blit(shape[1], 80 + (i * 90), 500);
else if (currentGame.stationedPlanet != currentGame.destinationPlanet)
graphics.blit(graphics.shape[26], 80 + (i * 90), 500);
blit(shape[26], 80 + (i * 90), 500);
}
else
{
graphics.blit(graphics.shape[i + 1], 80 + (i * 90), 500);
blit(shape[i + 1], 80 + (i * 90), 500);
}
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 80 + (i * 90), 500, 32, 32))
{
if (i != 0)
{
graphics.blit(iconInfo[i].image, (int)iconInfo[i].x, 545);
blit(iconInfo[i].image, (int)iconInfo[i].x, 545);
}
else
{
if (currentGame.stationedPlanet == currentGame.destinationPlanet)
graphics.blit(iconInfo[0].image, (int)iconInfo[i].x, 545);
blit(iconInfo[0].image, (int)iconInfo[i].x, 545);
else
graphics.blit(iconInfo[11].image, (int)iconInfo[i].x, 545);
blit(iconInfo[11].image, (int)iconInfo[i].x, 545);
}
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
@ -828,7 +828,7 @@ int galaxyMap()
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
doCursor();
graphics.delayFrame();
delayFrame();
}
Mix_HaltMusic();

View File

@ -49,7 +49,7 @@ int initSaveSlots()
{
sprintf(saveSlot[i], "%.2d - Empty", (i + 1));
if (engine.gameSection == SECTION_TITLE)
graphics.textSurface(13 + i, saveSlot[i], -1, imagePos, FONT_WHITE);
textSurface(13 + i, saveSlot[i], -1, imagePos, FONT_WHITE);
}
else
{
@ -61,7 +61,7 @@ int initSaveSlots()
{
sprintf(saveSlot[i], "%.2d - %s, %s", (i + 1), systemNames[tempGame.system], tempGame.stationedName);
if (engine.gameSection == SECTION_TITLE)
graphics.textSurface(13 + i, saveSlot[i], -1, imagePos, FONT_WHITE);
textSurface(13 + i, saveSlot[i], -1, imagePos, FONT_WHITE);
}
if (stat(fileName, &fileInfo) != -1)
@ -154,21 +154,21 @@ void saveGame(int slot)
void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
{
graphics.blevelRect(savesSurface, 0, 0, 348, 298, 0x00, 0x00, 0x00);
blevelRect(savesSurface, 0, 0, 348, 298, 0x00, 0x00, 0x00);
int y = 10;
for (int i = 0 ; i < 5 ; i++)
{
if (clickedSlot == i)
graphics.blevelRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00);
blevelRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00);
else
graphics.blevelRect(savesSurface, 5, y, 338, 25, 0x00, 0x00, 0x99);
graphics.drawString(saveSlot[i], 70, y + 5, FONT_WHITE, savesSurface);
blevelRect(savesSurface, 5, y, 338, 25, 0x00, 0x00, 0x99);
drawString(saveSlot[i], 70, y + 5, FONT_WHITE, savesSurface);
y += 30;
}
graphics.drawString("*** HELP ***", 120, 170, FONT_WHITE, savesSurface);
drawString("*** HELP ***", 120, 170, FONT_WHITE, savesSurface);
switch(clickedSlot)
{
@ -177,25 +177,25 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
case 2:
case 3:
case 4:
graphics.blevelRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00);
graphics.blevelRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00);
graphics.blevelRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00);
graphics.drawString("SAVE", 40, 270, FONT_WHITE, savesSurface);
graphics.drawString("CANCEL", 150, 270, FONT_WHITE, savesSurface);
graphics.drawString("DELETE", 270, 270, FONT_WHITE, savesSurface);
blevelRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00);
blevelRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00);
blevelRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00);
drawString("SAVE", 40, 270, FONT_WHITE, savesSurface);
drawString("CANCEL", 150, 270, FONT_WHITE, savesSurface);
drawString("DELETE", 270, 270, FONT_WHITE, savesSurface);
graphics.drawString("SAVE will save the game", 17, 200, FONT_WHITE, savesSurface);
graphics.drawString("CANCEL will unselect that slot", 17, 220, FONT_WHITE, savesSurface);
graphics.drawString("DELETE will remove the save", 17, 240, FONT_WHITE, savesSurface);
drawString("SAVE will save the game", 17, 200, FONT_WHITE, savesSurface);
drawString("CANCEL will unselect that slot", 17, 220, FONT_WHITE, savesSurface);
drawString("DELETE will remove the save", 17, 240, FONT_WHITE, savesSurface);
break;
case -1:
graphics.drawString("First click a Save game slot to use", 17, 200, FONT_WHITE, savesSurface);
drawString("First click a Save game slot to use", 17, 200, FONT_WHITE, savesSurface);
break;
case -10:
graphics.drawString("Game Saved", 130, 200, FONT_WHITE, savesSurface);
drawString("Game Saved", 130, 200, FONT_WHITE, savesSurface);
break;
case -11:
graphics.drawString("Save Deleted", 130, 200, FONT_WHITE, savesSurface);
drawString("Save Deleted", 130, 200, FONT_WHITE, savesSurface);
break;
}

View File

@ -24,15 +24,15 @@ void clearInfoLines()
{
for (int i = 0 ; i < 4 ; i++)
{
graphics.textShape[i].life = 0;
textShape[i].life = 0;
}
}
// from a to b
static void copyInfoLine(int a, int b)
{
graphics.textSurface(b, graphics.textShape[a].text, -1, 0, graphics.textShape[a].fontColor);
graphics.textShape[b].life = graphics.textShape[a].life;
textSurface(b, textShape[a].text, -1, 0, textShape[a].fontColor);
textShape[b].life = textShape[a].life;
}
/*
@ -47,7 +47,7 @@ void setInfoLine(const char *in, int color)
for (int i = 0 ; i < 3 ; i++)
{
if ((graphics.textShape[i].life == 0) && (index == -1))
if ((textShape[i].life == 0) && (index == -1))
{
index = i;
}
@ -61,8 +61,8 @@ void setInfoLine(const char *in, int color)
copyInfoLine(2, 1);
}
graphics.textSurface(index, in, -1, 0, color);
graphics.textShape[index].life = 240;
textSurface(index, in, -1, 0, color);
textShape[index].life = 240;
}
/*
@ -72,17 +72,17 @@ Phoebe or Ursula's banter to interrupt an important message
*/
void setRadioMessage(signed char face, const char *in, int priority)
{
if ((graphics.textShape[3].life > 0) && (priority == 0))
if ((textShape[3].life > 0) && (priority == 0))
return;
graphics.textSurface(3, in, -1, 50, FONT_WHITE);
graphics.textShape[3].life = 240;
textSurface(3, in, -1, 50, FONT_WHITE);
textShape[3].life = 240;
SDL_Surface *faceShape = NULL;
if (face > -1)
faceShape = graphics.shape[face];
faceShape = shape[face];
graphics.createMessageBox(faceShape, in, 1);
createMessageBox(faceShape, in, 1);
}
static void doTargetArrow()
@ -93,7 +93,7 @@ static void doTargetArrow()
if (enemy[engine.targetIndex].flags & FL_ISCLOAKED)
return;
if (graphics.textShape[3].life > 0)
if (textShape[3].life > 0)
return;
engine.targetArrow = -1;
@ -130,8 +130,8 @@ static void doTargetArrow()
if (engine.targetArrow != -1)
{
graphics.blit(graphics.shape[engine.targetArrow], 380, 50);
graphics.blit(graphics.shape[44], 365, 70);
blit(shape[engine.targetArrow], 380, 50);
blit(shape[44], 365, 70);
}
}
@ -145,8 +145,8 @@ void doInfo()
signed char fontColor;
char text[25];
graphics.addBuffer(0, 20, 800, 25);
graphics.addBuffer(0, 545, 800, 25);
addBuffer(0, 20, 800, 25);
addBuffer(0, 545, 800, 25);
if (engine.minutes > -1)
{
@ -156,24 +156,24 @@ void doInfo()
fontColor = FONT_YELLOW;
else
fontColor = FONT_WHITE;
graphics.blitText(10); // time remaining
blitText(10); // time remaining
sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds);
graphics.textSurface(30, text, 410, 21, fontColor);
graphics.blitText(30);
textSurface(30, text, 410, 21, fontColor);
blitText(30);
}
if (currentGame.area != MAX_MISSIONS - 1)
{
graphics.blitText(9); // mission objectives
blitText(9); // mission objectives
sprintf(text, "%d", (currentMission.remainingObjectives1 + currentMission.remainingObjectives2));
graphics.textSurface(39, text, 745, 21, FONT_WHITE);
graphics.blitText(39);
textSurface(39, text, 745, 21, FONT_WHITE);
blitText(39);
}
graphics.blitText(8); // cash
blitText(8); // cash
sprintf(text, "%.6d", currentGame.cash);
graphics.textSurface(38, text, 90, 21, FONT_WHITE);
graphics.blitText(38);
textSurface(38, text, 90, 21, FONT_WHITE);
blitText(38);
doTargetArrow();
@ -183,12 +183,12 @@ void doInfo()
if (player.ammo[0] <= 25) fontColor = FONT_YELLOW;
if (player.ammo[0] <= 10) fontColor = FONT_RED;
}
graphics.blitText(5); // plasma ammo
blitText(5); // plasma ammo
sprintf(text, "%.3d", player.ammo[0]);
graphics.textSurface(35, text, 320, 551, fontColor);
graphics.blitText(35);
textSurface(35, text, 320, 551, fontColor);
blitText(35);
graphics.blitText(6);
blitText(6);
if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER))
{
@ -197,15 +197,15 @@ void doInfo()
else
fontColor = FONT_WHITE;
sprintf(text, "%.3d", player.ammo[1]); // rocket ammo
graphics.textSurface(36, text, 465, 551, fontColor);
graphics.blitText(36);
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 = graphics.white;
int c = white;
if (player.ammo[1] > 100)
c = graphics.red;
c = red;
bar.x = 450;
bar.y = 550;
@ -214,7 +214,7 @@ void doInfo()
for (int i = 0 ; i < (player.ammo[1] / 5) ; i++)
{
bar.w = 1;
SDL_FillRect(graphics.screen, &bar, c);
SDL_FillRect(screen, &bar, c);
bar.x += 2;
}
}
@ -276,26 +276,26 @@ void doInfo()
for (int i = 0 ; i < 3 ; i++)
{
if (graphics.textShape[i].life > 0)
if (textShape[i].life > 0)
{
graphics.textShape[i].y = (525 - (i * 20));
graphics.blitText(i);
graphics.textShape[i].life--;
textShape[i].y = (525 - (i * 20));
blitText(i);
textShape[i].life--;
if (graphics.textShape[i].life == 0)
if (textShape[i].life == 0)
{
copyInfoLine(i + 1, i);
copyInfoLine(i + 2, i + 1);
graphics.textShape[2].life = 0;
textShape[2].life = 0;
}
}
}
// Show the radio message if there is one
if (graphics.textShape[3].life > 0)
if (textShape[3].life > 0)
{
graphics.blit(graphics.messageBox, (800 - graphics.messageBox->w) / 2, 50);
graphics.textShape[3].life--;
blit(messageBox, (800 - messageBox->w) / 2, 50);
textShape[3].life--;
}
// Do the target's remaining shield (if required)
@ -303,7 +303,7 @@ void doInfo()
{
if ((engine.targetIndex > -1) && (enemy[engine.targetIndex].shield > 0) && (engine.targetIndex > 9))
{
graphics.blitText(7);
blitText(7);
bar.w = 1;
bar.h = 12;
bar.x = 620;
@ -312,52 +312,52 @@ void doInfo()
for (float i = 0 ; i < (engine.targetShield * enemy[engine.targetIndex].shield) ; i++)
{
if (i > 50)
shieldColor = graphics.green;
shieldColor = green;
else if ((i >= 25) && (i <= 50))
shieldColor = graphics.yellow;
shieldColor = yellow;
else
shieldColor = graphics.red;
SDL_FillRect(graphics.screen, &bar, shieldColor);
shieldColor = red;
SDL_FillRect(screen, &bar, shieldColor);
bar.x += 2;
}
}
}
graphics.blitText(11);
blitText(11);
bar.w = 25;
bar.h = 12;
bar.x = 80;
bar.y = 571;
SDL_FillRect(graphics.screen, &bar, graphics.green);
SDL_FillRect(screen, &bar, green);
for (int i = 1 ; i < currentGame.maxPlasmaDamage ; i++)
{
bar.x += 30;
if (weapon[1].damage >= (i + 1))
SDL_FillRect(graphics.screen, &bar, graphics.green);
SDL_FillRect(screen, &bar, green);
else
SDL_FillRect(graphics.screen, &bar, graphics.darkGreen);
SDL_FillRect(screen, &bar, darkGreen);
}
graphics.blitText(12);
blitText(12);
bar.w = 25;
bar.h = 12;
bar.x = 315;
bar.y = 571;
SDL_FillRect(graphics.screen, &bar, graphics.yellow);
SDL_FillRect(screen, &bar, yellow);
for (int i = 1 ; i < currentGame.maxPlasmaDamage ; i++)
{
bar.x += 30;
if (weapon[1].ammo[0] >= (i + 1))
SDL_FillRect(graphics.screen, &bar, graphics.yellow);
SDL_FillRect(screen, &bar, yellow);
else
SDL_FillRect(graphics.screen, &bar, graphics.darkYellow);
SDL_FillRect(screen, &bar, darkYellow);
}
graphics.blitText(13);
blitText(13);
bar.w = 25;
bar.h = 12;
@ -367,13 +367,13 @@ void doInfo()
for (int i = 15 ; i > (currentGame.maxPlasmaRate - 1) ; i -= 2)
{
if (weapon[1].reload[0] <= i)
SDL_FillRect(graphics.screen, &bar, graphics.blue);
SDL_FillRect(screen, &bar, blue);
else
SDL_FillRect(graphics.screen, &bar, graphics.darkerBlue);
SDL_FillRect(screen, &bar, darkerBlue);
bar.x += 30;
}
graphics.blitText(4);
blitText(4);
if (player.shield < 1)
return;
@ -393,12 +393,12 @@ void doInfo()
for (int i = 0 ; i < player.shield ; i += blockSize)
{
if (i >= engine.averageShield)
shieldColor = graphics.green;
shieldColor = green;
else if ((i >= engine.lowShield) && (i < engine.averageShield))
shieldColor = graphics.yellow;
shieldColor = yellow;
else
shieldColor = graphics.red;
SDL_FillRect(graphics.screen, &bar, shieldColor);
shieldColor = red;
SDL_FillRect(screen, &bar, shieldColor);
bar.x += blockSize;
if (player.maxShield < 75)
bar.x++;
@ -453,7 +453,7 @@ void resetLists()
engine.collectableHead->next = NULL;
engine.collectableTail = engine.collectableHead;
r1 = graphics.bufferHead->next;
r1 = bufferHead->next;
while (r1 != NULL)
{
r2 = r1;
@ -461,8 +461,8 @@ void resetLists()
delete r2;
}
graphics.bufferHead->next = NULL;
graphics.bufferTail = graphics.bufferHead;
bufferHead->next = NULL;
bufferTail = bufferHead;
ob = engine.debrisHead->next;
while(ob != NULL)

View File

@ -676,42 +676,42 @@ static void drawBriefScreen()
for (int i = 0 ; i < 120 ; i++)
{
r.y = (i * 2) + 60;
SDL_FillRect(graphics.screen, &r, SDL_MapRGB(graphics.screen->format, 0, i, 0));
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
r.y = (300 + (i * 2));
SDL_FillRect(graphics.screen, &r, SDL_MapRGB(graphics.screen->format, 0, (120 - i), 0));
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, (120 - i), 0));
}
graphics.blevelRect(140, 70, 500, 20, 0x00, 0x77, 0x00);
graphics.blevelRect(140, 90, 500, 130, 0x00, 0x33, 0x00);
graphics.drawString("Primary Objectives", 150, 74, FONT_WHITE);
blevelRect(140, 70, 500, 20, 0x00, 0x77, 0x00);
blevelRect(140, 90, 500, 130, 0x00, 0x33, 0x00);
drawString("Primary Objectives", 150, 74, FONT_WHITE);
for (int i = 0 ; i < 3 ; i++)
{
if ((currentMission.primaryType[i] != NONE) && (currentMission.completed1[i] != OB_HIDDEN))
{
graphics.drawString(currentMission.primaryObjective[i], 160, 114 + (i * 30), FONT_WHITE);
drawString(currentMission.primaryObjective[i], 160, 114 + (i * 30), FONT_WHITE);
}
}
if (currentMission.secondaryType[0] != NONE)
{
graphics.blevelRect(140, 230, 500, 20, 0x00, 0x77, 0x77);
graphics.blevelRect(140, 250, 500, 130, 0x00, 0x33, 0x33);
graphics.drawString("Secondary Objectives", 150, 234, FONT_WHITE);
blevelRect(140, 230, 500, 20, 0x00, 0x77, 0x77);
blevelRect(140, 250, 500, 130, 0x00, 0x33, 0x33);
drawString("Secondary Objectives", 150, 234, FONT_WHITE);
for (int i = 0 ; i < 3 ; i++)
{
if (currentMission.secondaryType[i] != NONE)
{
graphics.drawString(currentMission.secondaryObjective[i], 160, 274 + (i * 30), FONT_WHITE);
drawString(currentMission.secondaryObjective[i], 160, 274 + (i * 30), FONT_WHITE);
currentGame.secondaryMissions++;
}
}
}
graphics.blevelRect(140, 390, 500, 20, 0x77, 0x77, 0x00);
graphics.blevelRect(140, 410, 500, 130, 0x33, 0x33, 0x00);
graphics.drawString("Additional Information", 150, 394, FONT_WHITE);
blevelRect(140, 390, 500, 20, 0x77, 0x77, 0x00);
blevelRect(140, 410, 500, 130, 0x33, 0x33, 0x00);
drawString("Additional Information", 150, 394, FONT_WHITE);
}
/*
@ -721,12 +721,12 @@ mission begins playing here.
*/
void missionBriefScreen()
{
graphics.clearScreen(graphics.black);
graphics.updateScreen();
clearScreen(black);
updateScreen();
if (currentGame.area != MAX_MISSIONS - 1)
{
graphics.clearScreen(graphics.black);
clearScreen(black);
drawBriefScreen();
if (currentMission.timeLimit1[0] > 0)
@ -737,7 +737,7 @@ void missionBriefScreen()
sprintf(temp, "TIME LIMIT: %d minutes", currentMission.timeLimit1[0]);
else
sprintf(temp, "SURVIVAL FOR %d minutes", currentMission.timeLimit1[0]);
graphics.drawString(temp, -1, 500, FONT_RED);
drawString(temp, -1, 500, FONT_RED);
}
switch (currentGame.area)
@ -749,43 +749,43 @@ void missionBriefScreen()
case 18:
case 24:
case 26:
graphics.drawString("Phoebe Lexx will not be present", 160, 420, FONT_WHITE);
drawString("Phoebe Lexx will not be present", 160, 420, FONT_WHITE);
if (currentGame.hasWingMate2)
graphics.drawString("Ursula Lexx will not be present", 160, 450, FONT_WHITE);
drawString("Ursula Lexx will not be present", 160, 450, FONT_WHITE);
break;
}
if ((currentGame.area == 9) || (currentGame.area == 17) || (currentGame.area == 25))
graphics.drawString("Sid Wilson will join you on this mission", 160, 480, FONT_WHITE);
drawString("Sid Wilson will join you on this mission", 160, 480, FONT_WHITE);
graphics.updateScreen();
updateScreen();
}
loadGameGraphics();
graphics.textSurface(4, "Shield", 25, 550, FONT_WHITE);
graphics.textSurface(5, "Plasma:", 250, 550, FONT_WHITE);
textSurface(4, "Shield", 25, 550, FONT_WHITE);
textSurface(5, "Plasma:", 250, 550, FONT_WHITE);
if (player.weaponType[1] == W_CHARGER)
graphics.textSurface(6, "Charge", 385, 550, FONT_WHITE);
textSurface(6, "Charge", 385, 550, FONT_WHITE);
else if (player.weaponType[1] == W_LASER)
graphics.textSurface(6, "Heat", 405, 550, FONT_WHITE);
textSurface(6, "Heat", 405, 550, FONT_WHITE);
else
graphics.textSurface(6, "Rockets:", 385, 550, FONT_WHITE);
textSurface(6, "Rockets:", 385, 550, FONT_WHITE);
graphics.textSurface(7, "Target", 550, 550, FONT_WHITE);
graphics.textSurface(8, "Cash: $", 25, 20, FONT_WHITE);
graphics.textSurface(9, "Objectives Remaining:", 550, 20, FONT_WHITE);
graphics.textSurface(10, "Time Remaining - ", 260, 20, FONT_WHITE);
graphics.textSurface(11, "Power", 25, 570, FONT_WHITE);
graphics.textSurface(12, "Output", 250, 570, FONT_WHITE);
graphics.textSurface(13, "Cooler", 485, 570, FONT_WHITE);
textSurface(7, "Target", 550, 550, FONT_WHITE);
textSurface(8, "Cash: $", 25, 20, FONT_WHITE);
textSurface(9, "Objectives Remaining:", 550, 20, FONT_WHITE);
textSurface(10, "Time Remaining - ", 260, 20, FONT_WHITE);
textSurface(11, "Power", 25, 570, FONT_WHITE);
textSurface(12, "Output", 250, 570, FONT_WHITE);
textSurface(13, "Cooler", 485, 570, FONT_WHITE);
playRandomTrack();
if (currentGame.area != MAX_MISSIONS - 1)
{
graphics.drawString("PRESS CTRL TO CONTINUE...", -1, 550, FONT_WHITE);
drawString("PRESS CTRL TO CONTINUE...", -1, 550, FONT_WHITE);
graphics.updateScreen();
updateScreen();
flushInput();
engine.done = 0;
@ -793,15 +793,15 @@ void missionBriefScreen()
while (true)
{
graphics.delayFrame();
delayFrame();
getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
break;
}
graphics.clearScreen(graphics.black);
graphics.updateScreen();
graphics.clearScreen(graphics.black);
clearScreen(black);
updateScreen();
clearScreen(black);
}
engine.gameSection = SECTION_GAME;
@ -817,13 +817,13 @@ void missionFinishedScreen()
{
if (currentGame.area != MAX_MISSIONS - 1)
{
graphics.clearScreen(graphics.black);
graphics.updateScreen();
clearScreen(black);
updateScreen();
if (currentGame.shots > 0)
currentGame.accuracy = (currentGame.hits * 100) / currentGame.shots;
graphics.clearScreen(graphics.black);
clearScreen(black);
drawBriefScreen();
char temp[100];
@ -833,9 +833,9 @@ void missionFinishedScreen()
if (currentMission.primaryType[i] != NONE)
{
if ((currentGame.area != 17) || ((currentGame.area == 17) && (i != 1)))
graphics.drawString("COMPLETED", 550, 114 + (i * 30), FONT_GREEN);
drawString("COMPLETED", 550, 114 + (i * 30), FONT_GREEN);
else
graphics.drawString("FAILED", 550, 114 + (i * 30), FONT_RED);
drawString("FAILED", 550, 114 + (i * 30), FONT_RED);
}
}
@ -848,12 +848,12 @@ void missionFinishedScreen()
sprintf(temp, currentMission.secondaryObjective[i]);
if (currentMission.completed2[i] >= 1)
{
graphics.drawString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN);
drawString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN);
currentGame.secondaryMissionsCompleted++;
}
else
{
graphics.drawString("FAILED", 550, 274 + (i * 30), FONT_RED);
drawString("FAILED", 550, 274 + (i * 30), FONT_RED);
}
}
}
@ -862,7 +862,7 @@ void missionFinishedScreen()
if (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 0)
{
sprintf(temp, "Shield Bonus: $%.3d", (player.shield * 10));
graphics.drawString(temp, -1, 430, FONT_WHITE);
drawString(temp, -1, 430, FONT_WHITE);
currentGame.cash += (player.shield * 10);
currentGame.cashEarned += (player.shield * 10);
}
@ -871,7 +871,7 @@ void missionFinishedScreen()
snprintf(temp, sizeof temp, "Mission Time: %2d:%02d:%02d", engine.timeTaken / 3600, (engine.timeTaken / 60) % 60, engine.timeTaken % 60);
graphics.drawString(temp, -1, 500, FONT_WHITE);
drawString(temp, -1, 500, FONT_WHITE);
// Do some mission specific stuff here...
if (currentGame.area == 1)
@ -883,7 +883,7 @@ void missionFinishedScreen()
checkForBossMission();
graphics.updateScreen();
updateScreen();
flushInput();
engine.done = 0;
@ -891,7 +891,7 @@ void missionFinishedScreen()
while (true)
{
graphics.delayFrame();
delayFrame();
getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
break;

View File

@ -35,8 +35,8 @@ void initPlayer()
player.systemPower = player.maxShield;
player.face = 0;
player.image[0] = graphics.shipShape[0];
player.image[1] = graphics.shipShape[1];
player.image[0] = shipShape[0];
player.image[1] = shipShape[1];
player.engineX = player.image[0]->w;
player.engineY = (player.image[0]->h / 2);
@ -282,7 +282,7 @@ void doPlayer()
limitCharAdd(&player.hit, -1, 0, 100);
graphics.blit(graphics.shipShape[shapeToUse], (int)player.x, (int)player.y);
blit(shipShape[shapeToUse], (int)player.x, (int)player.y);
if ((player.shield <= engine.lowShield) && (rand() % 5 < 1))
addExplosion(player.x + rrand(-10, 10), player.y + rrand(-10, 20), E_SMOKE);
}

View File

@ -22,13 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void loadBackground(const char *filename)
{
if (graphics.background != NULL)
if (background != NULL)
{
SDL_FreeSurface(graphics.background);
graphics.background = NULL;
SDL_FreeSurface(background);
background = NULL;
}
graphics.background = loadImage(filename);
SDL_SetColorKey(graphics.background, 0, 0);
background = loadImage(filename);
SDL_SetColorKey(background, 0, 0);
}
void loadGameGraphics()
@ -36,10 +36,10 @@ void loadGameGraphics()
int index;
char string[75];
graphics.freeGraphics();
freeGraphics();
graphics.shipShape[0] = loadImage("gfx/firefly1.png");
graphics.shipShape[1] = loadImage("gfx/firefly2.png");
shipShape[0] = loadImage("gfx/firefly1.png");
shipShape[1] = loadImage("gfx/firefly2.png");
strcpy(string, "");
switch(currentGame.system)
@ -74,7 +74,7 @@ void loadGameGraphics()
fscanf(fp, "%d %s", &index, string);
while (index != -1)
{
graphics.shipShape[index] = loadImage(string);
shipShape[index] = loadImage(string);
fscanf(fp, "%d %s", &index, string);
}
@ -86,13 +86,13 @@ void loadGameGraphics()
SDL_Surface *hitRect;
for (int i = SHIP_HIT_INDEX ; i < MAX_SHIPSHAPES ; i++)
{
if (graphics.shipShape[i - SHIP_HIT_INDEX] == NULL)
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
continue;
graphics.shipShape[i] = graphics.createSurface(graphics.shipShape[i - SHIP_HIT_INDEX]->w, graphics.shipShape[i- SHIP_HIT_INDEX]->h);
graphics.blit(graphics.shipShape[i - SHIP_HIT_INDEX], 0, 0, graphics.shipShape[i]);
hitRect = graphics.alphaRect(graphics.shipShape[i]->w, graphics.shipShape[i]->h, 255, 0, 0);
graphics.blit(hitRect, 0, 0, graphics.shipShape[i]);
SDL_SetColorKey(graphics.shipShape[i], (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(graphics.shipShape[i]->format, 127, 0, 0));
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w, shipShape[i- SHIP_HIT_INDEX]->h);
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
hitRect = alphaRect(shipShape[i]->w, shipShape[i]->h, 255, 0, 0);
blit(hitRect, 0, 0, shipShape[i]);
SDL_SetColorKey(shipShape[i], (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(shipShape[i]->format, 127, 0, 0));
SDL_FreeSurface(hitRect);
}
@ -109,7 +109,7 @@ void loadGameGraphics()
fscanf(fp, "%d %s", &index, string);
while (index != -1)
{
graphics.shape[index] = loadImage(string);
shape[index] = loadImage(string);
fscanf(fp, "%d %s", &index, string);
}
@ -214,7 +214,7 @@ void loadFont()
newImage = SDL_DisplayFormat(image);
graphics.fontShape[i] = graphics.setTransparent(newImage);
fontShape[i] = setTransparent(newImage);
SDL_FreeSurface(image);
}

View File

@ -174,7 +174,7 @@ static void setScene(int scene)
if (shape > -1)
{
enemy[index].image[0] = graphics.shipShape[shape];
enemy[index].image[0] = shipShape[shape];
enemy[index].x = x;
enemy[index].y = y;
enemy[index].dx = speed;
@ -200,17 +200,17 @@ static void setScene(int scene)
void doCutscene(int scene)
{
graphics.clearScreen(graphics.black);
graphics.updateScreen();
graphics.clearScreen(graphics.black);
clearScreen(black);
updateScreen();
clearScreen(black);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
engine.ssx = -0.5;
engine.ssy = 0;
graphics.flushBuffer();
graphics.freeGraphics();
flushBuffer();
freeGraphics();
resetLists();
loadGameGraphics();
@ -243,7 +243,7 @@ void doCutscene(int scene)
signed char currentMessage = -1;
int timer = 60 * 4;
graphics.drawBackGround();
drawBackGround();
SDL_Surface *face;
@ -251,8 +251,8 @@ void doCutscene(int scene)
while (true)
{
graphics.updateScreen();
graphics.unBuffer();
updateScreen();
unBuffer();
getPlayerInput();
doStarfield();
doExplosions();
@ -264,7 +264,7 @@ void doCutscene(int scene)
addEngine(&enemy[i]);
enemy[i].x += enemy[i].dx;
enemy[i].x += engine.ssx;
graphics.blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y);
blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y);
if (enemy[i].x > 850)
{
enemy[i].x = -50;
@ -291,22 +291,22 @@ void doCutscene(int scene)
face = NULL;
if (cutMessage[currentMessage].face != -1)
face = graphics.shape[cutMessage[currentMessage].face];
graphics.createMessageBox(face, cutMessage[currentMessage].message, 0);
face = shape[cutMessage[currentMessage].face];
createMessageBox(face, cutMessage[currentMessage].message, 0);
}
}
if ((showMessage) && (graphics.messageBox != NULL))
graphics.blit(graphics.messageBox, (800 - graphics.messageBox->w) / 2, 500);
if ((showMessage) && (messageBox != NULL))
blit(messageBox, (800 - messageBox->w) / 2, 500);
graphics.delayFrame();
delayFrame();
if (engine.keyState[SDLK_ESCAPE])
break;
}
graphics.flushBuffer();
graphics.freeGraphics();
graphics.clearScreen(graphics.black);
graphics.updateScreen();
flushBuffer();
freeGraphics();
clearScreen(black);
updateScreen();
}

View File

@ -28,7 +28,7 @@ static void drawSecondaryWeaponSurface()
char description[50];
strcpy(description, "");
graphics.drawString("Secondary Weapon", 10, 3, FONT_WHITE, graphics.shopSurface[2]);
drawString("Secondary Weapon", 10, 3, FONT_WHITE, shopSurface[2]);
switch (player.weaponType[1])
{
@ -60,12 +60,12 @@ static void drawSecondaryWeaponSurface()
strcpy(description, "Type : Mcr Homing Missiles");
break;
}
graphics.drawString(description, 10, 22, FONT_WHITE, graphics.shopSurface[2]);
drawString(description, 10, 22, FONT_WHITE, shopSurface[2]);
if ((player.weaponType[1] != W_LASER) && (player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_NONE))
{
sprintf(description, "Capacity : %d", currentGame.maxRocketAmmo);
graphics.drawString(description, 10, 37, FONT_WHITE, graphics.shopSurface[2]);
drawString(description, 10, 37, FONT_WHITE, shopSurface[2]);
}
}
@ -107,23 +107,23 @@ static void drawShop()
for (int i = 0 ; i < MAX_SHOPSHAPES ; i++)
{
if (graphics.shopSurface[i] != NULL)
if (shopSurface[i] != NULL)
{
SDL_FreeSurface(graphics.shopSurface[i]);
SDL_FreeSurface(shopSurface[i]);
}
}
for (int i = 0 ; i < 3 ; i++)
graphics.shopSurface[i] = graphics.createSurface(246, 91);
shopSurface[i] = createSurface(246, 91);
for (int i = 0 ; i < 3 ; i++)
{
graphics.blevelRect(graphics.shopSurface[i], 0, 0, 245, 90, 0x00, 0x00, 0x55);
graphics.blevelRect(graphics.shopSurface[i], 0, 0, 245, 20, 0x00, 0x00, 0x99);
blevelRect(shopSurface[i], 0, 0, 245, 90, 0x00, 0x00, 0x55);
blevelRect(shopSurface[i], 0, 0, 245, 20, 0x00, 0x00, 0x99);
}
graphics.shopSurface[4] = graphics.alphaRect(601, 101, 0x00, 0x00, 0x00);
graphics.blevelRect(graphics.shopSurface[4], 0, 0, 600, 100, 0x00, 0x00, 0x33);
shopSurface[4] = alphaRect(601, 101, 0x00, 0x00, 0x00);
blevelRect(shopSurface[4], 0, 0, 600, 100, 0x00, 0x00, 0x33);
switch (shopSelectedItem)
{
@ -138,58 +138,58 @@ static void drawShop()
case 1:
case 2:
case 8:
graphics.blevelRect(graphics.shopSurface[1], 0, 0, 245, 90, 0x55, 0x00, 0x00);
graphics.blevelRect(graphics.shopSurface[1], 0, 0, 245, 20, 0x99, 0x00, 0x00);
blevelRect(shopSurface[1], 0, 0, 245, 90, 0x55, 0x00, 0x00);
blevelRect(shopSurface[1], 0, 0, 245, 20, 0x99, 0x00, 0x00);
break;
case 3:
case 4:
graphics.blevelRect(graphics.shopSurface[4], 0, 0, 600, 100, 0x33, 0x00, 0x00);
blevelRect(shopSurface[4], 0, 0, 600, 100, 0x33, 0x00, 0x00);
break;
case 5:
case 6:
case 7:
graphics.blevelRect(graphics.shopSurface[0], 0, 0, 245, 90, 0x55, 0x00, 0x00);
graphics.blevelRect(graphics.shopSurface[0], 0, 0, 245, 20, 0x99, 0x00, 0x00);
blevelRect(shopSurface[0], 0, 0, 245, 90, 0x55, 0x00, 0x00);
blevelRect(shopSurface[0], 0, 0, 245, 20, 0x99, 0x00, 0x00);
break;
default:
graphics.blevelRect(graphics.shopSurface[2], 0, 0, 245, 90, 0x55, 0x00, 0x00);
graphics.blevelRect(graphics.shopSurface[2], 0, 0, 245, 20, 0x99, 0x00, 0x00);
blevelRect(shopSurface[2], 0, 0, 245, 90, 0x55, 0x00, 0x00);
blevelRect(shopSurface[2], 0, 0, 245, 20, 0x99, 0x00, 0x00);
break;
}
char description[100];
strcpy(description, "");
graphics.drawString("Primary Weapon", 10, 3, FONT_WHITE, graphics.shopSurface[0]);
drawString("Primary Weapon", 10, 3, FONT_WHITE, shopSurface[0]);
sprintf(description, "Plasma Cannons : %d", weapon[0].ammo[0]);
graphics.drawString(description, 10, 22, FONT_WHITE, graphics.shopSurface[0]);
drawString(description, 10, 22, FONT_WHITE, shopSurface[0]);
sprintf(description, "Plasma Power : Stage %d", weapon[0].damage);
graphics.drawString(description, 10, 37, FONT_WHITE, graphics.shopSurface[0]);
drawString(description, 10, 37, FONT_WHITE, shopSurface[0]);
sprintf(description, "Cooler : Stage %d", ((15 - weapon[0].reload[0]) / 2) + 1);
graphics.drawString(description, 10, 52, FONT_WHITE, graphics.shopSurface[0]);
drawString(description, 10, 52, FONT_WHITE, shopSurface[0]);
graphics.drawString("Powerup Weapon", 10, 3, FONT_WHITE, graphics.shopSurface[1]);
drawString("Powerup Weapon", 10, 3, FONT_WHITE, shopSurface[1]);
sprintf(description, "Plasma Output : Stage %d", currentGame.maxPlasmaOutput);
graphics.drawString(description, 10, 22, FONT_WHITE, graphics.shopSurface[1]);
drawString(description, 10, 22, FONT_WHITE, shopSurface[1]);
sprintf(description, "Plasma Condensor : Stage %d", currentGame.maxPlasmaDamage);
graphics.drawString(description, 10, 37, FONT_WHITE, graphics.shopSurface[1]);
drawString(description, 10, 37, FONT_WHITE, shopSurface[1]);
sprintf(description, "Liquid Nitrogen : Stage %d", ((15 - currentGame.maxPlasmaRate) / 2) + 1);
graphics.drawString(description, 10, 52, FONT_WHITE, graphics.shopSurface[1]);
drawString(description, 10, 52, FONT_WHITE, shopSurface[1]);
sprintf(description, "Plasma Capacity : %d", currentGame.maxPlasmaAmmo);
graphics.drawString(description, 10, 67, FONT_WHITE, graphics.shopSurface[1]);
drawString(description, 10, 67, FONT_WHITE, shopSurface[1]);
drawSecondaryWeaponSurface();
graphics.shopSurface[3] = graphics.createSurface(601, 121);
shopSurface[3] = createSurface(601, 121);
graphics.blevelRect(graphics.shopSurface[3], 0, 0, 600, 120, 0x00, 0x00, 0x22);
blevelRect(shopSurface[3], 0, 0, 600, 120, 0x00, 0x00, 0x22);
graphics.drawString("Temporary Weapons", 10, 2, FONT_WHITE, graphics.shopSurface[3]);
graphics.drawString("Ammo and Storage", 260, 2, FONT_WHITE, graphics.shopSurface[3]);
drawString("Temporary Weapons", 10, 2, FONT_WHITE, shopSurface[3]);
drawString("Ammo and Storage", 260, 2, FONT_WHITE, shopSurface[3]);
graphics.drawString("Primary Weapons", 10, 62, FONT_WHITE, graphics.shopSurface[3]);
drawString("Primary Weapons", 10, 62, FONT_WHITE, shopSurface[3]);
graphics.drawString("Secondary Weapons", 260, 62, FONT_WHITE, graphics.shopSurface[3]);
drawString("Secondary Weapons", 260, 62, FONT_WHITE, shopSurface[3]);
signed char icons = MAX_SHOPITEMS;
@ -201,50 +201,50 @@ static void drawShop()
icons = 15;
for (int i = 0 ; i < icons ; i++)
graphics.blit(graphics.shape[shopItems[i].image], shopItems[i].x - 90, shopItems[i].y - 178, graphics.shopSurface[3]);
blit(shape[shopItems[i].image], shopItems[i].x - 90, shopItems[i].y - 178, shopSurface[3]);
sprintf(description, "Shield Units : %d", currentGame.shieldUnits * 25);
graphics.drawString(description, 10, 4, FONT_WHITE, graphics.shopSurface[4]);
drawString(description, 10, 4, FONT_WHITE, shopSurface[4]);
sprintf(description, "Cash : $%d", currentGame.cash);
graphics.drawString(description, 10, 80, FONT_WHITE, graphics.shopSurface[4]);
drawString(description, 10, 80, FONT_WHITE, shopSurface[4]);
sprintf(description, "Plasma Cells : %.3d", player.ammo[0]);
graphics.drawString(description, 430, 4, FONT_WHITE, graphics.shopSurface[4]);
drawString(description, 430, 4, FONT_WHITE, shopSurface[4]);
sprintf(description, "Rockets : %.3d", player.ammo[1]);
graphics.drawString(description, 475, 80, FONT_WHITE, graphics.shopSurface[4]);
drawString(description, 475, 80, FONT_WHITE, shopSurface[4]);
graphics.shopSurface[5] = graphics.createSurface(601, 56);
graphics.blevelRect(graphics.shopSurface[5], 0, 0, 600, 35, 0x00, 0x99, 0x00);
graphics.blevelRect(graphics.shopSurface[5], 0, 20, 600, 35, 0x00, 0x33, 0x00);
graphics.drawString("Information", 5, 4, FONT_WHITE, graphics.shopSurface[5]);
shopSurface[5] = createSurface(601, 56);
blevelRect(shopSurface[5], 0, 0, 600, 35, 0x00, 0x99, 0x00);
blevelRect(shopSurface[5], 0, 20, 600, 35, 0x00, 0x33, 0x00);
drawString("Information", 5, 4, FONT_WHITE, shopSurface[5]);
switch (shopSelectedItem)
{
case -1:
break;
case -2:
graphics.drawString("You don't have enough money", 20, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("You don't have enough money", 20, 30, FONT_WHITE, shopSurface[5]);
break;
case -3:
graphics.drawString("Cannot upgrade ship", 5, 22, FONT_WHITE, graphics.shopSurface[5]);
graphics.drawString("Hardware capacity has been reached", 20, 38, FONT_CYAN, graphics.shopSurface[5]);
drawString("Cannot upgrade ship", 5, 22, FONT_WHITE, shopSurface[5]);
drawString("Hardware capacity has been reached", 20, 38, FONT_CYAN, shopSurface[5]);
break;
case -4:
graphics.drawString("Ammunition limit reached", 20, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("Ammunition limit reached", 20, 30, FONT_WHITE, shopSurface[5]);
break;
case -5:
graphics.drawString("You cannot sell that item", 20, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("You cannot sell that item", 20, 30, FONT_WHITE, shopSurface[5]);
break;
case -6:
graphics.drawString("Nothing to sell", 20, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("Nothing to sell", 20, 30, FONT_WHITE, shopSurface[5]);
break;
case -7:
graphics.drawString("Rockets cannot be bought for Laser or Charger Cannon", 5, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("Rockets cannot be bought for Laser or Charger Cannon", 5, 30, FONT_WHITE, shopSurface[5]);
break;
case -8:
graphics.drawString("You already have that weapon", 20, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("You already have that weapon", 20, 30, FONT_WHITE, shopSurface[5]);
break;
case -9:
graphics.drawString("This weapon's ammo limit has been reached", 20, 30, FONT_WHITE, graphics.shopSurface[5]);
drawString("This weapon's ammo limit has been reached", 20, 30, FONT_WHITE, shopSurface[5]);
break;
default:
if (shopItems[shopSelectedItem].price != 0)
@ -255,8 +255,8 @@ static void drawShop()
{
sprintf(description, "%s (N/A)", shopItems[shopSelectedItem].description);
}
graphics.drawString(shopItems[shopSelectedItem].name, 5, 22, FONT_WHITE, graphics.shopSurface[5]);
graphics.drawString(description, 20, 38, FONT_CYAN, graphics.shopSurface[5]);
drawString(shopItems[shopSelectedItem].name, 5, 22, FONT_WHITE, shopSurface[5]);
drawString(description, 20, 38, FONT_CYAN, shopSurface[5]);
break;
}
}
@ -299,7 +299,7 @@ static void loadShop()
shopSelectedItem = -1;
player.image[0] = graphics.shape[0];
player.image[0] = shape[0];
player.x = 380;
player.y = 95;
@ -467,7 +467,7 @@ void initShop()
shopSelectedItem = -1;
player.image[0] = graphics.shape[0];
player.image[0] = shape[0];
player.x = 380;
player.y = 95;
@ -719,20 +719,20 @@ static void sell(int i)
void showShop()
{
graphics.blit(graphics.shopSurface[0], 20, 395);
graphics.blit(graphics.shopSurface[1], 275, 395);
graphics.blit(graphics.shopSurface[2], 530, 395);
graphics.blit(graphics.shopSurface[3], 100, 180);
graphics.blit(graphics.shopSurface[4], 100, 50);
graphics.blit(graphics.shopSurface[5], 100, 320);
blit(shopSurface[0], 20, 395);
blit(shopSurface[1], 275, 395);
blit(shopSurface[2], 530, 395);
blit(shopSurface[3], 100, 180);
blit(shopSurface[4], 100, 50);
blit(shopSurface[5], 100, 320);
if (shopSelectedItem > -1)
{
graphics.blit(graphics.shape[27], 60, 350);
graphics.blit(graphics.shape[28], 710, 350);
blit(shape[27], 60, 350);
blit(shape[28], 710, 350);
}
graphics.blit(graphics.shape[29], (int)player.x, (int)player.y);
blit(shape[29], (int)player.x, (int)player.y);
signed char icons = MAX_SHOPITEMS;

View File

@ -22,23 +22,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static signed char showGameMenu(signed char continueSaveSlot)
{
graphics.blitText(2);
blitText(2);
if (continueSaveSlot != 0)
{
graphics.blitText(3);
graphics.blitText(4);
blitText(3);
blitText(4);
}
graphics.blitText(5);
blitText(5);
if (engine.cheat)
{
graphics.textShape[7].y = 450;
graphics.blitText(6);
textShape[7].y = 450;
blitText(6);
}
else
{
graphics.textShape[7].y = 430;
textShape[7].y = 430;
}
graphics.blitText(7);
blitText(7);
if (engine.cheat)
return 6;
@ -52,14 +52,14 @@ static signed char showLoadMenu()
for (int i = 13 ; i < 18 ; i++)
{
if (graphics.textShape[i].image != NULL)
if (textShape[i].image != NULL)
{
graphics.blitText(i);
blitText(i);
rtn++;
graphics.textShape[12].y = graphics.textShape[i].y + 40;
textShape[12].y = textShape[i].y + 40;
}
}
graphics.blitText(12);
blitText(12);
return rtn;
}
@ -67,36 +67,36 @@ static signed char showLoadMenu()
static void createOptionsMenu()
{
if (engine.useSound)
graphics.textSurface(8, "SOUND - ON", -1, 350, FONT_WHITE);
textSurface(8, "SOUND - ON", -1, 350, FONT_WHITE);
else
graphics.textSurface(8, "SOUND - OFF", -1, 350, FONT_WHITE);
textSurface(8, "SOUND - OFF", -1, 350, FONT_WHITE);
if (engine.useMusic)
graphics.textSurface(9, "MUSIC - ON", -1, 370, FONT_WHITE);
textSurface(9, "MUSIC - ON", -1, 370, FONT_WHITE);
else
graphics.textSurface(9, "MUSIC - OFF", -1, 370, FONT_WHITE);
textSurface(9, "MUSIC - OFF", -1, 370, FONT_WHITE);
if (engine.fullScreen)
graphics.textSurface(10, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
textSurface(10, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
else
graphics.textSurface(10, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
textSurface(10, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
char string[50];
strcpy(string, "AUTO SAVE SLOT - NONE");
if (currentGame.autoSaveSlot > -1)
sprintf(string, "AUTO SAVE SLOT - #%d", currentGame.autoSaveSlot + 1);
graphics.textSurface(11, string, -1, 410, FONT_WHITE);
textSurface(11, string, -1, 410, FONT_WHITE);
}
static signed char showOptionsMenu()
{
graphics.textShape[12].y = 450;
textShape[12].y = 450;
graphics.blitText(8);
graphics.blitText(9);
graphics.blitText(10);
graphics.blitText(11);
graphics.blitText(12);
blitText(8);
blitText(9);
blitText(10);
blitText(11);
blitText(12);
return 5;
}
@ -104,35 +104,35 @@ static signed char showOptionsMenu()
static void createCheatMenu()
{
if (engine.cheatShield)
graphics.textSurface(18, "UNLIMITED SHIELD - ON", -1, 350, FONT_WHITE);
textSurface(18, "UNLIMITED SHIELD - ON", -1, 350, FONT_WHITE);
else
graphics.textSurface(18, "UNLIMITED SHIELD - OFF", -1, 350, FONT_WHITE);
textSurface(18, "UNLIMITED SHIELD - OFF", -1, 350, FONT_WHITE);
if (engine.cheatAmmo)
graphics.textSurface(19, "UNLIMITED AMMO - ON", -1, 370, FONT_WHITE);
textSurface(19, "UNLIMITED AMMO - ON", -1, 370, FONT_WHITE);
else
graphics.textSurface(19, "UNLIMITED AMMO - OFF", -1, 370, FONT_WHITE);
textSurface(19, "UNLIMITED AMMO - OFF", -1, 370, FONT_WHITE);
if (engine.cheatCash)
graphics.textSurface(20, "UNLIMITED CASH - ON", -1, 390, FONT_WHITE);
textSurface(20, "UNLIMITED CASH - ON", -1, 390, FONT_WHITE);
else
graphics.textSurface(20, "UNLIMITED CASH - OFF", -1, 390, FONT_WHITE);
textSurface(20, "UNLIMITED CASH - OFF", -1, 390, FONT_WHITE);
if (engine.cheatTime)
graphics.textSurface(21, "UNLIMITED TIME - ON", -1, 410, FONT_WHITE);
textSurface(21, "UNLIMITED TIME - ON", -1, 410, FONT_WHITE);
else
graphics.textSurface(21, "UNLIMITED TIME - OFF", -1, 410, FONT_WHITE);
textSurface(21, "UNLIMITED TIME - OFF", -1, 410, FONT_WHITE);
}
static signed char showCheatMenu()
{
graphics.textShape[12].y = 450;
textShape[12].y = 450;
graphics.blitText(18);
graphics.blitText(19);
graphics.blitText(20);
graphics.blitText(21);
graphics.blitText(12);
blitText(18);
blitText(19);
blitText(20);
blitText(21);
blitText(12);
return 5;
}
@ -147,8 +147,8 @@ int doTitle()
engine.gameSection = SECTION_TITLE;
graphics.flushBuffer();
graphics.freeGraphics();
flushBuffer();
freeGraphics();
resetLists();
// required to stop the title screen crashing
@ -157,9 +157,9 @@ int doTitle()
loadGameGraphics();
graphics.clearScreen(graphics.black);
graphics.updateScreen();
graphics.clearScreen(graphics.black);
clearScreen(black);
updateScreen();
clearScreen(black);
signed char continueSaveSlot = initSaveSlots();
@ -177,17 +177,17 @@ int doTitle()
int sfx = ((800 - sflogo->w) / 2);
int sfy = ((600 - sflogo->h) / 2);
graphics.textSurface(0, "PRESENTS", -1, 300, FONT_WHITE);
graphics.textSurface(1, "AN SDL GAME", -1, 300, FONT_WHITE);
graphics.textSurface(2, "START NEW GAME", -1, 350, FONT_WHITE);
graphics.textSurface(3, "LOAD GAME", -1, 370, FONT_WHITE);
graphics.textSurface(4, "CONTINUE CURRENT GAME", -1, 390, FONT_WHITE);
graphics.textSurface(5, "OPTIONS", -1, 410, FONT_WHITE);
graphics.textSurface(6, "CHEAT OPTIONS", -1, 430, FONT_WHITE);
graphics.textSurface(7, "QUIT", -1, 430, FONT_WHITE);
textSurface(0, "PRESENTS", -1, 300, FONT_WHITE);
textSurface(1, "AN SDL GAME", -1, 300, FONT_WHITE);
textSurface(2, "START NEW GAME", -1, 350, FONT_WHITE);
textSurface(3, "LOAD GAME", -1, 370, FONT_WHITE);
textSurface(4, "CONTINUE CURRENT GAME", -1, 390, FONT_WHITE);
textSurface(5, "OPTIONS", -1, 410, FONT_WHITE);
textSurface(6, "CHEAT OPTIONS", -1, 430, FONT_WHITE);
textSurface(7, "QUIT", -1, 430, FONT_WHITE);
createOptionsMenu();
graphics.textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
createCheatMenu();
@ -231,7 +231,7 @@ int doTitle()
signed char listLength = 5; // menu list length
signed char menuType = 0;
graphics.drawBackGround();
drawBackGround();
engine.done = 0;
flushInput();
@ -242,8 +242,8 @@ int doTitle()
while (!engine.done)
{
graphics.updateScreen();
graphics.unBuffer();
updateScreen();
unBuffer();
now = SDL_GetTicks();
@ -254,7 +254,7 @@ int doTitle()
{
addEngine(&enemy[i]);
enemy[i].x += enemy[i].dx;
graphics.blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y);
blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y);
if (enemy[i].x > 830)
{
enemy[i].x = -10;
@ -265,25 +265,25 @@ int doTitle()
if ((now - then > 2000) && (now - then < 8000) && (!skip))
{
graphics.blit(prlogo, prx, pry);
blit(prlogo, prx, pry);
}
else if ((now - then > 9000) && (now - then < 15000) && (!skip))
{
graphics.blitText(0);
blitText(0);
}
else if ((now - then > 16000) && (now - then < 21000) && (!skip))
{
graphics.blitText(1);
blitText(1);
}
else if ((now - then > 25500) || (skip))
{
graphics.blit(sflogo, sfx, sfy);
blit(sflogo, sfx, sfy);
if ((now - then >= 27500) || (skip))
{
graphics.addBuffer(280, 345, 235, 145);
addBuffer(280, 345, 235, 145);
graphics.blevelRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
blevelRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
switch(menuType)
{
@ -331,9 +331,9 @@ int doTitle()
if (!skip)
{
graphics.drawString("Copyright Parallel Realities 2003", 5, 580, FONT_WHITE, graphics.background);
graphics.drawString(buildVersion, 695, 580, FONT_WHITE, graphics.background);
graphics.addBuffer(0, 580, 800, 20);
drawString("Copyright Parallel Realities 2003", 5, 580, FONT_WHITE, background);
drawString(buildVersion, 695, 580, FONT_WHITE, background);
addBuffer(0, 580, 800, 20);
skip = true;
}
}
@ -352,9 +352,9 @@ int doTitle()
{
if ((now - then <= 27500) && (!skip))
{
graphics.drawString("Copyright Parallel Realities 2003", 5, 580, FONT_WHITE, graphics.background);
graphics.drawString(buildVersion, 695, 580, FONT_WHITE, graphics.background);
graphics.addBuffer(0, 580, 800, 20);
drawString("Copyright Parallel Realities 2003", 5, 580, FONT_WHITE, background);
drawString(buildVersion, 695, 580, FONT_WHITE, background);
addBuffer(0, 580, 800, 20);
skip = true;
}
else
@ -409,14 +409,14 @@ int doTitle()
{
engine.fullScreen = !engine.fullScreen;
#if LINUX
SDL_WM_ToggleFullScreen(graphics.screen);
SDL_WM_ToggleFullScreen(screen);
#else
if (engine.fullScreen)
graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
else
graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
graphics.drawBackground();
drawBackground();
flushBuffer();
#endif
}
@ -450,7 +450,7 @@ int doTitle()
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
}
graphics.delayFrame();
delayFrame();
}
Mix_HaltMusic();
@ -487,7 +487,7 @@ into a data file when the game is finished.
*/
void showStory()
{
graphics.freeGraphics();
freeGraphics();
int y = 620;
@ -512,7 +512,7 @@ void showStory()
fscanf(fp, "%[^\n]%*c", string);
y += nextPos;
graphics.textSurface(i, string, -1, y, FONT_WHITE);
textSurface(i, string, -1, y, FONT_WHITE);
i++;
@ -522,28 +522,28 @@ void showStory()
fclose(fp);
loadBackground("gfx/startUp.jpg");
graphics.blit(graphics.background, 0, 0);
graphics.flushBuffer();
blit(background, 0, 0);
flushBuffer();
flushInput();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
while (true)
{
graphics.updateScreen();
graphics.unBuffer();
updateScreen();
unBuffer();
getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE]))
break;
if (graphics.textShape[8].y > 450)
if (textShape[8].y > 450)
{
for (int i = 0 ; i < 9 ; i++)
{
graphics.textShape[i].y -= 0.33333;
graphics.blitText(i);
textShape[i].y -= 0.33333;
blitText(i);
}
}
else
@ -552,7 +552,7 @@ void showStory()
break;
}
graphics.delayFrame();
delayFrame();
}
}
@ -561,9 +561,9 @@ The game over screen :(
*/
void gameover()
{
graphics.flushBuffer();
graphics.freeGraphics();
SDL_FillRect(graphics.background, NULL, graphics.black);
flushBuffer();
freeGraphics();
SDL_FillRect(background, NULL, black);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
engine.gameSection = SECTION_INTERMISSION;
@ -572,9 +572,9 @@ void gameover()
SDL_Surface *gameover = loadImage("gfx/gameover.png");
graphics.clearScreen(graphics.black);
graphics.updateScreen();
graphics.clearScreen(graphics.black);
clearScreen(black);
updateScreen();
clearScreen(black);
SDL_Delay(1000);
if ((engine.useMusic) && (engine.useAudio))
@ -586,7 +586,7 @@ void gameover()
int x = (800 - gameover->w) / 2;
int y = (600 - gameover->h) / 2;
graphics.updateScreen();
updateScreen();
flushInput();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
@ -598,14 +598,14 @@ void gameover()
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE]))
break;
graphics.updateScreen();
updateScreen();
graphics.unBuffer();
unBuffer();
x = ((800 - gameover->w) / 2) - rrand(-2, 2);
y = ((600 - gameover->h) / 2) - rrand(-2, 2);
graphics.blit(gameover, x, y);
blit(gameover, x, y);
graphics.delayFrame();
delayFrame();
}
SDL_FreeSurface(gameover);
@ -613,14 +613,14 @@ void gameover()
if ((engine.useMusic) && (engine.useAudio))
Mix_HaltMusic();
graphics.flushBuffer();
flushBuffer();
}
void doCredits()
{
loadBackground("gfx/credits.jpg");
graphics.flushBuffer();
graphics.freeGraphics();
flushBuffer();
freeGraphics();
if ((engine.useMusic) && (engine.useAudio))
loadMusic("music/Solace.s3m");
@ -635,11 +635,11 @@ void doCredits()
textObject *credit;
graphics.clearScreen(graphics.black);
graphics.updateScreen();
graphics.clearScreen(graphics.black);
clearScreen(black);
updateScreen();
clearScreen(black);
graphics.drawBackGround();
drawBackGround();
#if USEPACK
int dataLocation = locateDataInPak("data/credits.txt", 1);
@ -652,7 +652,7 @@ void doCredits()
for (int i = 0 ; i < 6 ; i++)
{
fscanf(fp, "%[^\n]%*c", text);
graphics.drawString(text, -1, 240 + (i * 20), FONT_WHITE);
drawString(text, -1, 240 + (i * 20), FONT_WHITE);
}
fscanf(fp, "%d%*c", &numberOfCredits);
@ -662,7 +662,7 @@ void doCredits()
for (int i = 0 ; i < numberOfCredits ; i++)
{
fscanf(fp, "%d %[^\n]%*c", &yPos, text);
credit[i].image = graphics.textSurface(text, FONT_WHITE);
credit[i].image = textSurface(text, FONT_WHITE);
credit[i].x = (800 - credit[i].image->w) / 2;
yPos2 += yPos;
credit[i].y = yPos2;
@ -678,9 +678,9 @@ void doCredits()
SDL_Delay(3000);
graphics.updateScreen();
updateScreen();
SDL_Delay(10000);
graphics.drawBackGround();
drawBackGround();
engine.done = 0;
@ -694,8 +694,8 @@ void doCredits()
while (true)
{
graphics.updateScreen();
graphics.unBuffer();
updateScreen();
unBuffer();
getPlayerInput();
if (engine.keyState[SDLK_ESCAPE])
@ -704,15 +704,15 @@ void doCredits()
for (int i = 0 ; i < numberOfCredits ; i++)
{
if ((credit[i].y > 80) && (credit[i].y < 500))
graphics.blit(credit[i].image, (int)credit[i].x, (int)credit[i].y);
blit(credit[i].image, (int)credit[i].x, (int)credit[i].y);
if (credit[lastCredit].y > 400)
credit[i].y -= 0.3;
}
SDL_FillRect(graphics.screen, &r1, graphics.black);
SDL_FillRect(graphics.screen, &r2, graphics.black);
SDL_FillRect(screen, &r1, black);
SDL_FillRect(screen, &r2, black);
graphics.delayFrame();
delayFrame();
}
for (int i = 0 ; i < numberOfCredits ; i++)

View File

@ -26,8 +26,8 @@ void setWeaponShapes()
{
for (int i = 0 ; i < MAX_WEAPONS ; i++)
{
weapon[i].image[0] = graphics.shape[weapon[i].imageIndex[0]];
weapon[i].image[1] = graphics.shape[weapon[i].imageIndex[1]];
weapon[i].image[0] = shape[weapon[i].imageIndex[0]];
weapon[i].image[1] = shape[weapon[i].imageIndex[1]];
}
}

View File

@ -15,7 +15,7 @@ DOCDIR = /usr/share/doc/starfighter/
all: $(PROG)
# compiling other source files.
%.o: code/%.cpp code/%.h code/structs.h code/defs.h code/classes.h
%.o: code/%.cpp code/*.h
$(CXX) $(CFLAGS) -c -O3 -DVERSION=\"$(VERSION)\" -DPACKLOCATION=\"$(DATADIR)$(PACK)\" $<
# linking the program.