| 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 |
| 7ac8aa4b |
sago007 |
2016-02-22 19:25 |
20 |
http://www.blockattack.net |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
21 |
=========================================================================== |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
22 |
*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
23 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
24 |
#ifndef BLOCKGAME_HPP |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
25 |
#define BLOCKGAME_HPP 1 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
26 |
|
| 32c9b349 |
sago007 |
2008-11-20 18:14 |
27 |
#include "stats.h" |
| 32c9b349 |
sago007 |
2008-11-20 18:14 |
28 |
#include "common.h" |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
29 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
30 |
#define NUMBEROFCHAINS 100 |
| 69862ef6 |
sago007 |
2015-08-22 17:24 |
31 |
#define BLOCKWAIT 100000 |
| 69862ef6 |
sago007 |
2015-08-22 17:24 |
32 |
#define BLOCKHANG 1000 |
| 32c9b349 |
sago007 |
2008-11-20 18:14 |
33 |
|
| a1072daf |
sago007 |
2016-02-20 12:47 |
34 |
enum stageButton {SBdontShow, SBstageClear, SBpuzzleMode}; |
| a1072daf |
sago007 |
2016-02-20 12:47 |
35 |
|
| a1072daf |
sago007 |
2016-02-20 12:47 |
36 |
extern stageButton stageButtonStatus; |
| a1072daf |
sago007 |
2016-02-20 12:47 |
37 |
|
| a1072daf |
sago007 |
2016-02-20 12:47 |
38 |
//This is the size of the blocks. They are always 50. The internal logic calculates it that way |
| a1072daf |
sago007 |
2016-02-20 12:47 |
39 |
const int bsize = 50; |
| a1072daf |
sago007 |
2016-02-20 12:47 |
40 |
|
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
41 |
/** |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
42 |
* This struct defines the start conditions of the game |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
43 |
*/ |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
44 |
struct BlockGameStartInfo { |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
45 |
unsigned int ticks = 0; |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
46 |
bool timeTrial = false; |
| b256fda5 |
sago007 |
2016-02-21 16:21 |
47 |
///True means a stage clear game will be started. level must be set too. |
| b1fe2ae5 |
sago007 |
2016-02-21 16:01 |
48 |
bool stageClear = false; |
| b256fda5 |
sago007 |
2016-02-21 16:21 |
49 |
///True if puzzle mode. level must be set too. |
| b256fda5 |
sago007 |
2016-02-21 16:21 |
50 |
bool puzzleMode = false; |
| 83e4f8fe |
sago007 |
2016-02-22 19:22 |
51 |
///Single puzzle is used for the editor only. |
| 83e4f8fe |
sago007 |
2016-02-22 19:22 |
52 |
bool singlePuzzle = false; |
| b1fe2ae5 |
sago007 |
2016-02-21 16:01 |
53 |
int level = 0; |
| 1e5aff60 |
sago007 |
2016-02-21 18:23 |
54 |
bool AI = false; |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
55 |
/** |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
56 |
* True means that stats will be recorded. |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
57 |
* If AI is true then this will be overruled to false |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
58 |
*/ |
| 50cf6485 |
sago007 |
2016-03-21 19:11 |
59 |
bool recordStats = true; |
| 1e5aff60 |
sago007 |
2016-02-21 18:23 |
60 |
bool vsMode = false; |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
61 |
/** |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
62 |
* Set to true if we are fighting an AI. level should be the AI level we are fighting |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
63 |
*/ |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
64 |
bool vsAI = false; |
| 917dac61 |
sago007 |
2016-02-21 20:01 |
65 |
int startBlocks = -1; |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
66 |
int handicap = 0; |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
67 |
int gameSpeed = 0; |
| 1e5aff60 |
sago007 |
2016-02-21 18:23 |
68 |
}; |
| 1e5aff60 |
sago007 |
2016-02-21 18:23 |
69 |
|
| 1e5aff60 |
sago007 |
2016-02-21 18:23 |
70 |
struct GarbageStruct { |
| 1e5aff60 |
sago007 |
2016-02-21 18:23 |
71 |
bool greyGarbage = false; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
72 |
int width = 0; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
73 |
int height = 0; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
74 |
void setGarbage(int w, int h, bool g = false) { |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
75 |
greyGarbage = g; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
76 |
width = w; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
77 |
height = h; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
78 |
} |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
79 |
}; |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
80 |
|
| 4fb2e351 |
sago007 |
2016-05-19 19:27 |
81 |
struct BlockGameAction { |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
82 |
enum class Action {NONE, UPDATE, SET_DRAW, SET_WON, SET_GAME_OVER, MOVE, SWITCH, PUSH}; |
| 62b3f619 |
sago007 |
2016-05-20 07:01 |
83 |
Action action = Action::NONE; |
| e5a23912 |
sago007 |
2016-06-04 10:52 |
84 |
unsigned int tick = 0; //< Used for update |
| e5a23912 |
sago007 |
2016-06-04 10:52 |
85 |
char way = '\0'; //< The direction to move the cursor: 'N', 'E', 'S' or 'W' |
| 4fb2e351 |
sago007 |
2016-05-19 19:27 |
86 |
}; |
| 4fb2e351 |
sago007 |
2016-05-19 19:27 |
87 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
88 |
//////////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
89 |
//The BloackGame class represents a board, score, time etc. for a single player/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
90 |
//////////////////////////////////////////////////////////////////////////////// |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
91 |
class BlockGame |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
92 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
93 |
private: |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
94 |
int prevTowerHeight = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
95 |
bool bGarbageFallLeft = false; |
| a1072daf |
sago007 |
2016-02-20 12:47 |
96 |
bool singlePuzzle = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
97 |
|
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
98 |
int nextGarbageNumber = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
99 |
int pushedPixelAt = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
100 |
int nrPushedPixel = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
101 |
int nrFellDown = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
102 |
unsigned int nrStops = 0; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
103 |
bool garbageToBeCleared[7][30]; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
104 |
unsigned int lastAImove = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
105 |
|
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
106 |
int AI_LineOffset = 0; //how many lines have changed since command |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
107 |
int hangTicks = 0; //How many times have hang been decreased? |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
108 |
//int the two following index 0 may NOT be used (what the fuck did I meen?) |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
109 |
int chainSize[NUMBEROFCHAINS]{}; //Contains the chains |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
110 |
bool chainUsed[NUMBEROFCHAINS]{}; //True if the chain is used |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
111 |
|
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
112 |
unsigned int nextRandomNumber = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
113 |
int Level = 0; //Only used in stageClear and puzzle (not implemented) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
114 |
|
| 63c773dd |
sago007 |
2016-01-24 11:47 |
115 |
int rand2(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
116 |
int firstUnusedChain(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
117 |
|
| e1290bdf |
sago007 |
2010-10-25 19:56 |
118 |
//public: |
| 6b1dc7a6 |
sago007 |
2010-11-08 21:03 |
119 |
protected: |
| c98e567e |
sago007 |
2016-03-25 09:39 |
120 |
int lastCounter = 0; |
| 63c773dd |
sago007 |
2016-01-24 11:47 |
121 |
std::string strHolder; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
122 |
bool bDraw = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
123 |
unsigned int ticks = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
124 |
unsigned int gameStartedAt = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
125 |
unsigned int gameEndedAfter = 0; //How long did the game last? |
| c98e567e |
sago007 |
2016-03-25 09:39 |
126 |
int linesCleared = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
127 |
int TowerHeight = 0; |
| 63c773dd |
sago007 |
2016-01-24 11:47 |
128 |
int board[7][30]; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
129 |
int stop = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
130 |
int speedLevel = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
131 |
int pixels = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
132 |
int MovesLeft = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
133 |
bool timetrial = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
134 |
bool stageClear = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
135 |
bool vsMode = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
136 |
bool puzzleMode = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
137 |
int stageClearLimit = 0; //stores number of lines user must clear to win |
| c98e567e |
sago007 |
2016-03-25 09:39 |
138 |
int combo = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
139 |
int chain = 0; |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
140 |
int cursorx = 2; //stores cursor position |
| 87a0a1db |
sago007 |
2016-04-16 13:11 |
141 |
int cursory = 3; // -||- |
| d0c62e33 |
sago007 |
2016-04-02 15:18 |
142 |
int mouse_cursorx = -1; //Stores the mouse hold cursor. -1 if nothing is selected. |
| d0c62e33 |
sago007 |
2016-04-02 15:18 |
143 |
int mouse_cursory = -1; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
144 |
double speed = 0.0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
145 |
double baseSpeed = 0.0; //factor for speed. Lower value = faster gameplay |
| c98e567e |
sago007 |
2016-03-25 09:39 |
146 |
int score = 0; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
147 |
bool bGameOver = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
148 |
bool hasWonTheGame = false; |
| c98e567e |
sago007 |
2016-03-25 09:39 |
149 |
int AI_MoveSpeed = 0; //How often will the computer move? milliseconds |
| c98e567e |
sago007 |
2016-03-25 09:39 |
150 |
bool AI_Enabled = false; |
| 50cf6485 |
sago007 |
2016-03-21 19:11 |
151 |
bool recordStats = true; |
| ae5fb2bb |
sago007 |
2016-03-22 18:00 |
152 |
bool vsAI = false; //Set to true for single player vs |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
153 |
|
| c98e567e |
sago007 |
2016-03-25 09:39 |
154 |
int handicap = 0; |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
155 |
|
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
156 |
std::vector<GarbageStruct> garbageSendQueue; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
157 |
|
| c98e567e |
sago007 |
2016-03-25 09:39 |
158 |
int AIlineToClear = 0; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
159 |
|
| c98e567e |
sago007 |
2016-03-25 09:39 |
160 |
short AIstatus = 0; //Status flags: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
161 |
//0: nothing, 2: clear tower, 3: clear horisontal, 4: clear vertical |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
162 |
//1: make more lines, 5: make 2 lines, 6: make 1 line |
| 6b1dc7a6 |
sago007 |
2010-11-08 21:03 |
163 |
|
| e1290bdf |
sago007 |
2010-10-25 19:56 |
164 |
public: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
165 |
|
| 8f632c05 |
sago007 |
2015-08-22 16:21 |
166 |
std::string name; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
167 |
|
| 0f031889 |
sago007 |
2012-05-01 19:57 |
168 |
public: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
169 |
BlockGame(); |
| 87ac12e9 |
sago007 |
2016-04-09 18:47 |
170 |
virtual ~BlockGame() = default; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
171 |
|
| 63c773dd |
sago007 |
2016-01-24 11:47 |
172 |
int getAIlevel() const; |
| 229e212d |
sago007 |
2015-08-22 17:14 |
173 |
|
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
174 |
virtual void AddText(int x, int y, const std::string& text, int time) const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
175 |
virtual void AddBall(int x, int y, bool right, int color) const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
176 |
virtual void AddExplosion(int x, int y) const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
177 |
virtual void PlayerWonEvent() const {} |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
178 |
virtual void DrawEvent() const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
179 |
virtual void BlockPopEvent() const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
180 |
virtual void LongChainDoneEvent() const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
181 |
virtual void TimeTrialEndEvent() const {} |
| 313ecd1b |
sago007 |
2015-08-22 20:38 |
182 |
virtual void EndlessHighscoreEvent() const {} |
| 229e212d |
sago007 |
2015-08-22 17:14 |
183 |
|
| e5a23912 |
sago007 |
2016-06-04 10:52 |
184 |
void NewGame(const BlockGameStartInfo &s); |
| 4fb2e351 |
sago007 |
2016-05-19 19:27 |
185 |
void DoAction (const BlockGameAction& action); |
| 4fb2e351 |
sago007 |
2016-05-19 19:27 |
186 |
|
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
187 |
int GetScore() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
188 |
int GetHandicap() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
189 |
bool isGameOver() const; |
| 63c773dd |
sago007 |
2016-01-24 11:47 |
190 |
int GetGameStartedAt() const; |
| 63c773dd |
sago007 |
2016-01-24 11:47 |
191 |
int GetGameEndedAt() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
192 |
bool isTimeTrial() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
193 |
bool isStageClear() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
194 |
bool isVsMode() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
195 |
bool isPuzzleMode() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
196 |
int GetLinesCleared() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
197 |
int GetStageClearLimit() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
198 |
int GetChains() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
199 |
int GetPixels() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
200 |
int GetSpeedLevel() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
201 |
int GetTowerHeight() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
202 |
int GetCursorX() const; |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
203 |
int GetCursorY() const; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
204 |
void MoveCursorTo(int x, int y); |
| d0c62e33 |
sago007 |
2016-04-02 15:18 |
205 |
void GetMouseCursor(bool& pressed, int& x, int&y) const; |
| d0c62e33 |
sago007 |
2016-04-02 15:18 |
206 |
void MouseDown(int x, int y); //Send then the mouse is pressed |
| d0c62e33 |
sago007 |
2016-04-02 15:18 |
207 |
void MouseMove(int x); //Send then the mouse moves |
| d0c62e33 |
sago007 |
2016-04-02 15:18 |
208 |
void MouseUp(); //Send then the mouse goes up |
| 027b5cfd |
sago007 |
2015-08-23 14:27 |
209 |
bool GetIsWinner() const; |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
210 |
bool isSinglePuzzle() const; |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
211 |
int getLevel() const; |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
212 |
bool GetAIenabled() const; |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
213 |
bool IsNearDeath() const; |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
214 |
//Creates garbage using a given wide and height |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
215 |
bool CreateGarbage(int wide, int height); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
216 |
//Creates garbage using a given wide and height |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
217 |
bool CreateGreyGarbage(); |
| 3d12f4a8 |
sago007 |
2016-03-21 18:40 |
218 |
void PopSendGarbage(std::vector<GarbageStruct>& poppedData); |
| e1290bdf |
sago007 |
2010-10-25 19:56 |
219 |
private: |
| 5159dd90 |
sago007 |
2016-02-21 15:50 |
220 |
void NewGame(unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
221 |
//Test if LineNr is an empty line, returns false otherwise. |
| ca486238 |
sago007 |
2015-08-23 15:12 |
222 |
bool LineEmpty(int lineNr) const; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
223 |
//Test if the entire board is empty (used for Puzzles) |
| ca486238 |
sago007 |
2015-08-23 15:12 |
224 |
bool BoardEmpty() const; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
225 |
//Anything that the user can't move? In that case Game Over cannot occur |
| ca486238 |
sago007 |
2015-08-23 15:12 |
226 |
bool hasStaticContent() const; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
227 |
void putStartBlocks(); |
| 917dac61 |
sago007 |
2016-02-21 20:01 |
228 |
void putStartBlocks(int n); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
229 |
//decreases hang for all hanging blocks and wait for waiting blocks |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
230 |
void ReduceStuff(); |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
231 |
void setGameSpeed(int globalSpeedLevel); |
| 3e7b8813 |
sago007 |
2016-02-22 19:45 |
232 |
void setHandicap(int globalHandicap); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
233 |
//Clears garbage, must take one the lower left corner! |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
234 |
int GarbageClearer(int x, int y, int number, bool aLineToClear, int chain); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
235 |
//Marks garbage that must be cleared |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
236 |
int GarbageMarker(int x, int y); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
237 |
int FirstGarbageMarker(int x, int y); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
238 |
//Clear Blocks if 3 or more is alligned (naive implemented) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
239 |
void ClearBlocks(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
240 |
//Moves all peaces a spot down if possible |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
241 |
int FallBlock(int x, int y, int number); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
242 |
//Makes all Garbage fall one spot |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
243 |
void GarbageFall(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
244 |
//Makes the blocks fall (it doesn't test time, this must be done before hand) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
245 |
void FallDown(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
246 |
//Pushes a single pixel, so it appears to scrool |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
247 |
void PushPixels(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
248 |
//See how high the tower is, saved in integer TowerHeight |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
249 |
void FindTowerHeight(); |
| c9226e8d |
sago007 |
2016-06-04 10:17 |
250 |
//Generates a new line and moves the field one block up (restart puzzle mode) |
| c9226e8d |
sago007 |
2016-06-04 10:17 |
251 |
void PushLine(); |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
252 |
//prints "Game Over" and ends game |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
253 |
void SetGameOver(); |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
254 |
//Moves the cursor, receaves N,S,E or W as a char an moves as desired |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
255 |
void MoveCursor(char way); |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
256 |
//switches the two blocks at the cursor position, unless game over |
| b58caa17 |
sago007 |
2016-06-04 10:32 |
257 |
void SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
258 |
/////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
259 |
/////////////////////////// AI starts here! /////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
260 |
/////////////////////////////////////////////////////////////////////////// |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
261 |
//First the helpet functions: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
262 |
int nrOfType(int line, int type); |
| ca31a27a |
sago007 |
2016-04-16 21:29 |
263 |
int AIcolorToClear = 0; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
264 |
//See if a combo can be made in this line |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
265 |
int horiInLine(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
266 |
bool horiClearPossible(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
267 |
//the Line Has Unmoveable Objects witch might stall the AI |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
268 |
bool lineHasGarbage(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
269 |
//Types 0..6 in line |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
270 |
int nrOfRealTypes(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
271 |
//See if there is a tower |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
272 |
bool ThereIsATower(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
273 |
double firstInLine1(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
274 |
//returns the first coordinate of the block of type |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
275 |
double firstInLine(int line, int type); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
276 |
//There in the line shall we move |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
277 |
int closestTo(int line, int place); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
278 |
//The AI will remove a tower |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
279 |
void AI_ClearTower(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
280 |
//The AI will try to clear block horisontally |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
281 |
void AI_ClearHori(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
282 |
//Test if vertical clear is possible |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
283 |
bool veriClearPossible(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
284 |
//There in the line shall we move |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
285 |
int closestTo(int line, int type, int place); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
286 |
//The AI will try to clear blocks vertically |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
287 |
void AI_ClearVertical(); |
| ca31a27a |
sago007 |
2016-04-16 21:29 |
288 |
bool firstLineCreated = 0; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
289 |
void AI_Move(); |
| 52d3ef2e |
sago007 |
2016-03-22 19:30 |
290 |
////////////////////////////////////////////////////////////////// |
| 52d3ef2e |
sago007 |
2016-03-22 19:30 |
291 |
///////////////////////////// AI ends here! ////////////////////// |
| a1072daf |
sago007 |
2016-02-20 12:47 |
292 |
////////////////////////////////////////////////////////////////// |
| 6d6b2788 |
sago007 |
2016-02-21 18:51 |
293 |
//Set the move speed of the AI based on the aiLevel parameter |
| 6d6b2788 |
sago007 |
2016-02-21 18:51 |
294 |
void setAIlevel(int aiLevel); |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
295 |
void PushLineInternal(); |
| 07f5b3f3 |
sago007 |
2016-05-19 19:37 |
296 |
//Prints "winner" and ends game |
| 07f5b3f3 |
sago007 |
2016-05-19 19:37 |
297 |
void setPlayerWon(); |
| 07f5b3f3 |
sago007 |
2016-05-19 19:37 |
298 |
//Prints "draw" and ends the game |
| 07f5b3f3 |
sago007 |
2016-05-19 19:37 |
299 |
void setDraw(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
300 |
//Updates evrything, if not called nothing happends |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
301 |
void Update(); |
| 80b830cd |
sago007 |
2012-08-19 17:51 |
302 |
void UpdateInternal(unsigned int newtick); |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
303 |
}; |
| fde1f2dd |
sago007 |
2016-02-21 15:24 |
304 |
|
| c1785ec5 |
sago007 |
2016-02-21 16:07 |
305 |
//Play the next level |
| c1785ec5 |
sago007 |
2016-02-21 16:07 |
306 |
void nextLevel(BlockGame& g, unsigned int ticks); |
| fde1f2dd |
sago007 |
2016-02-21 15:24 |
307 |
//Replay the current level |
| fde1f2dd |
sago007 |
2016-02-21 15:24 |
308 |
void retryLevel(BlockGame& g, unsigned int ticks); |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
309 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
310 |
#endif |
|
|
1970-01-01 00:00 |
311 |
|