diff --git a/Makefile b/Makefile
index 0a514db..d52b8a8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CXXFLAGS ?= -O2 -Wall -g
CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer`
LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer`
-OBJS = alien.o audio.o bullet.o cargo.o collectable.o engine.o explosion.o game.o graphics.o init.o intermission.o loadSave.o messages.o misc.o missions.o player.o resources.o script.o ship.o shop.o Starfighter.o title.o weapons.o
+OBJS = alien.o audio.o bullet.o cargo.o collectable.o colors.o engine.o explosion.o game.o graphics.o init.o intermission.o loadSave.o messages.o misc.o missions.o player.o resources.o script.o ship.o shop.o Starfighter.o title.o weapons.o
VERSION = 1.4
PROG = starfighter
diff --git a/src/Starfighter.cpp b/src/Starfighter.cpp
index ed91b8b..d9880ed 100644
--- a/src/Starfighter.cpp
+++ b/src/Starfighter.cpp
@@ -103,7 +103,7 @@ int main(int argc, char **argv)
initVars();
alien_defs_init();
- setColorIndexes();
+ colors_init();
showStory();
diff --git a/src/Starfighter.h b/src/Starfighter.h
index dd17d87..3675207 100644
--- a/src/Starfighter.h
+++ b/src/Starfighter.h
@@ -40,6 +40,7 @@ along with this program. If not, see .
#include "bullet.h"
#include "cargo.h"
#include "collectable.h"
+#include "colors.h"
#include "engine.h"
#include "explosion.h"
#include "game.h"
diff --git a/src/colors.cpp b/src/colors.cpp
new file mode 100644
index 0000000..1999173
--- /dev/null
+++ b/src/colors.cpp
@@ -0,0 +1,62 @@
+/*
+Copyright (C) 2003 Parallel Realities
+Copyright (C) 2011, 2012, 2013 Guus Sliepen
+Copyright (C) 2015 Julian Marchant
+
+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 3
+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, see .
+*/
+
+#include
+
+#include "Starfighter.h"
+
+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;
+
+/*
+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 colors_init()
+{
+ 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);
+}
diff --git a/src/colors.h b/src/colors.h
new file mode 100644
index 0000000..d6d76fc
--- /dev/null
+++ b/src/colors.h
@@ -0,0 +1,39 @@
+/*
+Copyright (C) 2003 Parallel Realities
+Copyright (C) 2011 Guus Sliepen
+Copyright (C) 2015 Julian Marchant
+
+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 3
+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, see .
+*/
+
+#ifndef COLORS_H
+#define COLORS_H
+
+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;
+
+void colors_init();
+
+#endif
diff --git a/src/graphics.cpp b/src/graphics.cpp
index b25bf48..79de564 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -26,19 +26,6 @@ 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_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
@@ -341,32 +328,6 @@ int drawString(const char *in, int x, int y, int fontColor)
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
*/
diff --git a/src/graphics.h b/src/graphics.h
index 3f4e71f..8353951 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -22,19 +22,6 @@ along with this program. If not, see .
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_Window *window;
extern SDL_Renderer *renderer;
extern SDL_Texture *texture;
@@ -64,7 +51,6 @@ 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();