| 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 bForward; //The "forward" button |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
49 |
#if NETWORK |
| 1d2e2129 |
sago007 |
2015-12-23 15:41 |
50 |
//static sago::SagoSprite bNetwork; |
| 1d2e2129 |
sago007 |
2015-12-23 15:41 |
51 |
//static sago::SagoSprite bConnect; |
| 1d2e2129 |
sago007 |
2015-12-23 15:41 |
52 |
//static sago::SagoSprite bHost; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
53 |
#endif |
| a3a8b2b4 |
Poul Sander |
2023-10-15 21:04 |
54 |
|
| 078900fe |
sago007 |
2015-12-05 15:31 |
55 |
SDL_Renderer *screen; //The whole screen; |
| a3a8b2b4 |
Poul Sander |
2023-10-15 21:04 |
56 |
|
| 38fa9b68 |
sago007 |
2016-03-12 08:46 |
57 |
const int bExitSize = 100; //height and width of the exit button |
| 38fa9b68 |
sago007 |
2016-03-12 08:46 |
58 |
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 |
59 |
|
| 524f188c |
sago007 |
2017-04-22 09:01 |
60 |
static sago::MusicHandler bgMusic; //backgroundMusic |
| 524f188c |
sago007 |
2017-04-22 09:01 |
61 |
static sago::MusicHandler highbeatMusic; //Background music with higher beat |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
62 |
|
| 30f910dd |
sago007 |
2010-11-10 21:02 |
63 |
static bool bMouseUp; //true if the mouse(1) is unpressed |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
64 |
static bool bMouseUp2; //true if the mouse(2) is unpressed |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
65 |
#if NETWORK |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
66 |
static bool bNetworkOpen; //Show the network menu |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
67 |
#endif |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
68 |
static bool bNearDeathPrev; //Near death status last time checked. |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
69 |
static bool puzzleLoaded; //true if the puzzle levels have been loaded |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
70 |
static bool drawBalls; //if true balls are drawed to the screen, this might lower framerate too much |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
71 |
|
| d450da8b |
sago007 |
2017-03-25 17:03 |
72 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
73 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
74 |
//global settings (reset everytime the game starts) |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
75 |
static Uint8 player1Speed=0; |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
76 |
static Uint8 player2Speed=0; |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
77 |
static bool player1AI=false; //Is AI enabled? |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
78 |
static bool player2AI=false; //Is AI enabled for player 2 (opponent in single player) |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
79 |
static Uint8 player1AIlevel=3; //What level is AI? 0 min, 6 max |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
80 |
static Uint8 player2AIlevel=3; |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
81 |
static const Uint8 AIlevels=7; //7 possible levels: 0..6 |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
82 |
static Uint8 player1handicap=0; |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
83 |
static Uint8 player2handicap=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
84 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
85 |
unsigned long int currentTime; //contains the current time, so we don't call SDL_GetTickets() too often... |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
86 |
|
| f87a08db |
Poul Sander |
2025-02-06 19:50 |
87 |
bool twoPlayers; //True if two playerImGui_ImplSDL2_ProcessEvent(&event);s are playing |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
88 |
|
| 43e3097e |
Poul Sander |
2023-10-22 08:50 |
89 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
90 |
|
| a7de0677 |
sago007 |
2016-04-29 16:54 |
91 |
//Allows starting the game with just a single puzzle. Mainly to be able to open a puzzle directly from the level editor |
| 1828235c |
Poul Sander |
2025-08-10 10:46 |
92 |
static bool singlePuzzle = false; |
| 1828235c |
Poul Sander |
2025-08-10 10:46 |
93 |
static bool editor = false; |
| f87a08db |
Poul Sander |
2025-02-06 19:50 |
94 |
static bool puzzleEditor = false; |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
95 |
static int singlePuzzleNr = 0; |
| 90e6c797 |
sago007 |
2015-11-22 21:46 |
96 |
static std::string singlePuzzleFile; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
97 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
98 |
#if DEBUG |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
99 |
//frame counter (fps) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
100 |
unsigned long int Frames, Ticks; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
101 |
char FPS[10]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
102 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
103 |
|
| 56241205 |
sago007 |
2012-08-05 11:15 |
104 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
105 |
//keySetup |
| f204c851 |
sago007 |
2016-04-16 14:42 |
106 |
const int player1keys = 0; |
| f204c851 |
sago007 |
2016-04-16 14:42 |
107 |
const int player2keys = 2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
108 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
109 |
//Stores the controls |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
110 |
struct control |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
111 |
{ |
| 078900fe |
sago007 |
2015-12-05 15:31 |
112 |
SDL_Keycode up; |
| 078900fe |
sago007 |
2015-12-05 15:31 |
113 |
SDL_Keycode down; |
| 078900fe |
sago007 |
2015-12-05 15:31 |
114 |
SDL_Keycode left; |
| 078900fe |
sago007 |
2015-12-05 15:31 |
115 |
SDL_Keycode right; |
| 078900fe |
sago007 |
2015-12-05 15:31 |
116 |
SDL_Keycode change; |
| 078900fe |
sago007 |
2015-12-05 15:31 |
117 |
SDL_Keycode push; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
118 |
}; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
119 |
|
| 593aeae4 |
sago007 |
2011-06-25 22:42 |
120 |
control keySettings[3]; //array to hold the controls (default and two custom) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
121 |
|
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
122 |
#define KEYMENU_MAXWITH 4 |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
123 |
#define KEYMENU_MAXDEPTH 7 |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
124 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
125 |
|
| 30f910dd |
sago007 |
2010-11-10 21:02 |
126 |
static const int buttonXsize = 120; |
| 30f910dd |
sago007 |
2010-11-10 21:02 |
127 |
static const int buttonYsize = 40; |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
128 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
129 |
|
| eec83b7d |
sago007 |
2009-03-29 15:46 |
130 |
#endif |
|
|
1970-01-01 00:00 |
131 |
|