git repos / blockattack-game

blame: source/code/global.hpp

normal view · raw

c53e6443 sago007 2012-04-17 11:04 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c4baf4ba sago007 2017-03-25 15:37 4
Copyright (C) 2005-2017 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
de81e07d sago007 2016-07-10 20:22 20
http://www.blockattack.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
c53e6443 sago007 2012-04-17 11:04 22
*/
099916fc sago007 2011-06-10 17:39 23
099916fc sago007 2011-06-10 17:39 24
#ifndef _GLOBAL_HPP
099916fc sago007 2011-06-10 17:39 25
#define	_GLOBAL_HPP
099916fc sago007 2011-06-10 17:39 26
f3a1637d sago007 2015-11-14 21:32 27
#include <memory>
1d2e2129 sago007 2015-12-23 15:41 28
#include "sago/SagoSpriteHolder.hpp"
c3b697c6 sago007 2016-02-07 17:30 29
#include "highscore.h"
59dcb571 sago007 2016-02-14 15:34 30
#include "sago/GameStateInterface.hpp"
c310f8a5 sago007 2017-03-25 16:05 31
#include "TextManager.hpp"
d450da8b sago007 2017-03-25 17:03 32
#include "ExplosionManager.hpp"
810e1c2f sago007 2018-03-28 09:40 33
#include "sago/SagoTextField.hpp"
a3a8b2b4 Poul Sander 2023-10-15 21:04 34
#include "sago/SagoTextBox.hpp"
3affd2d6 Poul Sander 2020-12-27 15:56 35
#include "ModInfo.hpp"
aaba4f1e Poul Sander 2023-07-25 13:34 36
#include "themes.hpp"
099916fc sago007 2011-06-10 17:39 37
9c062c1d Poul Sander 2022-01-15 14:48 38
//if SHAREDIR is not used we look in current directory
9c062c1d Poul Sander 2022-01-15 14:48 39
#ifndef SHAREDIR
9c062c1d Poul Sander 2022-01-15 14:48 40
#define SHAREDIR "."
9c062c1d Poul Sander 2022-01-15 14:48 41
#endif
9c062c1d Poul Sander 2022-01-15 14:48 42
9c062c1d Poul Sander 2022-01-15 14:48 43
#ifndef LOCALEDIR
9c062c1d Poul Sander 2022-01-15 14:48 44
#define LOCALEDIR SHAREDIR"/locale"
9c062c1d Poul Sander 2022-01-15 14:48 45
#endif
9c062c1d Poul Sander 2022-01-15 14:48 46
9c062c1d Poul Sander 2022-01-15 14:48 47
#ifndef PACKAGE
9c062c1d Poul Sander 2022-01-15 14:48 48
#define PACKAGE "blockattack_roftb"
9c062c1d Poul Sander 2022-01-15 14:48 49
#endif
9c062c1d Poul Sander 2022-01-15 14:48 50
9c062c1d Poul Sander 2022-01-15 14:48 51
#define MODLIST_TXT "mod_list.txt"
9c062c1d Poul Sander 2022-01-15 14:48 52
099916fc sago007 2011-06-10 17:39 53
void MainMenu();
ccee1ad0 Poul Sander 2019-03-13 18:39 54
void SafeModeMenu();
099916fc sago007 2011-06-10 17:39 55
void ResetFullscreen();
59dcb571 sago007 2016-02-14 15:34 56
void RunGameState(sago::GameStateInterface& state );
de81e07d sago007 2016-07-10 20:22 57
092bdebe sago007 2017-03-19 14:39 58
enum class Gametype { SinglePlayerEndless=0, SinglePlayerTimeTrial=1, StageClear=2, Puzzle=3, SinglePlayerVs=4, TwoPlayerTimeTrial=10, TwoPlayerVs=11, Replay=100  };
de81e07d sago007 2016-07-10 20:22 59
de81e07d sago007 2016-07-10 20:22 60
int runGame(Gametype gametype,int level);
96e759d9 sago007 2016-04-17 18:45 61
bool OpenDialogbox(int x, int y, std::string& name, const std::string& header);
f1708e5e sago007 2016-09-28 17:09 62
void DrawBackground(SDL_Renderer* target);
6e6e44b7 sago007 2016-10-18 15:30 63
void UpdateMouseCoordinates(const SDL_Event& event, int& mousex, int& mousey);
c4baf4ba sago007 2017-03-25 15:37 64
void DrawIMG(const sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y);
c4baf4ba sago007 2017-03-25 15:37 65
void DrawIMG_Bounded(const sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y, int minx, int miny, int maxx, int maxy);
099916fc sago007 2011-06-10 17:39 66
810e1c2f sago007 2018-03-28 09:40 67
void sagoTextSetHelpFont(sago::SagoTextField& field);
e7e189c7 sago007 2018-03-31 15:30 68
void sagoTextSetBlueFont(sago::SagoTextField& field);
810e1c2f sago007 2018-03-28 09:40 69
269c4c3f sago007 2019-04-27 19:31 70
const int SIXTEEN_NINE_WIDTH = 1364;
269c4c3f sago007 2019-04-27 19:31 71
const int FOUR_THREE_WIDTH = 1024;
269c4c3f sago007 2019-04-27 19:31 72
const int SCREEN_HIGHT = 768;
269c4c3f sago007 2019-04-27 19:31 73
5d36f49f Poul Sander 2023-07-11 22:38 74
const int BOARD_WIDTH = 300;
5d36f49f Poul Sander 2023-07-11 22:38 75
const int BOARD_HEIGHT = 600;
5d36f49f Poul Sander 2023-07-11 22:38 76
a3a8b2b4 Poul Sander 2023-10-15 21:04 77
struct ButtonCords
a3a8b2b4 Poul Sander 2023-10-15 21:04 78
{
a3a8b2b4 Poul Sander 2023-10-15 21:04 79
	int x;
a3a8b2b4 Poul Sander 2023-10-15 21:04 80
	int y;
a3a8b2b4 Poul Sander 2023-10-15 21:04 81
	int xsize;
a3a8b2b4 Poul Sander 2023-10-15 21:04 82
	int ysize;
a3a8b2b4 Poul Sander 2023-10-15 21:04 83
};
a3a8b2b4 Poul Sander 2023-10-15 21:04 84
a3a8b2b4 Poul Sander 2023-10-15 21:04 85
8f0c9d80 Poul Sander 2023-07-24 21:33 86
72383a9e sago007 2016-10-30 11:56 87
struct GlobalData {
72383a9e sago007 2016-10-30 11:56 88
	sago::SagoSprite bHighScore;
72383a9e sago007 2016-10-30 11:56 89
	sago::SagoSprite bBack;
72383a9e sago007 2016-10-30 11:56 90
	sago::SagoSprite bNext;
5e3bf517 sago007 2019-02-09 12:04 91
	sago::SagoSprite iLevelCheck;  //To the level select screen
c6c637cc sago007 2016-11-12 17:35 92
	sago::SagoSprite iLevelCheckBox;
c6c637cc sago007 2016-11-12 17:35 93
	sago::SagoSprite iLevelCheckBoxMarked;
c6c637cc sago007 2016-11-12 17:35 94
	sago::SagoSprite iCheckBoxArea;
5e3bf517 sago007 2019-02-09 12:04 95
	bool MusicEnabled;  //true if background music is enabled
5e3bf517 sago007 2019-02-09 12:04 96
	bool SoundEnabled;  //true if sound effects is enabled
5e3bf517 sago007 2019-02-09 12:04 97
	bool bFullscreen;  //true if game is running fullscreen
5e3bf517 sago007 2019-02-09 12:04 98
	std::string replayArgument;  //Name of the replay to play (if given as a commandline argument)
72383a9e sago007 2016-10-30 11:56 99
	std::string player1name;
72383a9e sago007 2016-10-30 11:56 100
	std::string player2name;
5e3bf517 sago007 2019-02-09 12:04 101
	SDL_Renderer *screen = nullptr;  //The whole screen;
524f188c sago007 2017-04-22 09:01 102
	sago::SoundHandler typingChunk;
72383a9e sago007 2016-10-30 11:56 103
	sago::SagoSprite mouse;
72383a9e sago007 2016-10-30 11:56 104
	bool highPriority = false;
548313f7 Poul Sander 2019-01-30 18:57 105
	bool NoSound = false;
b70b71e3 Poul Sander 2019-04-24 16:54 106
	bool alwaysSixteenNine = false;
72383a9e sago007 2016-10-30 11:56 107
	int verboseLevel = 0;
72383a9e sago007 2016-10-30 11:56 108
	std::unique_ptr<sago::SagoSpriteHolder> spriteHolder;
3affd2d6 Poul Sander 2020-12-27 15:56 109
	std::vector<std::string> modList;
3affd2d6 Poul Sander 2020-12-27 15:56 110
	ModInfo modinfo;
8f0c9d80 Poul Sander 2023-07-24 21:33 111
	Theme theme;
b70b71e3 Poul Sander 2019-04-24 16:54 112
c310f8a5 sago007 2017-03-25 16:05 113
	TextManager theTextManager;
099916fc sago007 2011-06-10 17:39 114
269c4c3f sago007 2019-04-27 19:31 115
	int xsize = FOUR_THREE_WIDTH;
269c4c3f sago007 2019-04-27 19:31 116
	int ysize = SCREEN_HIGHT;
20d77c6e sago007 2016-11-12 16:28 117
	int mousex = 0;
20d77c6e sago007 2016-11-12 16:28 118
	int mousey = 0;
a3a8b2b4 Poul Sander 2023-10-15 21:04 119
a3a8b2b4 Poul Sander 2023-10-15 21:04 120
	sago::SoundHandler applause;        //Applause, then the player is good
a3a8b2b4 Poul Sander 2023-10-15 21:04 121
	sago::SoundHandler boing;           //boing sound when clearing
a3a8b2b4 Poul Sander 2023-10-15 21:04 122
	sago::SoundHandler photoClick;      //clickSound
a3a8b2b4 Poul Sander 2023-10-15 21:04 123
	sago::SoundHandler counterChunk;         //When counting down
a3a8b2b4 Poul Sander 2023-10-15 21:04 124
	sago::SoundHandler counterFinalChunk;
a3a8b2b4 Poul Sander 2023-10-15 21:04 125
a3a8b2b4 Poul Sander 2023-10-15 21:04 126
	sago::SagoSprite garbageTL;			//the Garbage Blocks
a3a8b2b4 Poul Sander 2023-10-15 21:04 127
	sago::SagoSprite garbageT;
a3a8b2b4 Poul Sander 2023-10-15 21:04 128
	sago::SagoSprite garbageTR;
a3a8b2b4 Poul Sander 2023-10-15 21:04 129
	sago::SagoSprite garbageR;
a3a8b2b4 Poul Sander 2023-10-15 21:04 130
	sago::SagoSprite garbageBR;
a3a8b2b4 Poul Sander 2023-10-15 21:04 131
	sago::SagoSprite garbageB;
a3a8b2b4 Poul Sander 2023-10-15 21:04 132
	sago::SagoSprite garbageBL;
a3a8b2b4 Poul Sander 2023-10-15 21:04 133
	sago::SagoSprite garbageL;
a3a8b2b4 Poul Sander 2023-10-15 21:04 134
	sago::SagoSprite garbageFill;
a3a8b2b4 Poul Sander 2023-10-15 21:04 135
	sago::SagoSprite garbageM;
a3a8b2b4 Poul Sander 2023-10-15 21:04 136
	sago::SagoSprite garbageML;
a3a8b2b4 Poul Sander 2023-10-15 21:04 137
	sago::SagoSprite garbageMR;
a3a8b2b4 Poul Sander 2023-10-15 21:04 138
	sago::SagoSprite garbageGM;
a3a8b2b4 Poul Sander 2023-10-15 21:04 139
	sago::SagoSprite garbageGML;
a3a8b2b4 Poul Sander 2023-10-15 21:04 140
	sago::SagoSprite garbageGMR;
a3a8b2b4 Poul Sander 2023-10-15 21:04 141
	sago::SagoSprite transCover;        //The transperant block, covers the upcomming
a3a8b2b4 Poul Sander 2023-10-15 21:04 142
	sago::SagoSprite bSkip;
a3a8b2b4 Poul Sander 2023-10-15 21:04 143
	sago::SagoSprite bRetry;
a3a8b2b4 Poul Sander 2023-10-15 21:04 144
a3a8b2b4 Poul Sander 2023-10-15 21:04 145
	sago::SagoSprite blackLine;		//The seperator in stage clear
a3a8b2b4 Poul Sander 2023-10-15 21:04 146
	sago::SagoSprite stageBobble;	//The bobble instage clear
a3a8b2b4 Poul Sander 2023-10-15 21:04 147
	sago::SagoTextBox tbGameOver;
a3a8b2b4 Poul Sander 2023-10-15 21:04 148
	sago::SagoTextBox tbWinner;
a3a8b2b4 Poul Sander 2023-10-15 21:04 149
	sago::SagoTextBox tbDraw;
a3a8b2b4 Poul Sander 2023-10-15 21:04 150
	sago::SagoSprite iChainFrame;
a3a8b2b4 Poul Sander 2023-10-15 21:04 151
	//Animations:
a3a8b2b4 Poul Sander 2023-10-15 21:04 152
	sago::SagoSprite cursor;    //The animated cursor
a3a8b2b4 Poul Sander 2023-10-15 21:04 153
	sago::SagoSprite bomb;
a3a8b2b4 Poul Sander 2023-10-15 21:04 154
	sago::SagoSprite ready;      //Before the blocks fall
a3a8b2b4 Poul Sander 2023-10-15 21:04 155
	sago::SagoSprite explosion[4];   //Then a block explodes
a3a8b2b4 Poul Sander 2023-10-15 21:04 156
	//Animations end
a3a8b2b4 Poul Sander 2023-10-15 21:04 157
	sago::SagoSprite counter[3];    //Counts down from 3
a3a8b2b4 Poul Sander 2023-10-15 21:04 158
	sago::SagoSprite bricks[7];     //The bricks, saved in an array of pointers
a3a8b2b4 Poul Sander 2023-10-15 21:04 159
	sago::SagoSprite crossover;     //Cross the bricks that will be cleared soon
a3a8b2b4 Poul Sander 2023-10-15 21:04 160
	sago::SagoSprite balls[7];      //The balls (the small ones that jump around)
a3a8b2b4 Poul Sander 2023-10-15 21:04 161
a3a8b2b4 Poul Sander 2023-10-15 21:04 162
	sago::SagoSprite boardBackBack;
a3a8b2b4 Poul Sander 2023-10-15 21:04 163
a3a8b2b4 Poul Sander 2023-10-15 21:04 164
	ButtonCords cordNextButton;
a3a8b2b4 Poul Sander 2023-10-15 21:04 165
	ButtonCords cordRetryButton;
72383a9e sago007 2016-10-30 11:56 166
};
72383a9e sago007 2016-10-30 11:56 167
d450da8b sago007 2017-03-25 17:03 168
#include "BallManager.hpp"
d450da8b sago007 2017-03-25 17:03 169
72383a9e sago007 2016-10-30 11:56 170
extern GlobalData globalData;
a1072daf sago007 2016-02-20 12:47 171
099916fc sago007 2011-06-10 17:39 172
#endif	/* _GLOBAL_HPP */
099916fc sago007 2011-06-10 17:39 173
1970-01-01 00:00 174