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"
a1072daf sago007 2016-02-20 12:47 29
#include "BlockGame.hpp"
c6bde3e3 sago007 2015-12-22 16:56 30
c6bde3e3 sago007 2015-12-22 16:56 31
89c4a3a6 sago007 2008-08-29 14:32 32
//main variables and constants
89c4a3a6 sago007 2008-08-29 14:32 33
89c4a3a6 sago007 2008-08-29 14:32 34
89c4a3a6 sago007 2008-08-29 14:32 35
//Animation lengths:
89c4a3a6 sago007 2008-08-29 14:32 36
#define READYTIME 500
89c4a3a6 sago007 2008-08-29 14:32 37
#define BOMBTIME 200
89c4a3a6 sago007 2008-08-29 14:32 38
#define CURSORTIME 200
89c4a3a6 sago007 2008-08-29 14:32 39
1d2e2129 sago007 2015-12-23 15:41 40
#ifndef SHAREDIR
1d2e2129 sago007 2015-12-23 15:41 41
#define SHAREDIR "."
1d2e2129 sago007 2015-12-23 15:41 42
#endif
1d2e2129 sago007 2015-12-23 15:41 43
56241205 sago007 2012-08-05 11:15 44
const char sharedir[] = SHAREDIR;
89c4a3a6 sago007 2008-08-29 14:32 45
89c4a3a6 sago007 2008-08-29 14:32 46
//All graphic in the game (as pointers):
1d2e2129 sago007 2015-12-23 15:41 47
sago::SagoSprite backgroundImage; //Stores the background image
1d2e2129 sago007 2015-12-23 15:41 48
static sago::SagoSprite backBoard;     //Stores the background to the board
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
1d2e2129 sago007 2015-12-23 15:41 55
static sago::SagoSprite blackLine;		//The seperator in stage clear
1d2e2129 sago007 2015-12-23 15:41 56
static sago::SagoSprite stageBobble;	//The bobble instage clear
078900fe sago007 2015-12-05 15:31 57
SDL_Renderer *screen;        //The whole screen;
1d2e2129 sago007 2015-12-23 15:41 58
static sago::SagoSprite iGameOver;     //The gameOver image
1d2e2129 sago007 2015-12-23 15:41 59
static sago::SagoSprite iWinner;		//the "winner" image
1d2e2129 sago007 2015-12-23 15:41 60
static sago::SagoSprite iDraw;			//the "draw" image
1d2e2129 sago007 2015-12-23 15:41 61
static sago::SagoSprite iLoser;		//the "loser" image
c1bd83fb sago007 2015-12-23 19:41 62
static sago::SagoSprite iChainFrame;
89c4a3a6 sago007 2008-08-29 14:32 63
//Animations:
1d2e2129 sago007 2015-12-23 15:41 64
static sago::SagoSprite cursor;    //The animated cursor
1d2e2129 sago007 2015-12-23 15:41 65
static sago::SagoSprite bomb;
1d2e2129 sago007 2015-12-23 15:41 66
static sago::SagoSprite ready;      //Before the blocks fall
1d2e2129 sago007 2015-12-23 15:41 67
static sago::SagoSprite explosion[4];   //Then a block explodes
89c4a3a6 sago007 2008-08-29 14:32 68
//Animations end
1d2e2129 sago007 2015-12-23 15:41 69
static sago::SagoSprite counter[3];    //Counts down from 3
c6bde3e3 sago007 2015-12-22 16:56 70
static sago::SagoSprite bricks[7];     //The bricks, saved in an array of pointers
1d2e2129 sago007 2015-12-23 15:41 71
static sago::SagoSprite crossover;     //Cross the bricks that will be cleared soon
1d2e2129 sago007 2015-12-23 15:41 72
static sago::SagoSprite balls[7];      //The balls (the small ones that jump around)
c6c637cc sago007 2016-11-12 17:35 73
1d2e2129 sago007 2015-12-23 15:41 74
static sago::SagoSprite boardBackBack;
1d2e2129 sago007 2015-12-23 15:41 75
static sago::SagoSprite garbageTL;			//the Garbage Blocks
1d2e2129 sago007 2015-12-23 15:41 76
static sago::SagoSprite garbageT;
1d2e2129 sago007 2015-12-23 15:41 77
static sago::SagoSprite garbageTR;
1d2e2129 sago007 2015-12-23 15:41 78
static sago::SagoSprite garbageR;
1d2e2129 sago007 2015-12-23 15:41 79
static sago::SagoSprite garbageBR;
1d2e2129 sago007 2015-12-23 15:41 80
static sago::SagoSprite garbageB;
1d2e2129 sago007 2015-12-23 15:41 81
static sago::SagoSprite garbageBL;
1d2e2129 sago007 2015-12-23 15:41 82
static sago::SagoSprite garbageL;
1d2e2129 sago007 2015-12-23 15:41 83
static sago::SagoSprite garbageFill;
1d2e2129 sago007 2015-12-23 15:41 84
static sago::SagoSprite garbageM;
1d2e2129 sago007 2015-12-23 15:41 85
static sago::SagoSprite garbageML;
1d2e2129 sago007 2015-12-23 15:41 86
static sago::SagoSprite garbageMR;
1d2e2129 sago007 2015-12-23 15:41 87
static sago::SagoSprite smiley[4];
1d2e2129 sago007 2015-12-23 15:41 88
static sago::SagoSprite garbageGM;
1d2e2129 sago007 2015-12-23 15:41 89
static sago::SagoSprite garbageGML;
1d2e2129 sago007 2015-12-23 15:41 90
static sago::SagoSprite garbageGMR;
1d2e2129 sago007 2015-12-23 15:41 91
static sago::SagoSprite transCover;        //The transperant block, covers the upcomming
1d2e2129 sago007 2015-12-23 15:41 92
static sago::SagoSprite bSkip;
1d2e2129 sago007 2015-12-23 15:41 93
static sago::SagoSprite bRetry;
38fa9b68 sago007 2016-03-12 08:46 94
static sago::SagoSprite bExit;
38fa9b68 sago007 2016-03-12 08:46 95
const int bExitSize = 100;  //height and width of the exit button
38fa9b68 sago007 2016-03-12 08:46 96
const int bExitOffset = 140; //pixels from the buttom right corner to the top left of the exit button
89c4a3a6 sago007 2008-08-29 14:32 97
925b7e58 sago007 2011-04-25 16:35 98
static NFont nf_standard_small_font;
89c4a3a6 sago007 2008-08-29 14:32 99
30f910dd sago007 2010-11-10 21:02 100
static Mix_Music *bgMusic;         //backgroundMusic
30f910dd sago007 2010-11-10 21:02 101
static Mix_Music *highbeatMusic;   //Background music with higher beat
30f910dd sago007 2010-11-10 21:02 102
static Mix_Chunk *boing;           //boing sound when clearing
30f910dd sago007 2010-11-10 21:02 103
static Mix_Chunk *applause;        //Applause, then the player is good
30f910dd sago007 2010-11-10 21:02 104
static Mix_Chunk *photoClick;      //clickSound
30f910dd sago007 2010-11-10 21:02 105
static Mix_Chunk *counterChunk;         //When counting down
30f910dd sago007 2010-11-10 21:02 106
static Mix_Chunk *counterFinalChunk;
89c4a3a6 sago007 2008-08-29 14:32 107
30f910dd sago007 2010-11-10 21:02 108
static bool bMouseUp;              //true if the mouse(1) is unpressed
30f910dd sago007 2010-11-10 21:02 109
static bool bMouseUp2;             //true if the mouse(2) is unpressed
2f30c381 sago007 2008-09-14 13:08 110
#if NETWORK
30f910dd sago007 2010-11-10 21:02 111
static bool bNetworkOpen;			//Show the network menu
89c4a3a6 sago007 2008-08-29 14:32 112
#endif
30f910dd sago007 2010-11-10 21:02 113
static bool bNearDeathPrev;                    //Near death status last time checked.
30f910dd sago007 2010-11-10 21:02 114
static bool puzzleLoaded;          //true if the puzzle levels have been loaded
30f910dd sago007 2010-11-10 21:02 115
static bool drawBalls;             //if true balls are drawed to the screen, this might lower framerate too much
30f910dd sago007 2010-11-10 21:02 116
30f910dd sago007 2010-11-10 21:02 117
static bool editorMode = false;
30f910dd sago007 2010-11-10 21:02 118
static bool editorModeTest = false;
89c4a3a6 sago007 2008-08-29 14:32 119
d450da8b sago007 2017-03-25 17:03 120
89c4a3a6 sago007 2008-08-29 14:32 121
89c4a3a6 sago007 2008-08-29 14:32 122
//global settings (reset everytime the game starts)
30f910dd sago007 2010-11-10 21:02 123
static Uint8 player1Speed=0;
30f910dd sago007 2010-11-10 21:02 124
static Uint8 player2Speed=0;
30f910dd sago007 2010-11-10 21:02 125
static bool player1AI=false;		//Is AI enabled?
30f910dd sago007 2010-11-10 21:02 126
static bool player2AI=false;		//Is AI enabled for player 2 (opponent in single player)
30f910dd sago007 2010-11-10 21:02 127
static Uint8 player1AIlevel=3;		//What level is AI? 0 min, 6 max
30f910dd sago007 2010-11-10 21:02 128
static Uint8 player2AIlevel=3;
30f910dd sago007 2010-11-10 21:02 129
static const Uint8 AIlevels=7;		//7 possible levels: 0..6
30f910dd sago007 2010-11-10 21:02 130
static Uint8 player1handicap=0;
30f910dd sago007 2010-11-10 21:02 131
static Uint8 player2handicap=0;
89c4a3a6 sago007 2008-08-29 14:32 132
89c4a3a6 sago007 2008-08-29 14:32 133
unsigned long int currentTime;      //contains the current time, so we don't call SDL_GetTickets() too often...
89c4a3a6 sago007 2008-08-29 14:32 134
f72abf8b sago007 2010-01-16 20:00 135
bool twoPlayers;    //True if two players are playing
89c4a3a6 sago007 2008-08-29 14:32 136
89c4a3a6 sago007 2008-08-29 14:32 137
//Old Stage Clear Buble
30f910dd sago007 2010-11-10 21:02 138
static int oldBubleX, oldBubleY;
89c4a3a6 sago007 2008-08-29 14:32 139
a7de0677 sago007 2016-04-29 16:54 140
//Allows starting the game with just a single puzzle. Mainly to be able to open a puzzle directly from the level editor
a7de0677 sago007 2016-04-29 16:54 141
static bool singlePuzzle = false; 
30f910dd sago007 2010-11-10 21:02 142
static int singlePuzzleNr = 0;
90e6c797 sago007 2015-11-22 21:46 143
static std::string singlePuzzleFile;
89c4a3a6 sago007 2008-08-29 14:32 144
1572de2b sago007 2008-09-11 18:15 145
#if DEBUG
89c4a3a6 sago007 2008-08-29 14:32 146
//frame counter (fps)
89c4a3a6 sago007 2008-08-29 14:32 147
unsigned long int Frames, Ticks;
89c4a3a6 sago007 2008-08-29 14:32 148
char FPS[10];
89c4a3a6 sago007 2008-08-29 14:32 149
#endif
89c4a3a6 sago007 2008-08-29 14:32 150
56241205 sago007 2012-08-05 11:15 151
89c4a3a6 sago007 2008-08-29 14:32 152
//keySetup
f204c851 sago007 2016-04-16 14:42 153
const int player1keys = 0;
f204c851 sago007 2016-04-16 14:42 154
const int player2keys = 2;
89c4a3a6 sago007 2008-08-29 14:32 155
89c4a3a6 sago007 2008-08-29 14:32 156
//Stores the controls
89c4a3a6 sago007 2008-08-29 14:32 157
struct control
89c4a3a6 sago007 2008-08-29 14:32 158
{
078900fe sago007 2015-12-05 15:31 159
	SDL_Keycode up;
078900fe sago007 2015-12-05 15:31 160
	SDL_Keycode down;
078900fe sago007 2015-12-05 15:31 161
	SDL_Keycode left;
078900fe sago007 2015-12-05 15:31 162
	SDL_Keycode right;
078900fe sago007 2015-12-05 15:31 163
	SDL_Keycode change;
078900fe sago007 2015-12-05 15:31 164
	SDL_Keycode push;
89c4a3a6 sago007 2008-08-29 14:32 165
};
89c4a3a6 sago007 2008-08-29 14:32 166
593aeae4 sago007 2011-06-25 22:42 167
control keySettings[3];	//array to hold the controls (default and two custom)
89c4a3a6 sago007 2008-08-29 14:32 168
95bc02ff sago007 2009-03-15 02:46 169
#define KEYMENU_MAXWITH 4
95bc02ff sago007 2009-03-15 02:46 170
#define KEYMENU_MAXDEPTH 7
95bc02ff sago007 2009-03-15 02:46 171
89c4a3a6 sago007 2008-08-29 14:32 172
30f910dd sago007 2010-11-10 21:02 173
static const int buttonXsize = 120;
30f910dd sago007 2010-11-10 21:02 174
static const int buttonYsize = 40;
9050a50a sago007 2008-12-09 13:35 175
89c4a3a6 sago007 2008-08-29 14:32 176
struct ButtonCords
89c4a3a6 sago007 2008-08-29 14:32 177
{
c53e6443 sago007 2012-04-17 11:04 178
	int x;
c53e6443 sago007 2012-04-17 11:04 179
	int y;
c53e6443 sago007 2012-04-17 11:04 180
	int xsize;
c53e6443 sago007 2012-04-17 11:04 181
	int ysize;
89c4a3a6 sago007 2008-08-29 14:32 182
};
89c4a3a6 sago007 2008-08-29 14:32 183
c53e6443 sago007 2012-04-17 11:04 184
ButtonCords cordNextButton =
c53e6443 sago007 2012-04-17 11:04 185
{
c53e6443 sago007 2012-04-17 11:04 186
	cordNextButton.x = 3*bsize+(3*bsize-buttonXsize)/2,
c53e6443 sago007 2012-04-17 11:04 187
	cordNextButton.y = 10*bsize,
c53e6443 sago007 2012-04-17 11:04 188
	cordNextButton.xsize = buttonXsize,
c53e6443 sago007 2012-04-17 11:04 189
	cordNextButton.ysize = buttonYsize
6d48320c sago007 2009-03-28 17:06 190
};
89c4a3a6 sago007 2008-08-29 14:32 191
c53e6443 sago007 2012-04-17 11:04 192
ButtonCords cordRetryButton =
c53e6443 sago007 2012-04-17 11:04 193
{
c53e6443 sago007 2012-04-17 11:04 194
	cordRetryButton.x = (3*bsize-buttonXsize)/2,
c53e6443 sago007 2012-04-17 11:04 195
	cordRetryButton.y = 10*bsize,
c53e6443 sago007 2012-04-17 11:04 196
	cordRetryButton.xsize = buttonXsize,
c53e6443 sago007 2012-04-17 11:04 197
	cordRetryButton.ysize = buttonYsize
89c4a3a6 sago007 2008-08-29 14:32 198
};
6d48320c sago007 2009-03-28 17:06 199
eec83b7d sago007 2009-03-29 15:46 200
#endif
1970-01-01 00:00 201