diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-06-20 13:56:20 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-06-20 13:56:20 -0400 |
commit | af121493c84c116b06f2572846535293a827d089 (patch) | |
tree | dc04a8e44a933c42dfec19303051989f8132d15a | |
parent | 306c130cc425e96d2088f68551c4bb77dad412d3 (diff) | |
download | mazeoflife-af121493c84c116b06f2572846535293a827d089.tar.gz mazeoflife-af121493c84c116b06f2572846535293a827d089.tar.bz2 mazeoflife-af121493c84c116b06f2572846535293a827d089.zip |
Embedded images into executable file
-rw-r--r-- | Makefile | 18 | ||||
-rw-r--r-- | htpstate.cpp | 12 | ||||
-rw-r--r-- | includes.h | 1 | ||||
-rw-r--r-- | resources.h | 20 | ||||
-rw-r--r-- | titlestate.cpp | 8 |
5 files changed, 48 insertions, 11 deletions
diff --git a/Makefile b/Makefile index 7f503ba..a4fe8ff 100644 --- a/Makefile +++ b/Makefile | |||
@@ -1,12 +1,15 @@ | |||
1 | OBJS = mazeoflife.o titlestate.o htpstate.o gamestate.o | 1 | SOURCES = mazeoflife.cpp titlestate.cpp htpstate.cpp gamestate.cpp |
2 | OBJS = $(SOURCES:.cpp=.cpp.o) | ||
3 | IMAGES = title.bmp pointer.bmp htp1.bmp htp2.bmp | ||
4 | CIMAGES = $(IMAGES:.bmp=.bmp.o) | ||
2 | CC = g++ | 5 | CC = g++ |
3 | CFLAGS = `pkg-config sdl --cflags` | 6 | CFLAGS = `pkg-config sdl --cflags` |
4 | LIBS = `pkg-config sdl --libs` | 7 | LIBS = `pkg-config sdl --libs` |
5 | 8 | ||
6 | mazeoflife: $(OBJS) | 9 | mazeoflife: $(OBJS) $(CIMAGES) |
7 | $(CC) $(OBJS) $(LIBS) -o mazeoflife | 10 | $(CC) $(OBJS) $(CIMAGES) $(LIBS) -o mazeoflife |
8 | 11 | ||
9 | %.o: %.cpp | 12 | %.cpp.o: %.cpp |
10 | $(CC) -c $< $(CFLAGS) -o $@ | 13 | $(CC) -c $< $(CFLAGS) -o $@ |
11 | 14 | ||
12 | %.d: %.cpp | 15 | %.d: %.cpp |
@@ -15,7 +18,10 @@ mazeoflife: $(OBJS) | |||
15 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | 18 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ |
16 | rm -f $@.$$$$ | 19 | rm -f $@.$$$$ |
17 | 20 | ||
18 | include $(OBJS:.o=.d) | 21 | %.bmp.o: %.bmp |
22 | objcopy --input binary --output elf32-i386 -B i386 $< $@ | ||
23 | |||
24 | include $(OBJS:.cpp.o=.d) | ||
19 | 25 | ||
20 | clean: | 26 | clean: |
21 | rm -rdfv $(OBJS) $(OBJS:.o=.d) mazeoflife | 27 | rm -rdfv $(OBJS) $(OBJS:.cpp.o=.d) $(CIMAGES) mazeoflife |
diff --git a/htpstate.cpp b/htpstate.cpp index ad830da..30d58a2 100644 --- a/htpstate.cpp +++ b/htpstate.cpp | |||
@@ -2,9 +2,15 @@ | |||
2 | 2 | ||
3 | HowToPlayState::HowToPlayState() | 3 | HowToPlayState::HowToPlayState() |
4 | { | 4 | { |
5 | background1 = SDL_LoadBMP("htp1.bmp"); | 5 | SDL_RWops *rw = SDL_RWFromMem(&_binary_htp1_bmp_start, (int) &_binary_htp1_bmp_size); |
6 | background2 = SDL_LoadBMP("htp2.bmp"); | 6 | background1 = SDL_LoadBMP_RW(rw, 1); |
7 | pointer = SDL_LoadBMP("pointer.bmp"); | 7 | |
8 | rw = SDL_RWFromMem(&_binary_htp2_bmp_start, (int) &_binary_htp2_bmp_size); | ||
9 | background2 = SDL_LoadBMP_RW(rw, 1); | ||
10 | |||
11 | rw = SDL_RWFromMem(&_binary_pointer_bmp_start, (int) &_binary_pointer_bmp_size); | ||
12 | pointer = SDL_LoadBMP_RW(rw, 1); | ||
13 | |||
8 | secondPage = false; | 14 | secondPage = false; |
9 | selection = 0; | 15 | selection = 0; |
10 | 16 | ||
diff --git a/includes.h b/includes.h index fa6abeb..5b0895d 100644 --- a/includes.h +++ b/includes.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <string> | 4 | #include <string> |
5 | #include "state.h" | 5 | #include "state.h" |
6 | #include "mazeoflife.h" | 6 | #include "mazeoflife.h" |
7 | #include "resources.h" | ||
7 | #include "titlestate.h" | 8 | #include "titlestate.h" |
8 | #include "htpstate.h" | 9 | #include "htpstate.h" |
9 | #include "gamestate.h" | 10 | #include "gamestate.h" |
diff --git a/resources.h b/resources.h new file mode 100644 index 0000000..4e01a90 --- /dev/null +++ b/resources.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef RESOURCES_H | ||
2 | #define RESOURCES_H | ||
3 | |||
4 | // title.bmp | ||
5 | extern int* _binary_title_bmp_start; | ||
6 | extern int* _binary_title_bmp_size; | ||
7 | |||
8 | // pointer.bmp | ||
9 | extern int* _binary_pointer_bmp_start; | ||
10 | extern int* _binary_pointer_bmp_size; | ||
11 | |||
12 | // htp1.bmp | ||
13 | extern int* _binary_htp1_bmp_start; | ||
14 | extern int* _binary_htp1_bmp_size; | ||
15 | |||
16 | // htp2.bmp | ||
17 | extern int* _binary_htp2_bmp_start; | ||
18 | extern int* _binary_htp2_bmp_size; | ||
19 | |||
20 | #endif | ||
diff --git a/titlestate.cpp b/titlestate.cpp index 425e4ca..c011480 100644 --- a/titlestate.cpp +++ b/titlestate.cpp | |||
@@ -2,8 +2,12 @@ | |||
2 | 2 | ||
3 | TitleState::TitleState() | 3 | TitleState::TitleState() |
4 | { | 4 | { |
5 | background = SDL_LoadBMP("title.bmp"); | 5 | SDL_RWops *rw = SDL_RWFromMem(&_binary_title_bmp_start, (int) &_binary_title_bmp_size); |
6 | pointer = SDL_LoadBMP("pointer.bmp"); | 6 | background = SDL_LoadBMP_RW(rw, 1); |
7 | |||
8 | rw = SDL_RWFromMem(&_binary_pointer_bmp_start, (int) &_binary_pointer_bmp_size); | ||
9 | pointer = SDL_LoadBMP_RW(rw, 1); | ||
10 | |||
7 | selection = 0; | 11 | selection = 0; |
8 | 12 | ||
9 | SDL_WM_SetCaption("Maze Of Life", NULL); | 13 | SDL_WM_SetCaption("Maze Of Life", NULL); |