summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--gamestate.cpp16
-rw-r--r--gamestate.h2
-rw-r--r--hslist.cpp12
-rw-r--r--hslist.h12
-rw-r--r--mazeoflife.cpp2
-rw-r--r--state.h2
-rw-r--r--titlestate.cpp6
-rw-r--r--titlestate.h6
8 files changed, 32 insertions, 26 deletions
diff --git a/gamestate.cpp b/gamestate.cpp index 812f26c..f0de67a 100644 --- a/gamestate.cpp +++ b/gamestate.cpp
@@ -22,7 +22,7 @@ class GameBoard {
22class LoadGameState : public State { 22class LoadGameState : public State {
23 public: 23 public:
24 LoadGameState(int level); 24 LoadGameState(int level);
25 State* operator() (SDL_Renderer* renderer); 25 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
26 26
27 private: 27 private:
28 int level; 28 int level;
@@ -31,7 +31,7 @@ class LoadGameState : public State {
31class PlayGameState : public State { 31class PlayGameState : public State {
32 public: 32 public:
33 PlayGameState(int level, GameBoard* board, int playerx, int playery); 33 PlayGameState(int level, GameBoard* board, int playerx, int playery);
34 State* operator() (SDL_Renderer* renderer); 34 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
35 35
36 private: 36 private:
37 bool move(int x, int y); 37 bool move(int x, int y);
@@ -81,7 +81,7 @@ void incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick, int
81 } 81 }
82} 82}
83 83
84State* GameState::operator() (SDL_Renderer* renderer) 84State* GameState::operator() (SDL_Window* window, SDL_Renderer* renderer)
85{ 85{
86 return new LoadGameState(0); 86 return new LoadGameState(0);
87} 87}
@@ -91,8 +91,12 @@ LoadGameState::LoadGameState(int m_level)
91 level = m_level; 91 level = m_level;
92} 92}
93 93
94State* LoadGameState::operator() (SDL_Renderer* renderer) 94State* LoadGameState::operator() (SDL_Window* window, SDL_Renderer* renderer)
95{ 95{
96 char* wintitle = new char[50];
97 sprintf(wintitle, "Maze Of Life - Level %d", level);
98 SDL_SetWindowTitle(window, wintitle);
99
96 // Randomly place the player in a corner 100 // Randomly place the player in a corner
97 int playerx, playery; 101 int playerx, playery;
98 switch (rand()%4) 102 switch (rand()%4)
@@ -145,7 +149,7 @@ PlayGameState::PlayGameState(int m_level, GameBoard* m_board, int m_playerx, int
145 playery = m_playery; 149 playery = m_playery;
146} 150}
147 151
148State* PlayGameState::operator() (SDL_Renderer* renderer) 152State* PlayGameState::operator() (SDL_Window* window, SDL_Renderer* renderer)
149{ 153{
150 SDL_Event e; 154 SDL_Event e;
151 155
@@ -216,6 +220,8 @@ State* PlayGameState::operator() (SDL_Renderer* renderer)
216 } 220 }
217 221
218 case SDLK_ESCAPE: 222 case SDLK_ESCAPE:
223 SDL_SetWindowTitle(window, "");
224
219 std::ifstream exists(getDataFile()); 225 std::ifstream exists(getDataFile());
220 if (exists) 226 if (exists)
221 { 227 {
diff --git a/gamestate.h b/gamestate.h index 815bc73..3c77ba9 100644 --- a/gamestate.h +++ b/gamestate.h
@@ -6,7 +6,7 @@
6 6
7class GameState : public State { 7class GameState : public State {
8 public: 8 public:
9 State* operator() (SDL_Renderer* renderer); 9 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
10}; 10};
11 11
12#endif \ No newline at end of file 12#endif \ No newline at end of file
diff --git a/hslist.cpp b/hslist.cpp index 5ebface..a0debd7 100644 --- a/hslist.cpp +++ b/hslist.cpp
@@ -251,7 +251,7 @@ SDL_Surface* GlobalHighscoreList::render()
251 } 251 }
252} 252}
253 253
254State* ChooseHighscoreListState::operator() (SDL_Renderer* renderer) 254State* ChooseHighscoreListState::operator() (SDL_Window* window, SDL_Renderer* renderer)
255{ 255{
256 SDL_Texture* background = loadImage(renderer, "resources/chl.bmp"); 256 SDL_Texture* background = loadImage(renderer, "resources/chl.bmp");
257 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 257 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
@@ -292,7 +292,7 @@ State* ChooseHighscoreListState::operator() (SDL_Renderer* renderer)
292 } 292 }
293} 293}
294 294
295State* DisplayLocalHighscoreListState::operator() (SDL_Renderer* renderer) 295State* DisplayLocalHighscoreListState::operator() (SDL_Window* window, SDL_Renderer* renderer)
296{ 296{
297 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 297 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
298 298
@@ -338,7 +338,7 @@ State* DisplayLocalHighscoreListState::operator() (SDL_Renderer* renderer)
338 } 338 }
339} 339}
340 340
341State* DisplayAndReturnLocalHighscoreListState::operator() (SDL_Renderer* renderer) 341State* DisplayAndReturnLocalHighscoreListState::operator() (SDL_Window* window, SDL_Renderer* renderer)
342{ 342{
343 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 343 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
344 344
@@ -396,7 +396,7 @@ State* DisplayAndReturnLocalHighscoreListState::operator() (SDL_Renderer* render
396 } 396 }
397} 397}
398 398
399State* DisplayGlobalHighscoreListState::operator() (SDL_Renderer* renderer) 399State* DisplayGlobalHighscoreListState::operator() (SDL_Window* window, SDL_Renderer* renderer)
400{ 400{
401 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 401 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
402 402
@@ -508,7 +508,7 @@ EnterHighscoreState::EnterHighscoreState(int level)
508 this->level = level; 508 this->level = level;
509} 509}
510 510
511State* EnterHighscoreState::operator() (SDL_Renderer* renderer) 511State* EnterHighscoreState::operator() (SDL_Window* window, SDL_Renderer* renderer)
512{ 512{
513 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 513 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
514 514
@@ -624,7 +624,7 @@ NewHighscoreState::NewHighscoreState(Highscore* h)
624 this->h = h; 624 this->h = h;
625} 625}
626 626
627State* NewHighscoreState::operator() (SDL_Renderer* renderer) 627State* NewHighscoreState::operator() (SDL_Window* window, SDL_Renderer* renderer)
628{ 628{
629 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 629 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
630 630
diff --git a/hslist.h b/hslist.h index c1db137..8d450af 100644 --- a/hslist.h +++ b/hslist.h
@@ -43,22 +43,22 @@ class GlobalHighscoreList : public HighscoreList {
43 43
44class ChooseHighscoreListState : public State { 44class ChooseHighscoreListState : public State {
45 public: 45 public:
46 State* operator() (SDL_Renderer* renderer); 46 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
47}; 47};
48 48
49class DisplayLocalHighscoreListState : public State { 49class DisplayLocalHighscoreListState : public State {
50 public: 50 public:
51 State* operator() (SDL_Renderer* renderer); 51 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
52}; 52};
53 53
54class DisplayAndReturnLocalHighscoreListState : public State { 54class DisplayAndReturnLocalHighscoreListState : public State {
55 public: 55 public:
56 State* operator() (SDL_Renderer* renderer); 56 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
57}; 57};
58 58
59class DisplayGlobalHighscoreListState : public State { 59class DisplayGlobalHighscoreListState : public State {
60 public: 60 public:
61 State* operator() (SDL_Renderer* renderer); 61 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
62 62
63 protected: 63 protected:
64 SDL_Surface* list_s; 64 SDL_Surface* list_s;
@@ -73,7 +73,7 @@ class DisplayGlobalHighscoreListState : public State {
73class EnterHighscoreState : public State { 73class EnterHighscoreState : public State {
74 public: 74 public:
75 EnterHighscoreState(int level); 75 EnterHighscoreState(int level);
76 State* operator() (SDL_Renderer* renderer); 76 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
77 77
78 private: 78 private:
79 int level; 79 int level;
@@ -85,7 +85,7 @@ class EnterHighscoreState : public State {
85class NewHighscoreState : public State { 85class NewHighscoreState : public State {
86 public: 86 public:
87 NewHighscoreState(Highscore* h); 87 NewHighscoreState(Highscore* h);
88 State* operator() (SDL_Renderer* renderer); 88 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
89 89
90 private: 90 private:
91 Highscore* h; 91 Highscore* h;
diff --git a/mazeoflife.cpp b/mazeoflife.cpp index fda6f74..da19908 100644 --- a/mazeoflife.cpp +++ b/mazeoflife.cpp
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
50 State* state = new TitleState(); 50 State* state = new TitleState();
51 while (state != NULL) 51 while (state != NULL)
52 { 52 {
53 state = (*state)(renderer); 53 state = (*state)(window, renderer);
54 } 54 }
55 55
56 SDL_DestroyRenderer(renderer); 56 SDL_DestroyRenderer(renderer);
diff --git a/state.h b/state.h index 2d6f804..5e8c4e7 100644 --- a/state.h +++ b/state.h
@@ -6,7 +6,7 @@
6class State 6class State
7{ 7{
8 public: 8 public:
9 virtual State* operator() (SDL_Renderer* renderer) {return NULL;}; 9 virtual State* operator() (SDL_Window* window, SDL_Renderer* renderer) {return NULL;};
10}; 10};
11 11
12#endif \ No newline at end of file 12#endif \ No newline at end of file
diff --git a/titlestate.cpp b/titlestate.cpp index bf966ea..2b85fbe 100644 --- a/titlestate.cpp +++ b/titlestate.cpp
@@ -3,7 +3,7 @@
3#include "gamestate.h" 3#include "gamestate.h"
4#include "hslist.h" 4#include "hslist.h"
5 5
6State* TitleState::operator() (SDL_Renderer* renderer) 6State* TitleState::operator() (SDL_Window* window, SDL_Renderer* renderer)
7{ 7{
8 SDL_Texture* background = loadImage(renderer, "resources/title.bmp"); 8 SDL_Texture* background = loadImage(renderer, "resources/title.bmp");
9 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 9 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
@@ -45,7 +45,7 @@ State* TitleState::operator() (SDL_Renderer* renderer)
45 } 45 }
46} 46}
47 47
48State* HowToPlayState::operator() (SDL_Renderer* renderer) 48State* HowToPlayState::operator() (SDL_Window* window, SDL_Renderer* renderer)
49{ 49{
50 SDL_Texture* background = loadImage(renderer, "resources/htp1.bmp"); 50 SDL_Texture* background = loadImage(renderer, "resources/htp1.bmp");
51 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 51 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
@@ -89,7 +89,7 @@ State* HowToPlayState::operator() (SDL_Renderer* renderer)
89 } 89 }
90} 90}
91 91
92State* HowToPlayPageTwoState::operator() (SDL_Renderer* renderer) 92State* HowToPlayPageTwoState::operator() (SDL_Window* window, SDL_Renderer* renderer)
93{ 93{
94 SDL_Texture* background = loadImage(renderer, "resources/htp2.bmp"); 94 SDL_Texture* background = loadImage(renderer, "resources/htp2.bmp");
95 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp"); 95 SDL_Texture* pointer = loadImage(renderer, "resources/pointer.bmp");
diff --git a/titlestate.h b/titlestate.h index c7beb91..8e6ffbc 100644 --- a/titlestate.h +++ b/titlestate.h
@@ -6,17 +6,17 @@
6 6
7class TitleState : public State { 7class TitleState : public State {
8 public: 8 public:
9 State* operator() (SDL_Renderer* renderer); 9 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
10}; 10};
11 11
12class HowToPlayState : public State { 12class HowToPlayState : public State {
13 public: 13 public:
14 State* operator() (SDL_Renderer* renderer); 14 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
15}; 15};
16 16
17class HowToPlayPageTwoState : public State { 17class HowToPlayPageTwoState : public State {
18 public: 18 public:
19 State* operator() (SDL_Renderer* renderer); 19 State* operator() (SDL_Window* window, SDL_Renderer* renderer);
20}; 20};
21 21
22#endif \ No newline at end of file 22#endif \ No newline at end of file