diff options
Diffstat (limited to 'titlestate.cpp')
-rw-r--r-- | titlestate.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/titlestate.cpp b/titlestate.cpp new file mode 100644 index 0000000..ee6a2b5 --- /dev/null +++ b/titlestate.cpp | |||
@@ -0,0 +1,47 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | TitleState::TitleState() | ||
4 | { | ||
5 | background = SDL_LoadBMP("title.bmp"); | ||
6 | pointer = SDL_LoadBMP("pointer.bmp"); | ||
7 | selection = 0; | ||
8 | } | ||
9 | |||
10 | void TitleState::input(SDLKey key) | ||
11 | { | ||
12 | if ((key == SDLK_UP) && (selection != 0)) | ||
13 | { | ||
14 | selection--; | ||
15 | } else if ((key == SDLK_DOWN) && (selection != 3)) | ||
16 | { | ||
17 | selection++; | ||
18 | } else if (key == SDLK_RETURN) | ||
19 | { | ||
20 | switch (selection) | ||
21 | { | ||
22 | case 0: | ||
23 | changeState(new GameState()); | ||
24 | |||
25 | break; | ||
26 | case 1: // Add How To Play | ||
27 | break; | ||
28 | case 2: // Add choose highscore list | ||
29 | break; | ||
30 | case 3: | ||
31 | exit(0); | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | |||
36 | void TitleState::render(SDL_Surface* screen) | ||
37 | { | ||
38 | SDL_BlitSurface(background, NULL, screen, NULL); | ||
39 | |||
40 | SDL_Rect pSpace; | ||
41 | pSpace.x = 136; | ||
42 | pSpace.y = (selection==0?316:(selection==1?350:(selection==2?381:417))); | ||
43 | pSpace.w = screen->w; | ||
44 | pSpace.h = screen->h; | ||
45 | |||
46 | SDL_BlitSurface(pointer, NULL, screen, &pSpace); | ||
47 | } | ||