git repos / blockattack-game

blame: source/code/BlockGame.hpp

normal view · raw

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