| 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 |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
20 |
http://blockattack.sf.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 |
#include "SDL.h" |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
30 |
#include "replay.h" |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
31 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
32 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
33 |
//Some definitions |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
34 |
//The game is divided in frames. FALLTIME means the blocks will fall one block every FRAMELENGTH*FALLTIME millisecond |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
35 |
#define FRAMELENGTH 50 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
36 |
#define HANGTIME 40 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
37 |
#define FALLTIME 20 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
38 |
//Don't change the following, they are fundamental and later some functions are hardcoded |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
39 |
#define BLOCKFALL 10000 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
40 |
#define BLOCKWAIT 100000 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
41 |
#define BLOCKHANG 1000 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
42 |
#define GARBAGE 1000000 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
43 |
#define CHAINPLACE 10000000 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
44 |
#define NUMBEROFCHAINS 100 |
| 32c9b349 |
sago007 |
2008-11-20 18:14 |
45 |
|
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
46 |
#define ACTION_UPDATE 0 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
47 |
#define ACTION_MOVECURSOR 1 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
48 |
#define ACTION_MOVECURSORTO 2 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
49 |
#define ACTION_SWITCH 3 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
50 |
#define ACTION_PUSH 4 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
51 |
#define ACTION_CREATEGARBAGE 5 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
52 |
#define ACTION_CREATEGRAYGARBAGE 6 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
53 |
#define ACTION_GAMEOVER 7 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
54 |
#define ACTION_WIN 8 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
55 |
#define ACTION_DRAW 9 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
56 |
#define ACTION_GAMESPEED 10 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
57 |
#define ACTION_HANDICAP 11 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
58 |
#define ACTION_NEW 12 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
59 |
#define ACTION_NEWTT 13 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
60 |
#define ACTION_NEWVS 14 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
61 |
#define ACTION_STARTBLOCKS 15 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
62 |
#define ACTION_NOP 16 |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
63 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
64 |
//////////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
65 |
//The BloackGame class represents a board, score, time etc. for a single player/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
66 |
//////////////////////////////////////////////////////////////////////////////// |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
67 |
class BlockGame |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
68 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
69 |
private: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
70 |
int prevTowerHeight; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
71 |
bool bGarbageFallLeft; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
72 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
73 |
Uint32 nextGarbageNumber; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
74 |
Uint32 pushedPixelAt; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
75 |
Uint32 nrPushedPixel, nrFellDown, nrStops; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
76 |
bool garbageToBeCleared[7][30]; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
77 |
Uint32 lastAImove; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
78 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
79 |
Sint16 AI_LineOffset; //how many lines have changed since command |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
80 |
Uint32 hangTicks; //How many times have hang been decreased? |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
81 |
//int the two following index 0 may NOT be used (what the fuck did I meen?) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
82 |
Uint8 chainSize[NUMBEROFCHAINS]; //Contains the chains |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
83 |
bool chainUsed[NUMBEROFCHAINS]; //True if the chain is used |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
84 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
85 |
Uint32 nextRandomNumber; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
86 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
87 |
Uint16 rand2(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
88 |
int firstUnusedChain(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
89 |
|
| e1290bdf |
sago007 |
2010-10-25 19:56 |
90 |
//public: |
| 6b1dc7a6 |
sago007 |
2010-11-08 21:03 |
91 |
protected: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
92 |
int lastCounter; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
93 |
string strHolder; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
94 |
bool bDraw; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
95 |
bool bReplaying; //true if we are watching a replay |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
96 |
#if NETWORK |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
97 |
bool bNetworkPlayer; //must recieve packages from the net |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
98 |
bool bDisconnected; //The player has disconnected |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
99 |
#endif |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
100 |
unsigned int ticks; |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
101 |
Sint32 gameStartedAt; |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
102 |
Sint32 gameEndedAfter; //How long did the game last? |
| 50258544 |
sago007 |
2012-05-10 19:11 |
103 |
int replayIndex; //Used during replay to remeber how many replay actions we have performed. |
| 50258544 |
sago007 |
2012-05-10 19:11 |
104 |
int actionIndex; //Used during network to remeber how many actions we have sent. |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
105 |
int linesCleared; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
106 |
int TowerHeight; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
107 |
BlockGame *garbageTarget; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
108 |
Sint32 board[7][30]; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
109 |
int stop; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
110 |
int speedLevel; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
111 |
int pixels; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
112 |
int MovesLeft; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
113 |
bool timetrial, stageClear, vsMode, puzzleMode; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
114 |
int Level; //Only used in stageClear and puzzle (not implemented) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
115 |
int stageClearLimit; //stores number of lines user must clear to win |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
116 |
int topx, topy; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
117 |
int combo; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
118 |
int chain; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
119 |
int cursorx; //stores cursor position |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
120 |
int cursory; // -||- |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
121 |
double speed, baseSpeed; //factor for speed. Lower value = faster gameplay |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
122 |
Uint32 score; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
123 |
bool bGameOver; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
124 |
bool hasWonTheGame; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
125 |
int AI_MoveSpeed; //How often will the computer move? milliseconds |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
126 |
bool AI_Enabled; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
127 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
128 |
Uint32 handicap; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
129 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
130 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
131 |
int AIlineToClear; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
132 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
133 |
short AIstatus; //Status flags: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
134 |
//0: nothing, 2: clear tower, 3: clear horisontal, 4: clear vertical |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
135 |
//1: make more lines, 5: make 2 lines, 6: make 1 line |
| 6b1dc7a6 |
sago007 |
2010-11-08 21:03 |
136 |
|
| e1290bdf |
sago007 |
2010-10-25 19:56 |
137 |
public: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
138 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
139 |
char name[30]; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
140 |
Replay theReplay; //Stores the replay |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
141 |
|
| 0f031889 |
sago007 |
2012-05-01 19:57 |
142 |
public: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
143 |
//Constructor |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
144 |
BlockGame(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
145 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
146 |
//Deconstructor, never really used... game used to crash when called, cause of the way sBoard was created |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
147 |
//It should work now and can be used if we want to assign more players in network games that we need to free later |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
148 |
~BlockGame(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
149 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
150 |
void setGameSpeed(Uint8 globalSpeedLevel); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
151 |
void setHandicap(Uint8 globalHandicap); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
152 |
//Set the move speed of the AI based on the aiLevel parameter |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
153 |
//Also enables AI |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
154 |
void setAIlevel(Uint8 aiLevel); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
155 |
Uint8 getAIlevel(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
156 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
157 |
int GetScore(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
158 |
int GetHandicap(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
159 |
bool isGameOver(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
160 |
int GetTopX(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
161 |
int GetTopY(); |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
162 |
Sint32 GetGameStartedAt(); |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
163 |
Sint32 GetGameEndedAt(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
164 |
bool isTimeTrial(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
165 |
bool isStageClear(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
166 |
bool isVsMode(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
167 |
bool isPuzzleMode(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
168 |
int GetLinesCleared(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
169 |
int GetStageClearLimit(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
170 |
int GetChains(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
171 |
int GetPixels(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
172 |
int GetSpeedLevel(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
173 |
int GetTowerHeight(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
174 |
int GetCursorX(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
175 |
int GetCursorY(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
176 |
void MoveCursorTo(int x, int y); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
177 |
bool GetIsWinner(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
178 |
//Instead of creating new object new game is called, to prevent memory leaks |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
179 |
void NewGame(int tx, int ty, unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
180 |
void NewTimeTrialGame(int x,int y, unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
181 |
//Starts a new stage game, takes level as input! |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
182 |
void NewStageGame(int level, int tx, int ty,unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
183 |
void NewPuzzleGame(int level, int tx, int ty, unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
184 |
//Replay the current level |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
185 |
void retryLevel(unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
186 |
//Play the next level |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
187 |
void nextLevel(unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
188 |
//Starts new Vs Game (two Player) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
189 |
void NewVsGame(int tx, int ty, BlockGame *target,unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
190 |
//Starts new Vs Game (two Player) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
191 |
void NewVsGame(int tx, int ty, BlockGame *target, bool AI,unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
192 |
//We want to play the replay (must have been loaded beforehand) |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
193 |
void playReplay(int tx, int ty, unsigned int ticks, Replay r); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
194 |
void putStartBlocks(Uint32 n); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
195 |
//Creates garbage using a given wide and height |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
196 |
bool CreateGarbage(int wide, int height); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
197 |
//Creates garbage using a given wide and height |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
198 |
bool CreateGreyGarbage(); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
199 |
//prints "Game Over" and ends game |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
200 |
void SetGameOver(); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
201 |
bool GetAIenabled(); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
202 |
//Moves the cursor, receaves N,S,E or W as a char an moves as desired |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
203 |
void MoveCursor(char way); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
204 |
//switches the two blocks at the cursor position, unless game over |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
205 |
void SwitchAtCursor(); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
206 |
//Generates a new line and moves the field one block up (restart puzzle mode) |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
207 |
void PushLine(); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
208 |
void Update(int newtick); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
209 |
void PerformAction(int tick, int action, string param); |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
210 |
/** |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
211 |
* |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
212 |
* @param tick Tick of the action |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
213 |
* @param action The action |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
214 |
* @param param Params. |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
215 |
* @return 1 if an action was selected |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
216 |
*/ |
| 07383b8f |
sago007 |
2012-05-11 21:00 |
217 |
int GotAction(int &tick,int &action,string ¶m); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
218 |
#if NETWORK |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
219 |
//network play |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
220 |
void playNetwork(int tx, int ty,unsigned int ticks); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
221 |
#endif |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
222 |
//Prints "winner" and ends game |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
223 |
void setPlayerWon(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
224 |
//void SetGameOver(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
225 |
|
| 91886cae |
sago007 |
2008-09-12 16:28 |
226 |
#if NETWORK |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
227 |
//Sets disconnected: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
228 |
void setDisconnect(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
229 |
#endif |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
230 |
//Prints "draw" and ends the game |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
231 |
void setDraw(); |
| e1290bdf |
sago007 |
2010-10-25 19:56 |
232 |
private: |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
233 |
#if NETWORK |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
234 |
#define garbageStackSize 10 |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
235 |
Uint8 garbageStack[garbageStackSize][3]; //A garbage stack with space for 10 garbage blocks. 0=x,1=y,2=type |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
236 |
int garbageStackUsed; |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
237 |
|
| 0f031889 |
sago007 |
2012-05-01 19:57 |
238 |
void emptyGarbageStack(); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
239 |
bool pushGarbage(Uint8 width, Uint8 height, Uint8 type); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
240 |
public: |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
241 |
bool popGarbage(Uint8 *width, Uint8 *height, Uint8 *type); |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
242 |
private: |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
243 |
|
| 0f031889 |
sago007 |
2012-05-01 19:57 |
244 |
#endif |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
245 |
//Go in Demonstration mode, no movement |
| 0f031889 |
sago007 |
2012-05-01 19:57 |
246 |
void Demonstration(bool toggle); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
247 |
//Test if LineNr is an empty line, returns false otherwise. |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
248 |
bool LineEmpty(int lineNr); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
249 |
//Test if the entire board is empty (used for Puzzles) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
250 |
bool BoardEmpty(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
251 |
//Anything that the user can't move? In that case Game Over cannot occur |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
252 |
bool hasStaticContent(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
253 |
void putStartBlocks(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
254 |
//decreases hang for all hanging blocks and wait for waiting blocks |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
255 |
void ReduceStuff(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
256 |
//Clears garbage, must take one the lower left corner! |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
257 |
int GarbageClearer(int x, int y, int number, bool aLineToClear, int chain); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
258 |
//Marks garbage that must be cleared |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
259 |
int GarbageMarker(int x, int y); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
260 |
int FirstGarbageMarker(int x, int y); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
261 |
//Clear Blocks if 3 or more is alligned (naive implemented) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
262 |
void ClearBlocks(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
263 |
//Moves all peaces a spot down if possible |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
264 |
int FallBlock(int x, int y, int number); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
265 |
//Makes all Garbage fall one spot |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
266 |
void GarbageFall(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
267 |
//Makes the blocks fall (it doesn't test time, this must be done before hand) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
268 |
void FallDown(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
269 |
//Pushes a single pixel, so it appears to scrool |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
270 |
void PushPixels(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
271 |
//See how high the tower is, saved in integer TowerHeight |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
272 |
void FindTowerHeight(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
273 |
/////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
274 |
/////////////////////////// AI starts here! /////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
275 |
/////////////////////////////////////////////////////////////////////////// |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
276 |
//First the helpet functions: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
277 |
int nrOfType(int line, int type); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
278 |
int AIcolorToClear; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
279 |
//See if a combo can be made in this line |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
280 |
int horiInLine(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
281 |
bool horiClearPossible(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
282 |
//the Line Has Unmoveable Objects witch might stall the AI |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
283 |
bool lineHasGarbage(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
284 |
//Types 0..6 in line |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
285 |
int nrOfRealTypes(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
286 |
//See if there is a tower |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
287 |
bool ThereIsATower(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
288 |
double firstInLine1(int line); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
289 |
//returns the first coordinate of the block of type |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
290 |
double firstInLine(int line, int type); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
291 |
//There in the line shall we move |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
292 |
int closestTo(int line, int place); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
293 |
//The AI will remove a tower |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
294 |
void AI_ClearTower(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
295 |
//The AI will try to clear block horisontally |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
296 |
void AI_ClearHori(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
297 |
//Test if vertical clear is possible |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
298 |
bool veriClearPossible(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
299 |
//There in the line shall we move |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
300 |
int closestTo(int line, int type, int place); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
301 |
//The AI will try to clear blocks vertically |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
302 |
void AI_ClearVertical(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
303 |
bool firstLineCreated; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
304 |
void AI_Move(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
305 |
////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
306 |
///////////////////////////// AI ends here! ////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
307 |
////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
308 |
|
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
309 |
void ActionPerformed(int action, string param); |
| 79d3c1d3 |
sago007 |
2012-05-05 15:54 |
310 |
void PushLineInternal(); |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
311 |
//Updates evrything, if not called nothing happends |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
312 |
void Update(); |
| 6c9b4cd7 |
sago007 |
2012-05-01 19:34 |
313 |
void UpdateInternal(int newtick); |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
314 |
}; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
315 |
//////////////////////////////////////////////////////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
316 |
///////////////////////// BlockAttack class end //////////////////////////////// |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
317 |
//////////////////////////////////////////////////////////////////////////////// |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
318 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
319 |
#endif |
|
|
1970-01-01 00:00 |
320 |
|