/*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#include "title.h"
+extern void doMusicInfo(unsigned int);
+
/**
* Displays the skill level widgets and hide the others
*/
void setupSaveWidgets()
{
char widgetName[10];
- strcpy(widgetName, "");
+ widgetName[0] = 0;
for (int i = 0 ; i < 5 ; i++)
{
- sprintf(widgetName, "save%d", i + 1);
- strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]);
+ snprintf(widgetName, sizeof widgetName, "save%d", i + 1);
+ strlcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label);
if ((strstr(engine.saveSlot[i], _("Empty"))) || (strstr(engine.saveSlot[i], _("Corrupt"))))
{
engine.enableWidget(widgetName, false);
}
- sprintf(widgetName, "slot%d", i + 1);
- strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]);
+ snprintf(widgetName, sizeof widgetName, "slot%d", i + 1);
+ strlcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label);
}
}
setupSaveWidgets();
Widget *widget = engine.getWidgetByName("labelManual");
- strcpy(widget->label, GAMEPLAYMANUAL);
+ strlcpy(widget->label, GAMEPLAYMANUAL, sizeof widget->label);
showTitleWidgets();
}
graphics.setFontSize(3);
SDL_Surface *presents = graphics.quickSprite("Presents", graphics.getString(_("Presents"), true));
- SDL_Surface *sdl = graphics.quickSprite("SDL", graphics.getString(_("An SDL Game"), true));
+ SDL_Surface *sdl = graphics.quickSprite("SDL", graphics.getString(_("An SDL2 Game"), true));
graphics.setFontSize(2);
SDL_Surface *subTitle = graphics.quickSprite("SubTitle", graphics.getString(_("Blob Wars : Episode I"), true));
graphics.setFontSize(0);
- SDL_Surface *copyright = graphics.quickSprite("Copyright", graphics.getString(_("Copyright (C) 2004, 2005 Parallel Realities"), true));
+ SDL_Surface *copyright[] = {
+ graphics.quickSprite("Copyright1", graphics.getString(_("Copyright (C) 2011-2015 Perpendicular Dimensions"), true)),
+ graphics.quickSprite("Copyright2", graphics.getString(_("Copyright (C) 2004-2011 Parallel Realities"), true)),
+ NULL,
+ };
char v[50];
#define STRINGIFY_VALUE(x) STRINGIFY(x)
#define STRINGIFY(x) #x
- sprintf(v, _("Version %s"), STRINGIFY_VALUE(VERSION));
+ snprintf(v, sizeof v, _("Version %s"), STRINGIFY_VALUE(VERSION));
SDL_Surface *version = graphics.quickSprite("Version", graphics.getString(v, true));
- SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, 0);
+ SDL_SetAlpha(title, 0);
- audio.loadMusic("music/helmet-shake.mod");
+ audio.loadMusic("music/title");
graphics.loadBackground("gfx/main/CircuitBoard.jpg");
- SDL_SetAlpha(graphics.background, SDL_SRCALPHA|SDL_RLEACCEL, 0);
+ SDL_SetAlpha(graphics.background, 0);
int startNewGame, options, quit, help, easy, normal, hard, extreme, back, practice;
int load, cont, save[5], slot[6];
while (true)
{
+ unsigned int ticks = SDL_GetTicks();
graphics.updateScreen();
engine.getInput();
if (!allFadedOn)
{
- if ((SDL_GetTicks() >= now + 2000) && (SDL_GetTicks() <= now + 10000))
+ if ((ticks >= now + 2000) && (ticks <= now + 10000))
{
graphics.blit(prlogo, 320, 240, graphics.screen, true);
}
- else if ((SDL_GetTicks() >= now + 13000) && (SDL_GetTicks() <= now + 19000))
+ else if ((ticks >= now + 13000) && (ticks <= now + 19000))
{
graphics.blit(presents, 320, 240, graphics.screen, true);
}
- else if ((SDL_GetTicks() >= now + 22000) && (SDL_GetTicks() <= now + 27000))
+ else if ((ticks >= now + 22000) && (ticks <= now + 27000))
{
graphics.blit(sdl, 320, 240, graphics.screen, true);
}
engine.clearInput();
backAlpha = 255;
titleAlpha = 255;
- SDL_SetAlpha(graphics.background, SDL_SRCALPHA|SDL_RLEACCEL, (int)backAlpha);
- SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, (int)titleAlpha);
+ SDL_SetAlpha(graphics.background, backAlpha);
+ SDL_SetAlpha(title, titleAlpha);
}
}
- if ((SDL_GetTicks() >= now + 4000) || (allFadedOn))
+ if ((ticks >= now + 4000) || (allFadedOn))
{
if (backAlpha < 255)
{
backAlpha++;
- SDL_SetAlpha(graphics.background, SDL_SRCALPHA|SDL_RLEACCEL, (int)backAlpha);
+ SDL_SetAlpha(graphics.background, backAlpha);
}
}
- if ((SDL_GetTicks() >= now + 29000) || (allFadedOn))
+ if ((ticks >= now + 29000) || (allFadedOn))
{
if (titleAlpha < 255)
{
titleAlpha++;
- SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, (int)titleAlpha);
+ SDL_SetAlpha(title, titleAlpha);
}
else
{
graphics.blit(subTitle, 320, 180, graphics.screen, true);
- graphics.blit(copyright, 10, 460, graphics.screen, false);
+ for (int i = 0; copyright[i]; i++)
+ graphics.blit(copyright[i], 10, 460 - i * 18, graphics.screen, false);
graphics.blit(version, (630 - version->w), 460, graphics.screen, false);
allFadedOn = true;
}
+
+ doMusicInfo(ticks - (now + 39000));
}
Math::wrapFloat(&(offX -= 0.25), -graphics.background->w, 0);
if (save[3]) {load = 4; break;}
if (save[4]) {load = 5; break;}
- if (engine.keyState[SDLK_ESCAPE])
+ if (engine.keyState[SDL_SCANCODE_ESCAPE])
{
audio.playMenuSound(2);
back = 1;
}
engine.delay(frameLimit);
- frameLimit = SDL_GetTicks() + 16;
+ frameLimit = SDL_GetTicks() + 16;
}
engine.deleteWidgets();
if (quit)
{
- if (engine.useAudio)
- {
- SDL_Delay(1000);
- }
+ doQuit();
exit(0);
}
int i = 0;
int numberOfCredits = 0;
int pos1 = 0, pos2 = 0, size = 0;
- float *y;
+ float *y, deviceY = 0;
SDL_Surface *backdrop = graphics.quickSprite("CreditsBackGround", graphics.loadImage("gfx/main/creditsBack.png"));
y[i] = pos1;
+ if (pos2 == 220)
+ deviceY = pos1 - 50;
+
graphics.setFontSize(size);
credit[i] = graphics.quickSprite("credit", graphics.getString(string, true));
}
SDL_Surface *device = graphics.quickSprite("credit", graphics.loadImage("gfx/main/creditsDevice.png"));
- float deviceY = y[numberOfCredits - 7] - 50;
- audio.loadMusic("music/autumnsDawning.s3m");
+ if (!deviceY)
+ deviceY = y[numberOfCredits - 7] - 50;
+
+ audio.loadMusic("music/credits");
audio.playMusic();
engine.resetTimeDifference();
+ Uint32 now = SDL_GetTicks();
while (y[numberOfCredits - 1] > 350)
{
+ unsigned int frameLimit = SDL_GetTicks() + 16;
+
graphics.updateScreen();
engine.getInput();
config.populate();
SDL_FillRect(graphics.screen, NULL, graphics.black);
graphics.blit(backdrop, 0, 365, graphics.screen, false);
+
+ float speed = 0.25;
+
+ if (engine.keyState[SDL_SCANCODE_DOWN] || engine.joyY > 25000)
+ speed = 1.0;
+ else if (engine.keyState[SDL_SCANCODE_UP] || engine.joyY < -25000)
+ speed = -1.0;
- deviceY -= (0.25 * engine.getTimeDifference());
+ deviceY -= (speed* engine.getTimeDifference());
if ((deviceY > 10) && (deviceY < 470))
{
for (i = 0 ; i < numberOfCredits ; i++)
{
- y[i] -= (0.25 * engine.getTimeDifference());
+ y[i] -= (speed * engine.getTimeDifference());
if ((y[i] > 10) && (y[i] < 470))
{
graphics.drawRect(0, 0, 640, 30, graphics.black, graphics.screen);
}
- SDL_Delay(16);
+ doMusicInfo(SDL_GetTicks() - (now + 10000));
+
+ engine.delay(frameLimit);
}
graphics.delay(12000);
delete[] y;
delete[] credit;
}
+
+/**
+* Shows the exit screen, mentioning the sequel and the book by Stephen Sweeney
+*/
+void doQuit()
+{
+ SDL_FillRect(graphics.screen, NULL, graphics.black);
+ SDL_Surface *sequel = graphics.loadImage("gfx/main/sequel.png");
+ SDL_Surface *book = graphics.loadImage("gfx/main/book.png");
+
+ graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
+ graphics.setFontSize(1);
+ graphics.drawString(_("If you like Blob Wars: Metal Blob Solid, you might also like:"), 320, 20, true, graphics.screen);
+ graphics.blit(sequel, 160, 200, graphics.screen, true);
+ graphics.blit(book, 480, 200, graphics.screen, true);
+ graphics.setFontSize(0);
+ graphics.drawString("http://blobandconquer.sf.net", 160, 380, true, graphics.screen);
+ graphics.drawString("http://www.battleforthesolarsystem.com", 480, 380, true, graphics.screen);
+ graphics.setFontSize(3);
+ graphics.drawString(_("Thank you for playing Blob Wars!"), 320, 430, true, graphics.screen);
+ graphics.setFontSize(0);
+ graphics.drawString(_("Press Space to Exit."), 320, 460, true, graphics.screen);
+
+ graphics.updateScreen();
+
+ do {
+ SDL_Delay(16);
+ engine.getInput();
+ } while(!engine.userAccepts());
+}