From 49900856bece81481a56888b7bbce45bf746c422 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 22 Jun 2009 10:02:20 -0400 Subject: Added Choose Highscore List state Refs #104 --- chl.bmp | Bin 0 -> 921654 bytes chlstate.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ chlstate.h | 16 ++++++++++++++++ htpstate.cpp | 4 ++-- includes.h | 1 + resources.h | 1 + titlestate.cpp | 8 +++++--- 7 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 chl.bmp create mode 100644 chlstate.cpp create mode 100644 chlstate.h diff --git a/chl.bmp b/chl.bmp new file mode 100644 index 0000000..b69efd0 Binary files /dev/null and b/chl.bmp differ diff --git a/chlstate.cpp b/chlstate.cpp new file mode 100644 index 0000000..24dd674 --- /dev/null +++ b/chlstate.cpp @@ -0,0 +1,48 @@ +#include "includes.h" + +ChooseHighscoreListState::ChooseHighscoreListState() +{ + LOADIMAGE(background,chl) + LOADIMAGE(pointer,pointer) + + selection = 0; + + SDL_WM_SetCaption("Maze Of Life - Choose Highscore List", NULL); +} + +void ChooseHighscoreListState::input(SDLKey key) +{ + if ((key == SDLK_UP) && (selection != 0)) + { + selection--; + } else if ((key == SDLK_DOWN) && (selection != 2)) + { + selection++; + } else if (key == SDLK_RETURN) + { + switch (selection) + { + case 0: // Go to local highscore list + break; + case 1: // Go to global highscore list + break; + case 2: + changeState(new TitleState()); + + break; + } + } +} + +void ChooseHighscoreListState::render(SDL_Surface* screen) +{ + SDL_BlitSurface(background, NULL, screen, NULL); + + SDL_Rect pSpace; + pSpace.x = 127; + pSpace.y = (selection==0?306:(selection==1?336:396)); + pSpace.w = pointer->w; + pSpace.h = pointer->h; + + SDL_BlitSurface(pointer, NULL, screen, &pSpace); +} diff --git a/chlstate.h b/chlstate.h new file mode 100644 index 0000000..a8905e2 --- /dev/null +++ b/chlstate.h @@ -0,0 +1,16 @@ +#ifndef CHLSTATE_H +#define CHLSTATE_H + +class ChooseHighscoreListState : public State { + public: + ChooseHighscoreListState(); + void input(SDLKey key); + void render(SDL_Surface* screen); + + private: + SDL_Surface* background; + SDL_Surface* pointer; + int selection; +}; + +#endif diff --git a/htpstate.cpp b/htpstate.cpp index 8de884f..711dca4 100644 --- a/htpstate.cpp +++ b/htpstate.cpp @@ -52,8 +52,8 @@ void HowToPlayState::render(SDL_Surface* screen) } pSpace.y = 430; - pSpace.w = screen->w; - pSpace.h = screen->h; + pSpace.w = pointer->w; + pSpace.h = pointer->h; SDL_BlitSurface(pointer, NULL, screen, &pSpace); } diff --git a/includes.h b/includes.h index 5b0895d..a36c456 100644 --- a/includes.h +++ b/includes.h @@ -7,4 +7,5 @@ #include "resources.h" #include "titlestate.h" #include "htpstate.h" +#include "chlstate.h" #include "gamestate.h" diff --git a/resources.h b/resources.h index 457fbec..ced40b0 100644 --- a/resources.h +++ b/resources.h @@ -13,5 +13,6 @@ DEFIMAGE(title) DEFIMAGE(pointer) DEFIMAGE(htp1) DEFIMAGE(htp2) +DEFIMAGE(chl) #endif diff --git a/titlestate.cpp b/titlestate.cpp index 6c4401d..980e3b6 100644 --- a/titlestate.cpp +++ b/titlestate.cpp @@ -30,7 +30,9 @@ void TitleState::input(SDLKey key) changeState(new HowToPlayState()); break; - case 2: // Add choose highscore list + case 2: + changeState(new ChooseHighscoreListState()); + break; case 3: exit(0); @@ -45,8 +47,8 @@ void TitleState::render(SDL_Surface* screen) SDL_Rect pSpace; pSpace.x = 136; pSpace.y = (selection==0?316:(selection==1?350:(selection==2?381:417))); - pSpace.w = screen->w; - pSpace.h = screen->h; + pSpace.w = pointer->w; + pSpace.h = pointer->h; SDL_BlitSurface(pointer, NULL, screen, &pSpace); } -- cgit 1.4.1