diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-10-18 15:24:07 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-10-18 15:24:07 -0400 |
commit | c027f1b9cd6c9deb60931a7f9f75bb4ee130291b (patch) | |
tree | 49426a9cf3ee24434141c903b01481110b2808b6 /hslocal.cpp | |
parent | a157cd82a86390f1fcb1a2086f86af5187e85a69 (diff) | |
download | mazeoflife-c027f1b9cd6c9deb60931a7f9f75bb4ee130291b.tar.gz mazeoflife-c027f1b9cd6c9deb60931a7f9f75bb4ee130291b.tar.bz2 mazeoflife-c027f1b9cd6c9deb60931a7f9f75bb4ee130291b.zip |
Added local highscore list
You can now view and add to a local highscore list. A change to State was necessary due to how the user's name would be entered into the highscore list and thus all states have been modified. Refs #104
Diffstat (limited to 'hslocal.cpp')
-rw-r--r-- | hslocal.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/hslocal.cpp b/hslocal.cpp new file mode 100644 index 0000000..17cae1b --- /dev/null +++ b/hslocal.cpp | |||
@@ -0,0 +1,84 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | LocalHighscoreListState::LocalHighscoreListState(bool fromGame) | ||
4 | { | ||
5 | this->fromGame = fromGame; | ||
6 | |||
7 | if (fromGame) | ||
8 | { | ||
9 | LOADIMAGE(options,hlo_paartm) | ||
10 | } else { | ||
11 | LOADIMAGE(options,hlo_rtm) | ||
12 | } | ||
13 | |||
14 | LOADIMAGE(pointer,pointer) | ||
15 | |||
16 | LocalHighscoreList* lhl = new LocalHighscoreList(); | ||
17 | list = lhl->render(); | ||
18 | |||
19 | SDL_Color fontColor = {0, 0, 0, 0}; | ||
20 | SDL_Surface* title = TTF_RenderText_Blended(loadFont(40), "Highscore List", fontColor); | ||
21 | SDL_Rect tSpace = {240-(title->w/2), 0, title->w, title->h}; | ||
22 | SDL_BlitSurface(title, NULL, list, &tSpace); | ||
23 | |||
24 | SDL_Rect oSpace = {0, 440, options->w, options->h}; | ||
25 | SDL_BlitSurface(options, NULL, list, &oSpace); | ||
26 | |||
27 | selection = 0; | ||
28 | |||
29 | SDL_WM_SetCaption("Maze Of Life - Highscore List", NULL); | ||
30 | } | ||
31 | |||
32 | void LocalHighscoreListState::input(SDL_keysym key) | ||
33 | { | ||
34 | if (fromGame) | ||
35 | { | ||
36 | if ((key.sym == SDLK_LEFT) && (selection != 0)) | ||
37 | { | ||
38 | selection--; | ||
39 | } else if ((key.sym == SDLK_RIGHT) && (selection != 1)) | ||
40 | { | ||
41 | selection++; | ||
42 | } else if (key.sym == SDLK_RETURN) | ||
43 | { | ||
44 | switch (selection) | ||
45 | { | ||
46 | case 0: | ||
47 | changeState(new GameState()); | ||
48 | |||
49 | break; | ||
50 | case 1: | ||
51 | changeState(new TitleState()); | ||
52 | |||
53 | break; | ||
54 | } | ||
55 | } | ||
56 | } else { | ||
57 | if (key.sym == SDLK_RETURN) | ||
58 | { | ||
59 | changeState(new ChooseHighscoreListState()); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | |||
64 | void LocalHighscoreListState::render(SDL_Surface* screen) | ||
65 | { | ||
66 | SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); | ||
67 | |||
68 | SDL_BlitSurface(list, NULL, screen, NULL); | ||
69 | |||
70 | SDL_Rect pSpace; | ||
71 | pSpace.w = pointer->w; | ||
72 | pSpace.h = pointer->h; | ||
73 | |||
74 | if (fromGame) | ||
75 | { | ||
76 | pSpace.x = (selection==0?52:225); | ||
77 | pSpace.y = 447; | ||
78 | } else { | ||
79 | pSpace.x = 137; | ||
80 | pSpace.y = 449; | ||
81 | } | ||
82 | |||
83 | SDL_BlitSurface(pointer, NULL, screen, &pSpace); | ||
84 | } | ||