GameBustOutWindow.h (4893B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 #ifndef __GAME_BUSTOUT_WINDOW_H__ 29 #define __GAME_BUSTOUT_WINDOW_H__ 30 31 class idGameBustOutWindow; 32 33 typedef enum { 34 POWERUP_NONE = 0, 35 POWERUP_BIGPADDLE, 36 POWERUP_MULTIBALL 37 } powerupType_t; 38 39 class BOEntity { 40 public: 41 bool visible; 42 43 idStr materialName; 44 const idMaterial * material; 45 float width, height; 46 idVec4 color; 47 idVec2 position; 48 idVec2 velocity; 49 50 powerupType_t powerup; 51 52 bool removed; 53 bool fadeOut; 54 55 idGameBustOutWindow * game; 56 57 public: 58 BOEntity(idGameBustOutWindow* _game); 59 virtual ~BOEntity(); 60 61 virtual void WriteToSaveGame( idFile *savefile ); 62 virtual void ReadFromSaveGame( idFile *savefile, idGameBustOutWindow* _game ); 63 64 void SetMaterial(const char* name); 65 void SetSize( float _width, float _height ); 66 void SetColor( float r, float g, float b, float a ); 67 void SetVisible( bool isVisible ); 68 69 virtual void Update( float timeslice, int guiTime ); 70 virtual void Draw(); 71 72 private: 73 }; 74 75 typedef enum { 76 COLLIDE_NONE = 0, 77 COLLIDE_DOWN, 78 COLLIDE_UP, 79 COLLIDE_LEFT, 80 COLLIDE_RIGHT 81 } collideDir_t; 82 83 class BOBrick { 84 public: 85 float x; 86 float y; 87 float width; 88 float height; 89 powerupType_t powerup; 90 91 bool isBroken; 92 93 BOEntity *ent; 94 95 public: 96 BOBrick(); 97 BOBrick( BOEntity *_ent, float _x, float _y, float _width, float _height ); 98 ~BOBrick(); 99 100 virtual void WriteToSaveGame( idFile *savefile ); 101 virtual void ReadFromSaveGame( idFile *savefile, idGameBustOutWindow *game ); 102 103 void SetColor( idVec4 bcolor ); 104 collideDir_t checkCollision( idVec2 pos, idVec2 vel ); 105 106 private: 107 }; 108 109 #define BOARD_ROWS 12 110 111 class idGameBustOutWindow : public idWindow { 112 public: 113 idGameBustOutWindow(idUserInterfaceLocal *gui); 114 ~idGameBustOutWindow(); 115 116 virtual void WriteToSaveGame( idFile *savefile ); 117 virtual void ReadFromSaveGame( idFile *savefile ); 118 119 virtual const char* HandleEvent(const sysEvent_t *event, bool *updateVisuals); 120 virtual void PostParse(); 121 virtual void Draw(int time, float x, float y); 122 virtual const char* Activate(bool activate); 123 virtual idWinVar * GetWinVarByName (const char *_name, bool winLookup = false, drawWin_t** owner = NULL); 124 125 idList<BOEntity*> entities; 126 127 private: 128 void CommonInit(); 129 void ResetGameState(); 130 131 void ClearBoard(); 132 void ClearPowerups(); 133 void ClearBalls(); 134 135 void LoadBoardFiles(); 136 void SetCurrentBoard(); 137 void UpdateGame(); 138 void UpdatePowerups(); 139 void UpdatePaddle(); 140 void UpdateBall(); 141 void UpdateScore(); 142 143 BOEntity * CreateNewBall(); 144 BOEntity * CreatePowerup( BOBrick *brick ); 145 146 virtual bool ParseInternalVar(const char *name, idTokenParser *src); 147 148 private: 149 150 idWinBool gamerunning; 151 idWinBool onFire; 152 idWinBool onContinue; 153 idWinBool onNewGame; 154 idWinBool onNewLevel; 155 156 float timeSlice; 157 bool gameOver; 158 159 int numLevels; 160 byte * levelBoardData; 161 bool boardDataLoaded; 162 163 int numBricks; 164 int currentLevel; 165 166 bool updateScore; 167 int gameScore; 168 int nextBallScore; 169 170 int bigPaddleTime; 171 float paddleVelocity; 172 173 float ballSpeed; 174 int ballsRemaining; 175 int ballsInPlay; 176 bool ballHitCeiling; 177 178 idList<BOEntity*> balls; 179 idList<BOEntity*> powerUps; 180 181 BOBrick *paddle; 182 idList<BOBrick*> board[BOARD_ROWS]; 183 }; 184 185 #endif //__GAME_BUSTOUT_WINDOW_H__