1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/*
* Zaz
* Copyright (C) Remigiusz Dybka 2009 <remigiusz.dybka@gmail.com>
*
Zaz is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zaz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GAMELOOP_H__
#define __GAMELOOP_H__
#include <vector>
#include <string>
#include <sstream>
#include "common.h"
#include "scene.h"
#include "game.h"
#include "menu.h"
#include "lineeditor.h"
class GameLoop : public Scenes::Scene
{
friend void pauseMenuContinueHandler(void *ptr);
friend void pauseMenuEndGameHandler(void *ptr);
friend void nextLevelMenuNextLevelHandler(void *ptr);
friend void nextLevelMenuViewReplayHandler(void *ptr);
friend void nextLevelMenuExportVideoHandler(void *ptr);
friend void gameOverMenuRestartHandler(void *ptr);
friend void lifeLostMenuRetryLevelHandler(void *ptr);
static const uint nLives = 3;
static const uint screenShotTextureSize = 512;
uint score;
uint lastscore;
uint currentLevelName;
uint randomSeed;
GLuint *gameTextures;
vector<string>levelNames;
double vwidth;
double vleft;
double vheight;
bool showMenu;
bool gameOver;
bool showPauseMenu;
bool continueGame;
bool showLifeLostMenu;
bool pwned;
bool hiScore;
Game *game;
Level *level;
GLuint logoTexture;
GLuint screenShotTexture;
double pwnedr;
Menu pauseMenu;
Menu nextLevelMenu;
Menu gameOverMenu;
Menu lifeLostMenu;
LineEditor editor;
stringstream tempRecording;
string recording;
uint pausedFrame;
int livesLeft;
int livesLeftInReplay;
void CenterMsg(string msg, double y, FTFont *font);
public:
GameLoop(Scenes::Settings *settings, SDL_Surface *surf, GLuint *gameTextures, uint startLevel, uint fps = Scenes::DEFAULT_FPS);
~GameLoop();
void GenScreenShotTexture();
void GLSetup();
void Render(ulong frame);
void Logic(ulong frame);
void ViewReplay();
void ExportReplay();
void NextLevel();
void ClearGame();
void CenterMsg();
};
void pauseMenuContinueHandler(void *ptr);
void pauseMenuEndGameHandler(void *ptr);
void nextLevelMenuNextLevelHandler(void *ptr);
void nextLevelMenuViewReplayHandler(void *ptr);
void nextLevelMenuExportVideoHandler(void *ptr);
void gameOverMenuRestartHandler(void *ptr);
void lifeLostMenuRetryLevelHandler(void *ptr);
#endif //__GAMELOOP_H__
|