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