diff options
-rw-r--r-- | resources/htp1.bmp | bin | 921738 -> 921656 bytes | |||
-rw-r--r-- | resources/htp2.bmp | bin | 921738 -> 921656 bytes | |||
-rw-r--r-- | titlestate.cpp | 92 | ||||
-rw-r--r-- | titlestate.h | 10 |
4 files changed, 100 insertions, 2 deletions
diff --git a/resources/htp1.bmp b/resources/htp1.bmp index df06101..572c58b 100644 --- a/resources/htp1.bmp +++ b/resources/htp1.bmp | |||
Binary files differ | |||
diff --git a/resources/htp2.bmp b/resources/htp2.bmp index 5dcb4c4..eb00118 100644 --- a/resources/htp2.bmp +++ b/resources/htp2.bmp | |||
Binary files differ | |||
diff --git a/titlestate.cpp b/titlestate.cpp index 177a4c8..bf966ea 100644 --- a/titlestate.cpp +++ b/titlestate.cpp | |||
@@ -35,7 +35,7 @@ State* TitleState::operator() (SDL_Renderer* renderer) | |||
35 | switch (selection) | 35 | switch (selection) |
36 | { | 36 | { |
37 | case 0: return new GameState(); | 37 | case 0: return new GameState(); |
38 | //case 1: return new HowToPlayState(); | 38 | case 1: return new HowToPlayState(); |
39 | case 2: return new ChooseHighscoreListState(); | 39 | case 2: return new ChooseHighscoreListState(); |
40 | case 3: return NULL; | 40 | case 3: return NULL; |
41 | } | 41 | } |
@@ -43,4 +43,92 @@ State* TitleState::operator() (SDL_Renderer* renderer) | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } \ No newline at end of file | 46 | } |
47 | |||
48 | State* HowToPlayState::operator() (SDL_Renderer* renderer) | ||
49 | { | ||
50 | SDL_Texture* background = loadImage(renderer, "resources/htp1.bmp"); | ||
51 | SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); | ||
52 | int selection = 0; | ||
53 | SDL_Event e; | ||
54 | |||
55 | for (;;) | ||
56 | { | ||
57 | SDL_RenderClear(renderer); | ||
58 | SDL_RenderCopy(renderer, background, NULL, NULL); | ||
59 | applyTexture(renderer, pointer, selection==0?74:216, 430); | ||
60 | SDL_RenderPresent(renderer); | ||
61 | |||
62 | while (SDL_PollEvent(&e)) | ||
63 | { | ||
64 | if (e.type == SDL_QUIT) | ||
65 | { | ||
66 | return NULL; | ||
67 | } else if (e.type == SDL_KEYDOWN) | ||
68 | { | ||
69 | if ((e.key.keysym.sym == SDLK_LEFT) && (selection != 0)) | ||
70 | { | ||
71 | selection--; | ||
72 | } else if ((e.key.keysym.sym == SDLK_RIGHT) && (selection != 1)) | ||
73 | { | ||
74 | selection++; | ||
75 | } else if (e.key.keysym.sym == SDLK_RETURN) | ||
76 | { | ||
77 | switch (selection) | ||
78 | { | ||
79 | case 0: | ||
80 | return new HowToPlayPageTwoState(); | ||
81 | |||
82 | break; | ||
83 | case 1: | ||
84 | return new TitleState(); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | |||
92 | State* HowToPlayPageTwoState::operator() (SDL_Renderer* renderer) | ||
93 | { | ||
94 | SDL_Texture* background = loadImage(renderer, "resources/htp2.bmp"); | ||
95 | SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); | ||
96 | int selection = 0; | ||
97 | SDL_Event e; | ||
98 | |||
99 | for (;;) | ||
100 | { | ||
101 | SDL_RenderClear(renderer); | ||
102 | SDL_RenderCopy(renderer, background, NULL, NULL); | ||
103 | applyTexture(renderer, pointer, selection==0?45:238, 430); | ||
104 | SDL_RenderPresent(renderer); | ||
105 | |||
106 | while (SDL_PollEvent(&e)) | ||
107 | { | ||
108 | if (e.type == SDL_QUIT) | ||
109 | { | ||
110 | return NULL; | ||
111 | } else if (e.type == SDL_KEYDOWN) | ||
112 | { | ||
113 | if ((e.key.keysym.sym == SDLK_LEFT) && (selection != 0)) | ||
114 | { | ||
115 | selection--; | ||
116 | } else if ((e.key.keysym.sym == SDLK_RIGHT) && (selection != 1)) | ||
117 | { | ||
118 | selection++; | ||
119 | } else if (e.key.keysym.sym == SDLK_RETURN) | ||
120 | { | ||
121 | switch (selection) | ||
122 | { | ||
123 | case 0: | ||
124 | return new HowToPlayState(); | ||
125 | |||
126 | break; | ||
127 | case 1: | ||
128 | return new TitleState(); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/titlestate.h b/titlestate.h index 11d16d7..c7beb91 100644 --- a/titlestate.h +++ b/titlestate.h | |||
@@ -9,4 +9,14 @@ class TitleState : public State { | |||
9 | State* operator() (SDL_Renderer* renderer); | 9 | State* operator() (SDL_Renderer* renderer); |
10 | }; | 10 | }; |
11 | 11 | ||
12 | class HowToPlayState : public State { | ||
13 | public: | ||
14 | State* operator() (SDL_Renderer* renderer); | ||
15 | }; | ||
16 | |||
17 | class HowToPlayPageTwoState : public State { | ||
18 | public: | ||
19 | State* operator() (SDL_Renderer* renderer); | ||
20 | }; | ||
21 | |||
12 | #endif \ No newline at end of file | 22 | #endif \ No newline at end of file |