File: Configuration.h

package info (click to toggle)
gav 0.8.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 588 kB
  • ctags: 706
  • sloc: cpp: 3,602; makefile: 152; sh: 10
file content (131 lines) | stat: -rw-r--r-- 3,928 bytes parent folder | download
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* -*- C++ -*- */
/*
  GAV - Gpl Arcade Volleyball
  
  Copyright (C) 2002
  GAV team (http://sourceforge.net/projects/gav/)

  This program 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 2 of the License, or
  (at your option) any later version.

  This program 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, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/* Configuration options */

#ifndef __CONFIGURATION_H__
#define __CONFIGURATION_H__

#define MAX_PLAYERS (12)
#define FPS (50)
#define WINNING_SCORE (15)

#define DEFAULT_BALL_AMPLIFY 5

#define DEFAULT_NPLAYERFRAMES 4
#define DEFAULT_PLAYERSTILLB  1
#define DEFAULT_PLAYERSTILLE  1
#define DEFAULT_PLAYERSTILLP  0
#define DEFAULT_PLAYERRUNB    2
#define DEFAULT_PLAYERRUNE    3
#define DEFAULT_PLAYERRUNP    250
#define DEFAULT_PLAYERJMPB    4
#define DEFAULT_PLAYERJMPE    4
#define DEFAULT_PLAYERJMPP    0

#define DEFAULT_NBALLFRAMES   4
#define DEFAULT_BALLPERIOD    1000

enum { PLAYER_NONE, PLAYER_HUMAN, PLAYER_COMPUTER};
enum { MONITOR_NORMAL, MONITOR_OLD, MONITOR_VERYOLD, MONITOR_VERYVERYOLD};

typedef struct PlayerFrameConf_s {
  unsigned short nPlayerFrames;
  unsigned short playerStillB;
  unsigned short playerStillE;
  unsigned short playerStillP;
  unsigned short playerRunB;
  unsigned short playerRunE;
  unsigned short playerRunP;
  unsigned short playerJmpB;
  unsigned short playerJmpE;
  unsigned short playerJmpP;
} PlayerFrameConf_t;

typedef struct BallFrameConf_s {
  unsigned short nBallFrames;
  unsigned short ballPeriod;
} BallFrameConf_t;

class Configuration {
public:
  int left_nplayers;
  int right_nplayers;
  int left_players[MAX_PLAYERS/2];
  int right_players[MAX_PLAYERS/2];
  PlayerFrameConf_t playerFrameConf;
  BallFrameConf_t ballFrameConf;


  /* To add: something meaningful to record the controls... */

  int sound;
  int winning_score;

  int monitor_type;

  unsigned int frame_skip;     // one every frame_skip + 1 are actually drawn
  unsigned int fps;            // fps of the update (not graphical)
  unsigned int mill_per_frame; // caches the # of msecs per frame (1000/fps)
  bool bgBig;                  // if the background is big
  unsigned int ballAmplify;

  Configuration() : left_nplayers(1), right_nplayers(1),
		    sound(1), winning_score(WINNING_SCORE) {
    monitor_type = MONITOR_NORMAL;
    frame_skip = 0;
    fps = FPS;
    mill_per_frame = 1000 / fps;
    left_players[0] = PLAYER_HUMAN;
    right_players[0] = PLAYER_COMPUTER;
    for ( int i = 1; i < MAX_PLAYERS/2; i++ ) {
      left_players[i] = PLAYER_NONE;
      right_players[i] = PLAYER_NONE;
    }
    bgBig = false;
    ballAmplify = DEFAULT_BALL_AMPLIFY;
    setDefaultFrameConf();
  }

  inline void setDefaultFrameConf() {
    playerFrameConf.nPlayerFrames = DEFAULT_NPLAYERFRAMES;
    playerFrameConf.playerStillB = DEFAULT_PLAYERSTILLB;
    playerFrameConf.playerStillE = DEFAULT_PLAYERSTILLE;
    playerFrameConf.playerStillP = DEFAULT_PLAYERSTILLP;
    playerFrameConf.playerRunB = DEFAULT_PLAYERRUNB;
    playerFrameConf.playerRunE = DEFAULT_PLAYERRUNE;
    playerFrameConf.playerRunP = DEFAULT_PLAYERRUNP;
    playerFrameConf.playerJmpB = DEFAULT_PLAYERJMPB;
    playerFrameConf.playerJmpE = DEFAULT_PLAYERJMPE;
    playerFrameConf.playerJmpP = DEFAULT_PLAYERJMPP;

    ballFrameConf.nBallFrames = DEFAULT_NBALLFRAMES;
    ballFrameConf.ballPeriod = DEFAULT_BALLPERIOD;
  }

  inline void setFps(int val) {
    fps = val;
    mill_per_frame = 1000 / val;
  }
};

#endif