More reorganization.
Added colors.cpp and colors.h to contain some of the stuff in graphics.
This commit is contained in:
parent
14dceac750
commit
1c833b1818
2
Makefile
2
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
|
||||
|
|
|
@ -103,7 +103,7 @@ int main(int argc, char **argv)
|
|||
initVars();
|
||||
alien_defs_init();
|
||||
|
||||
setColorIndexes();
|
||||
colors_init();
|
||||
|
||||
showStory();
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "bullet.h"
|
||||
#include "cargo.h"
|
||||
#include "collectable.h"
|
||||
#include "colors.h"
|
||||
#include "engine.h"
|
||||
#include "explosion.h"
|
||||
#include "game.h"
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#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);
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -22,19 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue