diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-11-08 13:42:14 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-11-08 13:42:14 -0500 |
commit | ba90715d26e84fd176a0d44bd8e5dde826067d93 (patch) | |
tree | a5f0ca481895197f1d0e5db341e7263e3fcc0529 /hsglobal.cpp | |
parent | c027f1b9cd6c9deb60931a7f9f75bb4ee130291b (diff) | |
download | mazeoflife-ba90715d26e84fd176a0d44bd8e5dde826067d93.tar.gz mazeoflife-ba90715d26e84fd176a0d44bd8e5dde826067d93.tar.bz2 mazeoflife-ba90715d26e84fd176a0d44bd8e5dde826067d93.zip |
Added global highscore list
You can now view and submit highscores to the global highscore list. If the connection fails, you are allowed to retry sending it so your score is not lost. The actual global highscore list is a PHP file and MySQL database that will need to be uploaded to Four Island Other for this to work. Some other things were done. Because it was discovered that the frequent window caption changes were making Maze Of Life crash, they were removed and the player is now notified of their score by the level number appearing in 100 point font at the beginning of each level during the doneWorking stage. Also, a cheat was added that allows you to play the game in fullscreen if you press F4 on a supporting platform. The player is now also slightly faster. Closes #104
Diffstat (limited to 'hsglobal.cpp')
-rw-r--r-- | hsglobal.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/hsglobal.cpp b/hsglobal.cpp new file mode 100644 index 0000000..37db44b --- /dev/null +++ b/hsglobal.cpp | |||
@@ -0,0 +1,63 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | GlobalHighscoreListState::GlobalHighscoreListState() | ||
4 | { | ||
5 | LOADIMAGE(options,hlo_rtm) | ||
6 | LOADIMAGE(pointer,pointer) | ||
7 | |||
8 | list = SDL_CreateRGBSurface(SDL_SWSURFACE || SDL_SRCCOLORKEY, 480, 480, 32, 0,0,0,0); | ||
9 | Uint32 bgColor = SDL_MapRGB(list->format, 255, 255, 255); | ||
10 | SDL_FillRect(list, NULL, bgColor); | ||
11 | SDL_SetColorKey(list, SDL_SRCCOLORKEY, bgColor); | ||
12 | TTF_Font* dataFont = loadFont(25); | ||
13 | SDL_Color fontColor = {0, 0, 0, 0}; | ||
14 | SDL_Surface* text = TTF_RenderText_Blended(dataFont, "Fetching highscores....", fontColor); | ||
15 | SDL_Rect aSpace = {240-(text->w/2), 240-(text->h/2), text->w, text->h}; | ||
16 | SDL_BlitSurface(text, NULL, list, &aSpace); | ||
17 | |||
18 | SDL_Surface* title = TTF_RenderText_Blended(loadFont(40), "Highscore List", fontColor); | ||
19 | SDL_Rect tSpace = {240-(title->w/2), 0, title->w, title->h}; | ||
20 | SDL_BlitSurface(title, NULL, list, &tSpace); | ||
21 | |||
22 | SDL_Rect oSpace = {0, 440, options->w, options->h}; | ||
23 | SDL_BlitSurface(options, NULL, list, &oSpace); | ||
24 | |||
25 | SDL_CreateThread(&LoadHighscoreList, this); | ||
26 | } | ||
27 | |||
28 | int GlobalHighscoreListState::LoadHighscoreList(void* pParam) | ||
29 | { | ||
30 | GlobalHighscoreList* lhl = new GlobalHighscoreList(); | ||
31 | ((GlobalHighscoreListState*)pParam)->list = lhl->render(); | ||
32 | |||
33 | SDL_Color fontColor = {0, 0, 0, 0}; | ||
34 | SDL_Surface* title = TTF_RenderText_Blended(loadFont(40), "Highscore List", fontColor); | ||
35 | SDL_Rect tSpace = {240-(title->w/2), 0, title->w, title->h}; | ||
36 | SDL_BlitSurface(title, NULL, ((GlobalHighscoreListState*)pParam)->list, &tSpace); | ||
37 | |||
38 | SDL_Rect oSpace = {0, 440, ((GlobalHighscoreListState*)pParam)->options->w, ((GlobalHighscoreListState*)pParam)->options->h}; | ||
39 | SDL_BlitSurface(((GlobalHighscoreListState*)pParam)->options, NULL, ((GlobalHighscoreListState*)pParam)->list, &oSpace); | ||
40 | } | ||
41 | |||
42 | void GlobalHighscoreListState::input(SDL_keysym key) | ||
43 | { | ||
44 | if (key.sym == SDLK_RETURN) | ||
45 | { | ||
46 | changeState(new ChooseHighscoreListState()); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | void GlobalHighscoreListState::render(SDL_Surface* screen) | ||
51 | { | ||
52 | SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); | ||
53 | |||
54 | SDL_BlitSurface(list, NULL, screen, NULL); | ||
55 | |||
56 | SDL_Rect pSpace; | ||
57 | pSpace.x = 137; | ||
58 | pSpace.y = 449; | ||
59 | pSpace.w = pointer->w; | ||
60 | pSpace.h = pointer->h; | ||
61 | |||
62 | SDL_BlitSurface(pointer, NULL, screen, &pSpace); | ||
63 | } | ||