summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile18
-rw-r--r--htpstate.cpp12
-rw-r--r--includes.h1
-rw-r--r--resources.h20
-rw-r--r--titlestate.cpp8
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 @@
1OBJS = mazeoflife.o titlestate.o htpstate.o gamestate.o 1SOURCES = mazeoflife.cpp titlestate.cpp htpstate.cpp gamestate.cpp
2OBJS = $(SOURCES:.cpp=.cpp.o)
3IMAGES = title.bmp pointer.bmp htp1.bmp htp2.bmp
4CIMAGES = $(IMAGES:.bmp=.bmp.o)
2CC = g++ 5CC = g++
3CFLAGS = `pkg-config sdl --cflags` 6CFLAGS = `pkg-config sdl --cflags`
4LIBS = `pkg-config sdl --libs` 7LIBS = `pkg-config sdl --libs`
5 8
6mazeoflife: $(OBJS) 9mazeoflife: $(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
18include $(OBJS:.o=.d) 21%.bmp.o: %.bmp
22 objcopy --input binary --output elf32-i386 -B i386 $< $@
23
24include $(OBJS:.cpp.o=.d)
19 25
20clean: 26clean:
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
3HowToPlayState::HowToPlayState() 3HowToPlayState::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
5extern int* _binary_title_bmp_start;
6extern int* _binary_title_bmp_size;
7
8// pointer.bmp
9extern int* _binary_pointer_bmp_start;
10extern int* _binary_pointer_bmp_size;
11
12// htp1.bmp
13extern int* _binary_htp1_bmp_start;
14extern int* _binary_htp1_bmp_size;
15
16// htp2.bmp
17extern int* _binary_htp2_bmp_start;
18extern 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
3TitleState::TitleState() 3TitleState::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);