23
23
/* Configuration options */
25
29
#ifndef __CONFIGURATION_H__
26
30
#define __CONFIGURATION_H__
28
#define MAX_PLAYERS (12)
30
#define WINNING_SCORE (15)
32
#define MAX_PLAYERS (4)
33
#define DEFAULT_FPS (50)
34
#define DEFAULT_WINNING_SCORE (15)
32
36
#define DEFAULT_BALL_AMPLIFY 5
38
#define DEFAULT_FRAME_SKIP 0
40
#define DEFAULT_THEME "classic"
42
#define DEFAULT_FULLSCREEN false
44
#define DEFAULT_SOUND true
34
46
#define DEFAULT_NPLAYERFRAMES 4
35
47
#define DEFAULT_PLAYERSTILLB 1
36
48
#define DEFAULT_PLAYERSTILLE 1
45
57
#define DEFAULT_NBALLFRAMES 4
46
58
#define DEFAULT_BALLPERIOD 1000
60
#define BALL_SPEED_INC 3
62
#define DEFAULT_CONF_FILENAME ".gav"
63
#define ALTERNATIVE_CONF_FILENAME "gav.ini"
65
#define ENVIRONMENT_WIDTH (640)
66
#define ENVIRONMENT_HEIGHT (400)
68
#define BIG_ENVIRONMENT_WIDTH (1000)
69
#define BIG_ENVIRONMENT_HEIGHT (400)
48
72
enum { PLAYER_NONE, PLAYER_HUMAN, PLAYER_COMPUTER};
49
73
enum { MONITOR_NORMAL, MONITOR_OLD, MONITOR_VERYOLD, MONITOR_VERYVERYOLD};
74
110
int right_players[MAX_PLAYERS/2];
75
111
PlayerFrameConf_t playerFrameConf;
76
112
BallFrameConf_t ballFrameConf;
113
Resolution_t resolution;
114
Resolution_t desiredResolution;
116
std::string currentTheme;
118
/* Constants that depend on the screen size */
123
int SPEED_MULTIPLIER;
79
131
/* To add: something meaningful to record the controls... */
82
134
int winning_score;
87
139
unsigned int fps; // fps of the update (not graphical)
88
140
unsigned int mill_per_frame; // caches the # of msecs per frame (1000/fps)
89
141
bool bgBig; // if the background is big
90
143
unsigned int ballAmplify;
92
145
Configuration() : left_nplayers(1), right_nplayers(1),
93
sound(1), winning_score(WINNING_SCORE) {
146
sound(DEFAULT_SOUND),
147
winning_score(DEFAULT_WINNING_SCORE) {
94
148
monitor_type = MONITOR_NORMAL;
149
frame_skip = DEFAULT_FRAME_SKIP;
97
151
mill_per_frame = 1000 / fps;
98
152
left_players[0] = PLAYER_HUMAN;
99
153
right_players[0] = PLAYER_COMPUTER;
102
156
right_players[i] = PLAYER_NONE;
159
fullscreen = DEFAULT_FULLSCREEN;
105
160
ballAmplify = DEFAULT_BALL_AMPLIFY;
106
161
setDefaultFrameConf();
162
currentTheme = "classic";
163
scaleFactors(ENVIRONMENT_WIDTH, ENVIRONMENT_HEIGHT);
164
env.w = ENVIRONMENT_WIDTH;
165
env.h = ENVIRONMENT_HEIGHT;
166
setDesiredResolution(ENVIRONMENT_WIDTH, ENVIRONMENT_HEIGHT);
167
setResolution(ENVIRONMENT_WIDTH, ENVIRONMENT_HEIGHT);
170
void scaleFactors(int width, int height) {
171
SCREEN_WIDTH = width;
172
SCREEN_HEIGHT = height;
173
SPEEDY = ((float) SCREEN_HEIGHT / 2.5);
174
FLOOR_ORD = SCREEN_HEIGHT -(SCREEN_HEIGHT / 200);
175
NET_X = width / 2 - width / 80;
176
NET_Y = height / 2 + ( 3*height / 200 );
177
CEILING = (int) (height / 17);
178
LEFT_WALL = (int) (width / 80);
179
RIGHT_WALL = (int) (width - width / 40);
180
DEFAULT_SPEED = (int) (bgBig)?(width/4):(25*width/64);
183
inline void setResolution(int w, int h) {
186
resolution.ratioX = (float) resolution.x / (float) env.w;
187
resolution.ratioY = (float) resolution.y / (float) env.h;
190
inline void setResolutionToDesired() {
191
setResolution(desiredResolution.x, desiredResolution.y);
194
inline void setDesiredResolution(int w, int h) {
195
desiredResolution.x = w;
196
desiredResolution.y = h;
197
desiredResolution.ratioX = (float) desiredResolution.x / (float) env.w;
198
desiredResolution.ratioY = (float) desiredResolution.y / (float) env.h;
109
201
inline void setDefaultFrameConf() {
127
219
mill_per_frame = 1000 / val;
222
std::string toString(int v) {
223
std::ostringstream os;
230
int loadConfiguration();
231
int saveConfiguration(std::string fname);
232
int createConfigurationFile();
233
std::string confFileName();
234
//void scaleFactors(int width, int height);