diff options
-rw-r--r-- | .hgignore | 1 | ||||
-rw-r--r-- | Makefile | 53 | ||||
-rw-r--r-- | htpstate.cpp | 11 | ||||
-rw-r--r-- | resources.h | 25 | ||||
-rw-r--r-- | titlestate.cpp | 7 |
5 files changed, 50 insertions, 47 deletions
diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.hgignore | |||
@@ -0,0 +1 @@ | |||
build | |||
diff --git a/Makefile b/Makefile index a4fe8ff..e7429a5 100644 --- a/Makefile +++ b/Makefile | |||
@@ -1,27 +1,40 @@ | |||
1 | SOURCES = mazeoflife.cpp titlestate.cpp htpstate.cpp gamestate.cpp | 1 | PROJECT = mazeoflife |
2 | OBJS = $(SOURCES:.cpp=.cpp.o) | 2 | LTARGET = build/$(PROJECT) |
3 | IMAGES = title.bmp pointer.bmp htp1.bmp htp2.bmp | 3 | WTARGET = build/$(PROJECT).exe |
4 | CIMAGES = $(IMAGES:.bmp=.bmp.o) | ||
5 | CC = g++ | 4 | CC = g++ |
6 | CFLAGS = `pkg-config sdl --cflags` | 5 | WINCC = i586-mingw32msvc-g++ |
7 | LIBS = `pkg-config sdl --libs` | 6 | FILES = $(addprefix build/,$(wildcard *.cpp)) |
7 | MODULES = $(patsubst %.cpp,%,$(FILES)) | ||
8 | SOURCES = $(addsuffix .o,$(MODULES)) | ||
9 | WINSRC = $(addsuffix win,$(SOURCES)) | ||
10 | IMAGES = $(wildcard *.bmp) | ||
11 | CIMAGES = $(addprefix build/,$(IMAGES:.bmp=.bmp.o)) | ||
12 | LINCCFL = `sdl-config --cflags` | ||
13 | LINLDFL = `sdl-config --libs` | ||
14 | WINCCFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --cflags` -DWINDOWS | ||
15 | WINLDFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --libs` | ||
8 | 16 | ||
9 | mazeoflife: $(OBJS) $(CIMAGES) | 17 | all: init $(LTARGET) $(WTARGET) |
10 | $(CC) $(OBJS) $(CIMAGES) $(LIBS) -o mazeoflife | 18 | linux: init $(LTARGET) |
19 | windows: init $(WTARGET) | ||
11 | 20 | ||
12 | %.cpp.o: %.cpp | 21 | init: |
13 | $(CC) -c $< $(CFLAGS) -o $@ | 22 | mkdir -p build |
14 | 23 | ||
15 | %.d: %.cpp | 24 | clean: |
16 | @set -e; rm -f $@; \ | 25 | rm -rdfv build |
17 | $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ | ||
18 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | ||
19 | rm -f $@.$$$$ | ||
20 | 26 | ||
21 | %.bmp.o: %.bmp | 27 | $(LTARGET): $(SOURCES) $(CIMAGES) |
22 | objcopy --input binary --output elf32-i386 -B i386 $< $@ | 28 | $(CC) $(SOURCES) $(CIMAGES) -o $(LTARGET) $(LINLDFL) |
23 | 29 | ||
24 | include $(OBJS:.cpp.o=.d) | 30 | $(SOURCES): build/%.o: %.cpp |
31 | $(CC) -c $? -o $@ $(LINCCFL) | ||
25 | 32 | ||
26 | clean: | 33 | $(WTARGET): $(WINSRC) $(CIMAGES) |
27 | rm -rdfv $(OBJS) $(OBJS:.cpp.o=.d) $(CIMAGES) mazeoflife | 34 | $(WINCC) $(WINSRC) $(CIMAGES) -o $(WTARGET) $(WINLDFL) |
35 | |||
36 | $(WINSRC): build/%.owin: %.cpp | ||
37 | $(WINCC) -c $? -o $@ $(WINCCFL) | ||
38 | |||
39 | $(CIMAGES): build/%.bmp.o: %.bmp | ||
40 | objcopy --input binary --output elf32-i386 -B i386 $? $@ | ||
diff --git a/htpstate.cpp b/htpstate.cpp index 30d58a2..8de884f 100644 --- a/htpstate.cpp +++ b/htpstate.cpp | |||
@@ -2,14 +2,9 @@ | |||
2 | 2 | ||
3 | HowToPlayState::HowToPlayState() | 3 | HowToPlayState::HowToPlayState() |
4 | { | 4 | { |
5 | SDL_RWops *rw = SDL_RWFromMem(&_binary_htp1_bmp_start, (int) &_binary_htp1_bmp_size); | 5 | LOADIMAGE(background1,htp1) |
6 | background1 = SDL_LoadBMP_RW(rw, 1); | 6 | LOADIMAGE(background2,htp2) |
7 | 7 | LOADIMAGE(pointer,pointer) | |
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 | ||
14 | secondPage = false; | 9 | secondPage = false; |
15 | selection = 0; | 10 | selection = 0; |
diff --git a/resources.h b/resources.h index 4e01a90..457fbec 100644 --- a/resources.h +++ b/resources.h | |||
@@ -1,20 +1,17 @@ | |||
1 | #ifndef RESOURCES_H | 1 | #ifndef RESOURCES_H |
2 | #define RESOURCES_H | 2 | #define RESOURCES_H |
3 | 3 | ||
4 | // title.bmp | 4 | #ifdef WINDOWS |
5 | extern int* _binary_title_bmp_start; | 5 | #define LOADIMAGE(var,title) SDL_RWops * title ## _rw = SDL_RWFromMem(&binary_ ## title ## _bmp_start, (int) &binary_ ## title ## _bmp_size); var = SDL_LoadBMP_RW( title ## _rw, 1); |
6 | extern int* _binary_title_bmp_size; | 6 | #define DEFIMAGE(title) extern int* binary_ ## title ## _bmp_start; extern int* binary_ ## title ## _bmp_size; |
7 | 7 | #else | |
8 | // pointer.bmp | 8 | #define LOADIMAGE(var,title) SDL_RWops * title ## _rw = SDL_RWFromMem(&_binary_ ## title ## _bmp_start, (int) &_binary_ ## title ## _bmp_size); var = SDL_LoadBMP_RW( title ## _rw, 1); |
9 | extern int* _binary_pointer_bmp_start; | 9 | #define DEFIMAGE(title) extern int* _binary_ ## title ## _bmp_start; extern int* _binary_ ## title ## _bmp_size; |
10 | extern int* _binary_pointer_bmp_size; | 10 | #endif |
11 | |||
12 | // htp1.bmp | ||
13 | extern int* _binary_htp1_bmp_start; | ||
14 | extern int* _binary_htp1_bmp_size; | ||
15 | 11 | ||
16 | // htp2.bmp | 12 | DEFIMAGE(title) |
17 | extern int* _binary_htp2_bmp_start; | 13 | DEFIMAGE(pointer) |
18 | extern int* _binary_htp2_bmp_size; | 14 | DEFIMAGE(htp1) |
15 | DEFIMAGE(htp2) | ||
19 | 16 | ||
20 | #endif | 17 | #endif |
diff --git a/titlestate.cpp b/titlestate.cpp index c011480..6c4401d 100644 --- a/titlestate.cpp +++ b/titlestate.cpp | |||
@@ -2,11 +2,8 @@ | |||
2 | 2 | ||
3 | TitleState::TitleState() | 3 | TitleState::TitleState() |
4 | { | 4 | { |
5 | SDL_RWops *rw = SDL_RWFromMem(&_binary_title_bmp_start, (int) &_binary_title_bmp_size); | 5 | LOADIMAGE(background,title) |
6 | background = SDL_LoadBMP_RW(rw, 1); | 6 | LOADIMAGE(pointer,pointer) |
7 | |||
8 | rw = SDL_RWFromMem(&_binary_pointer_bmp_start, (int) &_binary_pointer_bmp_size); | ||
9 | pointer = SDL_LoadBMP_RW(rw, 1); | ||
10 | 7 | ||
11 | selection = 0; | 8 | selection = 0; |
12 | 9 | ||