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
89c4a3a6 sago007 2008-08-29 14:32 47
//All graphic in the game (as pointers):
1d2e2129 sago007 2015-12-23 15:41 48
sago::SagoSprite backgroundImage; //Stores the background image
1d2e2129 sago007 2015-12-23 15:41 49
static sago::SagoSprite backBoard;     //Stores the background to the board
1d2e2129 sago007 2015-12-23 15:41 50
static sago::SagoSprite bForward;      //The "forward" button
2f30c381 sago007 2008-09-14 13:08 51
#if NETWORK
1d2e2129 sago007 2015-12-23 15:41 52
//static sago::SagoSprite bNetwork;
1d2e2129 sago007 2015-12-23 15:41 53
//static sago::SagoSprite bConnect;
1d2e2129 sago007 2015-12-23 15:41 54
//static sago::SagoSprite bHost;
89c4a3a6 sago007 2008-08-29 14:32 55
#endif
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)
c6c637cc sago007 2016-11-12 17:35 74
1d2e2129 sago007 2015-12-23 15:41 75
static sago::SagoSprite boardBackBack;
1d2e2129 sago007 2015-12-23 15:41 76
static sago::SagoSprite garbageTL;			//the Garbage Blocks
1d2e2129 sago007 2015-12-23 15:41 77
static sago::SagoSprite garbageT;
1d2e2129 sago007 2015-12-23 15:41 78
static sago::SagoSprite garbageTR;
1d2e2129 sago007 2015-12-23 15:41 79
static sago::SagoSprite garbageR;
1d2e2129 sago007 2015-12-23 15:41 80
static sago::SagoSprite garbageBR;
1d2e2129 sago007 2015-12-23 15:41 81
static sago::SagoSprite garbageB;
1d2e2129 sago007 2015-12-23 15:41 82
static sago::SagoSprite garbageBL;
1d2e2129 sago007 2015-12-23 15:41 83
static sago::SagoSprite garbageL;
1d2e2129 sago007 2015-12-23 15:41 84
static sago::SagoSprite garbageFill;
1d2e2129 sago007 2015-12-23 15:41 85
static sago::SagoSprite garbageM;
1d2e2129 sago007 2015-12-23 15:41 86
static sago::SagoSprite garbageML;
1d2e2129 sago007 2015-12-23 15:41 87
static sago::SagoSprite garbageMR;
1d2e2129 sago007 2015-12-23 15:41 88
static sago::SagoSprite smiley[4];
1d2e2129 sago007 2015-12-23 15:41 89
static sago::SagoSprite garbageGM;
1d2e2129 sago007 2015-12-23 15:41 90
static sago::SagoSprite garbageGML;
1d2e2129 sago007 2015-12-23 15:41 91
static sago::SagoSprite garbageGMR;
1d2e2129 sago007 2015-12-23 15:41 92
static sago::SagoSprite transCover;        //The transperant block, covers the upcomming
1d2e2129 sago007 2015-12-23 15:41 93
static sago::SagoSprite bSkip;
1d2e2129 sago007 2015-12-23 15:41 94
static sago::SagoSprite bRetry;
38fa9b68 sago007 2016-03-12 08:46 95
static sago::SagoSprite bExit;
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
30f910dd sago007 2010-11-10 21:02 116
static bool editorMode = false;
30f910dd sago007 2010-11-10 21:02 117
static bool editorModeTest = false;
89c4a3a6 sago007 2008-08-29 14:32 118
d450da8b sago007 2017-03-25 17:03 119
89c4a3a6 sago007 2008-08-29 14:32 120
89c4a3a6 sago007 2008-08-29 14:32 121
//global settings (reset everytime the game starts)
30f910dd sago007 2010-11-10 21:02 122
static Uint8 player1Speed=0;
30f910dd sago007 2010-11-10 21:02 123
static Uint8 player2Speed=0;
30f910dd sago007 2010-11-10 21:02 124
static bool player1AI=false;		//Is AI enabled?
30f910dd sago007 2010-11-10 21:02 125
static bool player2AI=false;		//Is AI enabled for player 2 (opponent in single player)
30f910dd sago007 2010-11-10 21:02 126
static Uint8 player1AIlevel=3;		//What level is AI? 0 min, 6 max
30f910dd sago007 2010-11-10 21:02 127
static Uint8 player2AIlevel=3;
30f910dd sago007 2010-11-10 21:02 128
static const Uint8 AIlevels=7;		//7 possible levels: 0..6
30f910dd sago007 2010-11-10 21:02 129
static Uint8 player1handicap=0;
30f910dd sago007 2010-11-10 21:02 130
static Uint8 player2handicap=0;
89c4a3a6 sago007 2008-08-29 14:32 131
89c4a3a6 sago007 2008-08-29 14:32 132
unsigned long int currentTime;      //contains the current time, so we don't call SDL_GetTickets() too often...
89c4a3a6 sago007 2008-08-29 14:32 133
f72abf8b sago007 2010-01-16 20:00 134
bool twoPlayers;    //True if two players are playing
89c4a3a6 sago007 2008-08-29 14:32 135
89c4a3a6 sago007 2008-08-29 14:32 136
//Old Stage Clear Buble
30f910dd sago007 2010-11-10 21:02 137
static int oldBubleX, oldBubleY;
89c4a3a6 sago007 2008-08-29 14:32 138
a7de0677 sago007 2016-04-29 16:54 139
//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 140
static bool singlePuzzle = false; 
30f910dd sago007 2010-11-10 21:02 141
static int singlePuzzleNr = 0;
90e6c797 sago007 2015-11-22 21:46 142
static std::string singlePuzzleFile;
89c4a3a6 sago007 2008-08-29 14:32 143
1572de2b sago007 2008-09-11 18:15 144
#if DEBUG
89c4a3a6 sago007 2008-08-29 14:32 145
//frame counter (fps)
89c4a3a6 sago007 2008-08-29 14:32 146
unsigned long int Frames, Ticks;
89c4a3a6 sago007 2008-08-29 14:32 147
char FPS[10];
89c4a3a6 sago007 2008-08-29 14:32 148
#endif
89c4a3a6 sago007 2008-08-29 14:32 149
56241205 sago007 2012-08-05 11:15 150
89c4a3a6 sago007 2008-08-29 14:32 151
//keySetup
f204c851 sago007 2016-04-16 14:42 152
const int player1keys = 0;
f204c851 sago007 2016-04-16 14:42 153
const int player2keys = 2;
89c4a3a6 sago007 2008-08-29 14:32 154
89c4a3a6 sago007 2008-08-29 14:32 155
//Stores the controls
89c4a3a6 sago007 2008-08-29 14:32 156
struct control
89c4a3a6 sago007 2008-08-29 14:32 157
{
078900fe sago007 2015-12-05 15:31 158
	SDL_Keycode up;
078900fe sago007 2015-12-05 15:31 159
	SDL_Keycode down;
078900fe sago007 2015-12-05 15:31 160
	SDL_Keycode left;
078900fe sago007 2015-12-05 15:31 161
	SDL_Keycode right;
078900fe sago007 2015-12-05 15:31 162
	SDL_Keycode change;
078900fe sago007 2015-12-05 15:31 163
	SDL_Keycode push;
89c4a3a6 sago007 2008-08-29 14:32 164
};
89c4a3a6 sago007 2008-08-29 14:32 165
593aeae4 sago007 2011-06-25 22:42 166
control keySettings[3];	//array to hold the controls (default and two custom)
89c4a3a6 sago007 2008-08-29 14:32 167
95bc02ff sago007 2009-03-15 02:46 168
#define KEYMENU_MAXWITH 4
95bc02ff sago007 2009-03-15 02:46 169
#define KEYMENU_MAXDEPTH 7
95bc02ff sago007 2009-03-15 02:46 170
89c4a3a6 sago007 2008-08-29 14:32 171
30f910dd sago007 2010-11-10 21:02 172
static const int buttonXsize = 120;
30f910dd sago007 2010-11-10 21:02 173
static const int buttonYsize = 40;
9050a50a sago007 2008-12-09 13:35 174
89c4a3a6 sago007 2008-08-29 14:32 175
struct ButtonCords
89c4a3a6 sago007 2008-08-29 14:32 176
{
c53e6443 sago007 2012-04-17 11:04 177
	int x;
c53e6443 sago007 2012-04-17 11:04 178
	int y;
c53e6443 sago007 2012-04-17 11:04 179
	int xsize;
c53e6443 sago007 2012-04-17 11:04 180
	int ysize;
89c4a3a6 sago007 2008-08-29 14:32 181
};
89c4a3a6 sago007 2008-08-29 14:32 182
c53e6443 sago007 2012-04-17 11:04 183
ButtonCords cordNextButton =
c53e6443 sago007 2012-04-17 11:04 184
{
c53e6443 sago007 2012-04-17 11:04 185
	cordNextButton.x = 3*bsize+(3*bsize-buttonXsize)/2,
c53e6443 sago007 2012-04-17 11:04 186
	cordNextButton.y = 10*bsize,
c53e6443 sago007 2012-04-17 11:04 187
	cordNextButton.xsize = buttonXsize,
c53e6443 sago007 2012-04-17 11:04 188
	cordNextButton.ysize = buttonYsize
6d48320c sago007 2009-03-28 17:06 189
};
89c4a3a6 sago007 2008-08-29 14:32 190
c53e6443 sago007 2012-04-17 11:04 191
ButtonCords cordRetryButton =
c53e6443 sago007 2012-04-17 11:04 192
{
c53e6443 sago007 2012-04-17 11:04 193
	cordRetryButton.x = (3*bsize-buttonXsize)/2,
c53e6443 sago007 2012-04-17 11:04 194
	cordRetryButton.y = 10*bsize,
c53e6443 sago007 2012-04-17 11:04 195
	cordRetryButton.xsize = buttonXsize,
c53e6443 sago007 2012-04-17 11:04 196
	cordRetryButton.ysize = buttonYsize
89c4a3a6 sago007 2008-08-29 14:32 197
};
6d48320c sago007 2009-03-28 17:06 198
a11d40ec sago007 2018-03-31 18:04 199
static sago::SagoTextField player1name;
a11d40ec sago007 2018-03-31 18:04 200
static sago::SagoTextField player2name;
a11d40ec sago007 2018-03-31 18:04 201
static sago::SagoTextField player1time;
a11d40ec sago007 2018-03-31 18:04 202
static sago::SagoTextField player2time;
a11d40ec sago007 2018-03-31 18:04 203
static sago::SagoTextField player1score;
a11d40ec sago007 2018-03-31 18:04 204
static sago::SagoTextField player2score;
a11d40ec sago007 2018-03-31 18:04 205
static sago::SagoTextField player1chain;
a11d40ec sago007 2018-03-31 18:04 206
static sago::SagoTextField player2chain;
a11d40ec sago007 2018-03-31 18:04 207
static sago::SagoTextField player1speed;
a11d40ec sago007 2018-03-31 18:04 208
static sago::SagoTextField player2speed;
a11d40ec sago007 2018-03-31 18:04 209
a11d40ec sago007 2018-03-31 18:04 210
eec83b7d sago007 2009-03-29 15:46 211
#endif
1970-01-01 00:00 212