diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | htp1.bmp | bin | 0 -> 921738 bytes | |||
-rw-r--r-- | htp2.bmp | bin | 0 -> 921738 bytes | |||
-rw-r--r-- | htpstate.cpp | 56 | ||||
-rw-r--r-- | htpstate.h | 18 | ||||
-rw-r--r-- | includes.h | 1 | ||||
-rw-r--r-- | titlestate.cpp | 4 |
7 files changed, 79 insertions, 2 deletions
diff --git a/Makefile b/Makefile index b79fe63..7f503ba 100644 --- a/Makefile +++ b/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | OBJS = mazeoflife.o titlestate.o gamestate.o | 1 | OBJS = mazeoflife.o titlestate.o htpstate.o gamestate.o |
2 | CC = g++ | 2 | CC = g++ |
3 | CFLAGS = `pkg-config sdl --cflags` | 3 | CFLAGS = `pkg-config sdl --cflags` |
4 | LIBS = `pkg-config sdl --libs` | 4 | LIBS = `pkg-config sdl --libs` |
diff --git a/htp1.bmp b/htp1.bmp new file mode 100644 index 0000000..df06101 --- /dev/null +++ b/htp1.bmp | |||
Binary files differ | |||
diff --git a/htp2.bmp b/htp2.bmp new file mode 100644 index 0000000..5dcb4c4 --- /dev/null +++ b/htp2.bmp | |||
Binary files differ | |||
diff --git a/htpstate.cpp b/htpstate.cpp new file mode 100644 index 0000000..273392e --- /dev/null +++ b/htpstate.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | HowToPlayState::HowToPlayState() | ||
4 | { | ||
5 | background1 = SDL_LoadBMP("htp1.bmp"); | ||
6 | background2 = SDL_LoadBMP("htp2.bmp"); | ||
7 | pointer = SDL_LoadBMP("pointer.bmp"); | ||
8 | secondPage = false; | ||
9 | selection = 0; | ||
10 | } | ||
11 | |||
12 | void HowToPlayState::input(SDLKey key) | ||
13 | { | ||
14 | if ((key == SDLK_LEFT) && (selection != 0)) | ||
15 | { | ||
16 | selection--; | ||
17 | } else if ((key == SDLK_RIGHT) && (selection != 1)) | ||
18 | { | ||
19 | selection++; | ||
20 | } else if (key == SDLK_RETURN) | ||
21 | { | ||
22 | switch (selection) | ||
23 | { | ||
24 | case 0: | ||
25 | secondPage = !secondPage; | ||
26 | |||
27 | break; | ||
28 | case 1: | ||
29 | changeState(new TitleState()); | ||
30 | |||
31 | break; | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | |||
36 | void HowToPlayState::render(SDL_Surface* screen) | ||
37 | { | ||
38 | SDL_Rect pSpace; | ||
39 | |||
40 | if (!secondPage) | ||
41 | { | ||
42 | SDL_BlitSurface(background1, NULL, screen, NULL); | ||
43 | |||
44 | pSpace.x = (selection==0?74:216); | ||
45 | } else { | ||
46 | SDL_BlitSurface(background2, NULL, screen, NULL); | ||
47 | |||
48 | pSpace.x = (selection==0?45:238); | ||
49 | } | ||
50 | |||
51 | pSpace.y = 430; | ||
52 | pSpace.w = screen->w; | ||
53 | pSpace.h = screen->h; | ||
54 | |||
55 | SDL_BlitSurface(pointer, NULL, screen, &pSpace); | ||
56 | } | ||
diff --git a/htpstate.h b/htpstate.h new file mode 100644 index 0000000..2639d1a --- /dev/null +++ b/htpstate.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef HTPSTATE_H | ||
2 | #define HTPSTATE_H | ||
3 | |||
4 | class HowToPlayState : public State { | ||
5 | public: | ||
6 | HowToPlayState(); | ||
7 | void input(SDLKey key); | ||
8 | void render(SDL_Surface* screen); | ||
9 | |||
10 | private: | ||
11 | SDL_Surface* background1; | ||
12 | SDL_Surface* background2; | ||
13 | SDL_Surface* pointer; | ||
14 | bool secondPage; | ||
15 | int selection; | ||
16 | }; | ||
17 | |||
18 | #endif | ||
diff --git a/includes.h b/includes.h index d066b8e..fa6abeb 100644 --- a/includes.h +++ b/includes.h | |||
@@ -5,4 +5,5 @@ | |||
5 | #include "state.h" | 5 | #include "state.h" |
6 | #include "mazeoflife.h" | 6 | #include "mazeoflife.h" |
7 | #include "titlestate.h" | 7 | #include "titlestate.h" |
8 | #include "htpstate.h" | ||
8 | #include "gamestate.h" | 9 | #include "gamestate.h" |
diff --git a/titlestate.cpp b/titlestate.cpp index ee6a2b5..144148a 100644 --- a/titlestate.cpp +++ b/titlestate.cpp | |||
@@ -23,7 +23,9 @@ void TitleState::input(SDLKey key) | |||
23 | changeState(new GameState()); | 23 | changeState(new GameState()); |
24 | 24 | ||
25 | break; | 25 | break; |
26 | case 1: // Add How To Play | 26 | case 1: |
27 | changeState(new HowToPlayState()); | ||
28 | |||
27 | break; | 29 | break; |
28 | case 2: // Add choose highscore list | 30 | case 2: // Add choose highscore list |
29 | break; | 31 | break; |