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