git repos / blockattack-game

blame: source/code/mainVars.inc

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c53e6443 sago007 2012-04-17 11:04 4
Copyright (C) 2005-2012 Poul Sander
c53e6443 sago007 2012-04-17 11:04 5
c53e6443 sago007 2012-04-17 11:04 6
This program is free software: you can redistribute it and/or modify
c53e6443 sago007 2012-04-17 11:04 7
it under the terms of the GNU General Public License as published by
c53e6443 sago007 2012-04-17 11:04 8
the Free Software Foundation, either version 2 of the License, or
c53e6443 sago007 2012-04-17 11:04 9
(at your option) any later version.
c53e6443 sago007 2012-04-17 11:04 10
c53e6443 sago007 2012-04-17 11:04 11
This program is distributed in the hope that it will be useful,
c53e6443 sago007 2012-04-17 11:04 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
c53e6443 sago007 2012-04-17 11:04 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c53e6443 sago007 2012-04-17 11:04 14
GNU General Public License for more details.
c53e6443 sago007 2012-04-17 11:04 15
c53e6443 sago007 2012-04-17 11:04 16
You should have received a copy of the GNU General Public License
c53e6443 sago007 2012-04-17 11:04 17
along with this program.  If not, see http://www.gnu.org/licenses/
c53e6443 sago007 2012-04-17 11:04 18
c53e6443 sago007 2012-04-17 11:04 19
Source information and contacts persons can be found at
021de090 sago007 2015-12-30 18:56 20
http://blockattack.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
89c4a3a6 sago007 2008-08-29 14:32 22
*/
89c4a3a6 sago007 2008-08-29 14:32 23
6d48320c sago007 2009-03-28 17:06 24
//Make sure it is only included once
6d48320c sago007 2009-03-28 17:06 25
#ifndef _MAINVARS_HPP
6d48320c sago007 2009-03-28 17:06 26
#define	_MAINVARS_HPP
6d48320c sago007 2009-03-28 17:06 27
c6bde3e3 sago007 2015-12-22 16:56 28
#include "sago/SagoSprite.hpp"
c6bde3e3 sago007 2015-12-22 16:56 29
c6bde3e3 sago007 2015-12-22 16:56 30
89c4a3a6 sago007 2008-08-29 14:32 31
//main variables and constants
89c4a3a6 sago007 2008-08-29 14:32 32
89c4a3a6 sago007 2008-08-29 14:32 33
89c4a3a6 sago007 2008-08-29 14:32 34
//Animation lengths:
89c4a3a6 sago007 2008-08-29 14:32 35
#define READYTIME 500
89c4a3a6 sago007 2008-08-29 14:32 36
#define BOMBTIME 200
89c4a3a6 sago007 2008-08-29 14:32 37
#define CURSORTIME 200
89c4a3a6 sago007 2008-08-29 14:32 38
1d2e2129 sago007 2015-12-23 15:41 39
#ifndef SHAREDIR
1d2e2129 sago007 2015-12-23 15:41 40
#define SHAREDIR "."
1d2e2129 sago007 2015-12-23 15:41 41
#endif
1d2e2129 sago007 2015-12-23 15:41 42
56241205 sago007 2012-08-05 11:15 43
const char sharedir[] = SHAREDIR;
89c4a3a6 sago007 2008-08-29 14:32 44
89c4a3a6 sago007 2008-08-29 14:32 45
//All graphic in the game (as pointers):
1d2e2129 sago007 2015-12-23 15:41 46
sago::SagoSprite backgroundImage; //Stores the background image
1d2e2129 sago007 2015-12-23 15:41 47
static sago::SagoSprite backBoard;     //Stores the background to the board
c3b697c6 sago007 2016-02-07 17:30 48
sago::SagoSprite bBack;         //The "Back" button
1d2e2129 sago007 2015-12-23 15:41 49
static sago::SagoSprite bForward;      //The "forward" button
2f30c381 sago007 2008-09-14 13:08 50
#if NETWORK
1d2e2129 sago007 2015-12-23 15:41 51
//static sago::SagoSprite bNetwork;
1d2e2129 sago007 2015-12-23 15:41 52
//static sago::SagoSprite bConnect;
1d2e2129 sago007 2015-12-23 15:41 53
//static sago::SagoSprite bHost;
89c4a3a6 sago007 2008-08-29 14:32 54
#endif
c3b697c6 sago007 2016-02-07 17:30 55
sago::SagoSprite bHighScore;    //The High Score botton
1d2e2129 sago007 2015-12-23 15:41 56
static sago::SagoSprite blackLine;		//The seperator in stage clear
1d2e2129 sago007 2015-12-23 15:41 57
static sago::SagoSprite stageBobble;	//The bobble instage clear
078900fe sago007 2015-12-05 15:31 58
SDL_Renderer *screen;        //The whole screen;
1d2e2129 sago007 2015-12-23 15:41 59
static sago::SagoSprite iGameOver;     //The gameOver image
1d2e2129 sago007 2015-12-23 15:41 60
static sago::SagoSprite iWinner;		//the "winner" image
1d2e2129 sago007 2015-12-23 15:41 61
static sago::SagoSprite iDraw;			//the "draw" image
1d2e2129 sago007 2015-12-23 15:41 62
static sago::SagoSprite iLoser;		//the "loser" image
c1bd83fb sago007 2015-12-23 19:41 63
static sago::SagoSprite iChainFrame;
89c4a3a6 sago007 2008-08-29 14:32 64
//Animations:
1d2e2129 sago007 2015-12-23 15:41 65
static sago::SagoSprite cursor;    //The animated cursor
1d2e2129 sago007 2015-12-23 15:41 66
static sago::SagoSprite bomb;
1d2e2129 sago007 2015-12-23 15:41 67
static sago::SagoSprite ready;      //Before the blocks fall
1d2e2129 sago007 2015-12-23 15:41 68
static sago::SagoSprite explosion[4];   //Then a block explodes
89c4a3a6 sago007 2008-08-29 14:32 69
//Animations end
1d2e2129 sago007 2015-12-23 15:41 70
static sago::SagoSprite counter[3];    //Counts down from 3
c6bde3e3 sago007 2015-12-22 16:56 71
static sago::SagoSprite bricks[7];     //The bricks, saved in an array of pointers
1d2e2129 sago007 2015-12-23 15:41 72
static sago::SagoSprite crossover;     //Cross the bricks that will be cleared soon
1d2e2129 sago007 2015-12-23 15:41 73
static sago::SagoSprite balls[7];      //The balls (the small ones that jump around)
59dcb571 sago007 2016-02-14 15:34 74
sago::SagoSprite dialogBox;
1d2e2129 sago007 2015-12-23 15:41 75
static sago::SagoSprite iLevelCheck;		//To the level select screen
1d2e2129 sago007 2015-12-23 15:41 76
static sago::SagoSprite iLevelCheckBox;
1d2e2129 sago007 2015-12-23 15:41 77
static sago::SagoSprite iLevelCheckBoxMarked;
1d2e2129 sago007 2015-12-23 15:41 78
static sago::SagoSprite iCheckBoxArea;
1d2e2129 sago007 2015-12-23 15:41 79
static sago::SagoSprite boardBackBack;
1d2e2129 sago007 2015-12-23 15:41 80
static sago::SagoSprite garbageTL;			//the Garbage Blocks
1d2e2129 sago007 2015-12-23 15:41 81
static sago::SagoSprite garbageT;
1d2e2129 sago007 2015-12-23 15:41 82
static sago::SagoSprite garbageTR;
1d2e2129 sago007 2015-12-23 15:41 83
static sago::SagoSprite garbageR;
1d2e2129 sago007 2015-12-23 15:41 84
static sago::SagoSprite garbageBR;
1d2e2129 sago007 2015-12-23 15:41 85
static sago::SagoSprite garbageB;
1d2e2129 sago007 2015-12-23 15:41 86
static sago::SagoSprite garbageBL;
1d2e2129 sago007 2015-12-23 15:41 87
static sago::SagoSprite garbageL;
1d2e2129 sago007 2015-12-23 15:41 88
static sago::SagoSprite garbageFill;
1d2e2129 sago007 2015-12-23 15:41 89
static sago::SagoSprite garbageM;
1d2e2129 sago007 2015-12-23 15:41 90
static sago::SagoSprite garbageML;
1d2e2129 sago007 2015-12-23 15:41 91
static sago::SagoSprite garbageMR;
1d2e2129 sago007 2015-12-23 15:41 92
static sago::SagoSprite smiley[4];
1d2e2129 sago007 2015-12-23 15:41 93
static sago::SagoSprite garbageGM;
1d2e2129 sago007 2015-12-23 15:41 94
static sago::SagoSprite garbageGML;
1d2e2129 sago007 2015-12-23 15:41 95
static sago::SagoSprite garbageGMR;
1d2e2129 sago007 2015-12-23 15:41 96
static sago::SagoSprite transCover;        //The transperant block, covers the upcomming
1d2e2129 sago007 2015-12-23 15:41 97
static sago::SagoSprite bSkip;
1d2e2129 sago007 2015-12-23 15:41 98
static sago::SagoSprite bRetry;
c3b697c6 sago007 2016-02-07 17:30 99
sago::SagoSprite bNext;
89c4a3a6 sago007 2008-08-29 14:32 100
1d2e2129 sago007 2015-12-23 15:41 101
sago::SagoSprite menuMarked;
1d2e2129 sago007 2015-12-23 15:41 102
sago::SagoSprite menuUnmarked;
1d2e2129 sago007 2015-12-23 15:41 103
sago::SagoSprite mouse;
89c4a3a6 sago007 2008-08-29 14:32 104
c3b697c6 sago007 2016-02-07 17:30 105
NFont nf_button_font;        //Font used for buttons!
26ddb424 sago007 2011-06-09 20:06 106
NFont nf_scoreboard_font;
c3b697c6 sago007 2016-02-07 17:30 107
NFont nf_standard_blue_font;      //Font used instead of the old blue SFont
925b7e58 sago007 2011-04-25 16:35 108
static NFont nf_standard_small_font;
89c4a3a6 sago007 2008-08-29 14:32 109
30f910dd sago007 2010-11-10 21:02 110
static Mix_Music *bgMusic;         //backgroundMusic
30f910dd sago007 2010-11-10 21:02 111
static Mix_Music *highbeatMusic;   //Background music with higher beat
30f910dd sago007 2010-11-10 21:02 112
static Mix_Chunk *boing;           //boing sound when clearing
30f910dd sago007 2010-11-10 21:02 113
static Mix_Chunk *applause;        //Applause, then the player is good
30f910dd sago007 2010-11-10 21:02 114
static Mix_Chunk *photoClick;      //clickSound
59dcb571 sago007 2016-02-14 15:34 115
Mix_Chunk *typingChunk;          //When writing
30f910dd sago007 2010-11-10 21:02 116
static Mix_Chunk *counterChunk;         //When counting down
30f910dd sago007 2010-11-10 21:02 117
static Mix_Chunk *counterFinalChunk;
89c4a3a6 sago007 2008-08-29 14:32 118
89c4a3a6 sago007 2008-08-29 14:32 119
Highscore theTopScoresEndless;      //Stores highscores for endless
89c4a3a6 sago007 2008-08-29 14:32 120
Highscore theTopScoresTimeTrial;    //Stores highscores for timetrial
89c4a3a6 sago007 2008-08-29 14:32 121
30f910dd sago007 2010-11-10 21:02 122
static bool bMouseUp;              //true if the mouse(1) is unpressed
30f910dd sago007 2010-11-10 21:02 123
static bool bMouseUp2;             //true if the mouse(2) is unpressed
2f30c381 sago007 2008-09-14 13:08 124
#if NETWORK
30f910dd sago007 2010-11-10 21:02 125
static bool bNetworkOpen;			//Show the network menu
89c4a3a6 sago007 2008-08-29 14:32 126
#endif
59dcb571 sago007 2016-02-14 15:34 127
bool NoSound;				//if true, absolutely no sound will be played, can be set from the commandline
89c4a3a6 sago007 2008-08-29 14:32 128
//prevents crash on systems without a soundcard
26ddb424 sago007 2011-06-09 20:06 129
bool MusicEnabled;			//true if background music is enabled
26ddb424 sago007 2011-06-09 20:06 130
bool SoundEnabled;			//true if sound effects is enabled
30f910dd sago007 2010-11-10 21:02 131
static bool bNearDeathPrev;                    //Near death status last time checked.
26ddb424 sago007 2011-06-09 20:06 132
bool bFullscreen;			//true if game is running fullscreen
30f910dd sago007 2010-11-10 21:02 133
static bool puzzleLoaded;          //true if the puzzle levels have been loaded
30f910dd sago007 2010-11-10 21:02 134
static bool drawBalls;             //if true balls are drawed to the screen, this might lower framerate too much
b7590374 sago007 2011-05-19 16:15 135
bool highPriority;
30f910dd sago007 2010-11-10 21:02 136
30f910dd sago007 2010-11-10 21:02 137
static bool editorMode = false;
30f910dd sago007 2010-11-10 21:02 138
static bool editorModeTest = false;
89c4a3a6 sago007 2008-08-29 14:32 139
89c4a3a6 sago007 2008-08-29 14:32 140
//other ball constants:
b37fa2db sago007 2015-12-04 20:44 141
const double gravity = 200.8; //acceleration
b37fa2db sago007 2015-12-04 20:44 142
const double startVelocityY = 50.0;
b37fa2db sago007 2015-12-04 20:44 143
const double VelocityX = 50.0;
b37fa2db sago007 2015-12-04 20:44 144
const int ballSize = 16;
b37fa2db sago007 2015-12-04 20:44 145
const double minVelocity = 200.0;
89c4a3a6 sago007 2008-08-29 14:32 146
89c4a3a6 sago007 2008-08-29 14:32 147
//global settings (reset everytime the game starts)
30f910dd sago007 2010-11-10 21:02 148
static Uint8 player1Speed=0;
30f910dd sago007 2010-11-10 21:02 149
static Uint8 player2Speed=0;
30f910dd sago007 2010-11-10 21:02 150
static bool player1AI=false;		//Is AI enabled?
30f910dd sago007 2010-11-10 21:02 151
static bool player2AI=false;		//Is AI enabled for player 2 (opponent in single player)
30f910dd sago007 2010-11-10 21:02 152
static Uint8 player1AIlevel=3;		//What level is AI? 0 min, 6 max
30f910dd sago007 2010-11-10 21:02 153
static Uint8 player2AIlevel=3;
30f910dd sago007 2010-11-10 21:02 154
static const Uint8 AIlevels=7;		//7 possible levels: 0..6
30f910dd sago007 2010-11-10 21:02 155
static Uint8 player1handicap=0;
30f910dd sago007 2010-11-10 21:02 156
static Uint8 player2handicap=0;
89c4a3a6 sago007 2008-08-29 14:32 157
89c4a3a6 sago007 2008-08-29 14:32 158
unsigned long int currentTime;      //contains the current time, so we don't call SDL_GetTickets() too often...
89c4a3a6 sago007 2008-08-29 14:32 159
30f910dd sago007 2010-11-10 21:02 160
static int xsize = 1024;
30f910dd sago007 2010-11-10 21:02 161
static int ysize = 768;
970c4ebe sago007 2015-08-22 18:08 162
static const int bsize = 50;
89c4a3a6 sago007 2008-08-29 14:32 163
89c4a3a6 sago007 2008-08-29 14:32 164
//Stores the players names (way to long, but at least no buffer overflows (max length is 16 for display reasons))
f6707482 sago007 2015-12-04 22:55 165
std::string player1name;
f6707482 sago007 2015-12-04 22:55 166
std::string player2name;
89c4a3a6 sago007 2008-08-29 14:32 167
f72abf8b sago007 2010-01-16 20:00 168
bool twoPlayers;    //True if two players are playing
89c4a3a6 sago007 2008-08-29 14:32 169
89c4a3a6 sago007 2008-08-29 14:32 170
//Old Stage Clear Buble
30f910dd sago007 2010-11-10 21:02 171
static int oldBubleX, oldBubleY;
89c4a3a6 sago007 2008-08-29 14:32 172
30f910dd sago007 2010-11-10 21:02 173
static bool singlePuzzle = false; //if true we are just in a little 300x600 window
30f910dd sago007 2010-11-10 21:02 174
static int singlePuzzleNr = 0;
90e6c797 sago007 2015-11-22 21:46 175
static std::string singlePuzzleFile;
89c4a3a6 sago007 2008-08-29 14:32 176
1572de2b sago007 2008-09-11 18:15 177
#if DEBUG
89c4a3a6 sago007 2008-08-29 14:32 178
//frame counter (fps)
89c4a3a6 sago007 2008-08-29 14:32 179
unsigned long int Frames, Ticks;
89c4a3a6 sago007 2008-08-29 14:32 180
char FPS[10];
89c4a3a6 sago007 2008-08-29 14:32 181
#endif
89c4a3a6 sago007 2008-08-29 14:32 182
56241205 sago007 2012-08-05 11:15 183
int verboseLevel = 0;
56241205 sago007 2012-08-05 11:15 184
89c4a3a6 sago007 2008-08-29 14:32 185
//keySetup
89c4a3a6 sago007 2008-08-29 14:32 186
int player1keys, player2keys;
89c4a3a6 sago007 2008-08-29 14:32 187
bool mouseplay1=false;  //The mouse works on the play field
89c4a3a6 sago007 2008-08-29 14:32 188
bool mouseplay2=false;  //Same for player2
89c4a3a6 sago007 2008-08-29 14:32 189
bool joyplay1=false;    //Player one uses the joypad
89c4a3a6 sago007 2008-08-29 14:32 190
bool joyplay2=false;    //Player two uses the joypad
89c4a3a6 sago007 2008-08-29 14:32 191
89c4a3a6 sago007 2008-08-29 14:32 192
//Stores the controls
89c4a3a6 sago007 2008-08-29 14:32 193
struct control
89c4a3a6 sago007 2008-08-29 14:32 194
{
078900fe sago007 2015-12-05 15:31 195
	SDL_Keycode up;
078900fe sago007 2015-12-05 15:31 196
	SDL_Keycode down;
078900fe sago007 2015-12-05 15:31 197
	SDL_Keycode left;
078900fe sago007 2015-12-05 15:31 198
	SDL_Keycode right;
078900fe sago007 2015-12-05 15:31 199
	SDL_Keycode change;
078900fe sago007 2015-12-05 15:31 200
	SDL_Keycode push;
89c4a3a6 sago007 2008-08-29 14:32 201
};
89c4a3a6 sago007 2008-08-29 14:32 202
593aeae4 sago007 2011-06-25 22:42 203
control keySettings[3];	//array to hold the controls (default and two custom)
89c4a3a6 sago007 2008-08-29 14:32 204
95bc02ff sago007 2009-03-15 02:46 205
#define KEYMENU_MAXWITH 4
95bc02ff sago007 2009-03-15 02:46 206
#define KEYMENU_MAXDEPTH 7
95bc02ff sago007 2009-03-15 02:46 207
89c4a3a6 sago007 2008-08-29 14:32 208
enum stageButton {SBdontShow, SBstageClear, SBpuzzleMode};
89c4a3a6 sago007 2008-08-29 14:32 209
30f910dd sago007 2010-11-10 21:02 210
static stageButton stageButtonStatus = SBdontShow;
89c4a3a6 sago007 2008-08-29 14:32 211
30f910dd sago007 2010-11-10 21:02 212
static const int buttonXsize = 120;
30f910dd sago007 2010-11-10 21:02 213
static const int buttonYsize = 40;
9050a50a sago007 2008-12-09 13:35 214
89c4a3a6 sago007 2008-08-29 14:32 215
struct ButtonCords
89c4a3a6 sago007 2008-08-29 14:32 216
{
c53e6443 sago007 2012-04-17 11:04 217
	int x;
c53e6443 sago007 2012-04-17 11:04 218
	int y;
c53e6443 sago007 2012-04-17 11:04 219
	int xsize;
c53e6443 sago007 2012-04-17 11:04 220
	int ysize;
89c4a3a6 sago007 2008-08-29 14:32 221
};
89c4a3a6 sago007 2008-08-29 14:32 222
c53e6443 sago007 2012-04-17 11:04 223
ButtonCords cordNextButton =
c53e6443 sago007 2012-04-17 11:04 224
{
c53e6443 sago007 2012-04-17 11:04 225
	cordNextButton.x = 3*bsize+(3*bsize-buttonXsize)/2,
c53e6443 sago007 2012-04-17 11:04 226
	cordNextButton.y = 10*bsize,
c53e6443 sago007 2012-04-17 11:04 227
	cordNextButton.xsize = buttonXsize,
c53e6443 sago007 2012-04-17 11:04 228
	cordNextButton.ysize = buttonYsize
6d48320c sago007 2009-03-28 17:06 229
};
89c4a3a6 sago007 2008-08-29 14:32 230
c53e6443 sago007 2012-04-17 11:04 231
ButtonCords cordRetryButton =
c53e6443 sago007 2012-04-17 11:04 232
{
c53e6443 sago007 2012-04-17 11:04 233
	cordRetryButton.x = (3*bsize-buttonXsize)/2,
c53e6443 sago007 2012-04-17 11:04 234
	cordRetryButton.y = 10*bsize,
c53e6443 sago007 2012-04-17 11:04 235
	cordRetryButton.xsize = buttonXsize,
c53e6443 sago007 2012-04-17 11:04 236
	cordRetryButton.ysize = buttonYsize
89c4a3a6 sago007 2008-08-29 14:32 237
};
6d48320c sago007 2009-03-28 17:06 238
eec83b7d sago007 2009-03-29 15:46 239
#endif
1970-01-01 00:00 240