GameBoard.h
上传用户:royluo
上传日期:2007-01-05
资源大小:1584k
文件大小:4k
源码类别:

游戏

开发平台:

Visual C++

  1. /*****************************************************************************
  2. *                                                                             
  3. *   GameBoard.h
  4. *                                                                             
  5. *   Electrical Engineering Faculty - Software Lab                             
  6. *   Spring semester 1998                                                      
  7. *                                                                             
  8. *   Tanks game                                                                
  9. *                                                                             
  10. *   Module description: Implements the game board object.
  11. *                       
  12. *                                                                             
  13. *   Authors: Eran Yariv - 28484475                                           
  14. *            Moshe Zur  - 24070856                                           
  15. *                                                                            
  16. *                                                                            
  17. *   Date: 23/09/98                                                           
  18. *                                                                            
  19. ******************************************************************************/
  20. #if !defined _GAME_BOARD_H
  21. #define _GAME_BOARD_H
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif 
  25. #include <GameObject.h>
  26. #include <GameConsts.h>
  27. class CGameBoard : public CGameObject
  28. {
  29. public:
  30. CGameBoard();
  31. virtual ~CGameBoard();
  32.     void                GenerateBoard (UINT uRandSeed,          // Random seed
  33.                                        UINT uComplexityLevel    // Complexity level [1..20]
  34.                                       );
  35.     StateType           CalcState (DWORD dwCurTime);
  36.     CPoint &            GetPos();
  37.     ObjectHeightType    GetHeight();
  38.     HIMAGE              GetImage(); // Call after a call to GenerateBoard only!
  39.     CReaction           React(CGameObject *pTo);
  40.     GameObjectType      GetType();
  41.     CRect &             GetUpdateRectangle();
  42.     CSize &             GetDimensions();
  43.     BOOL                IsRectVacant(CRect&);   // return TRUE if rect is vacant
  44. private:
  45.     enum {  MAP_BLOCK_SCALE                     = 10,
  46.             MAP_X_CELLS                         = MAP_WIDTH / MAP_BLOCK_SCALE,
  47.             MAP_Y_CELLS                         = MAP_HEIGHT / MAP_BLOCK_SCALE,
  48.             DIRECTION_UP                        = 0x01,
  49.             DIRECTION_LEFT                      = 0x02,
  50.             DIRECTION_RIGHT                     = 0x04,
  51.             DIRECTION_DOWN                      = 0x08,
  52.             DIRECTION_UPLEFT                    = 0x10,
  53.             DIRECTION_UPRIGHT                   = 0x20,
  54.             DIRECTION_DOWNLEFT                  = 0x40,
  55.             DIRECTION_DOWNRIGHT                 = 0x80,
  56.          };
  57.     TerrainType         ReadMap (UINT x, UINT y);
  58.     void                WriteMap (UINT x, UINT y, TerrainType);
  59.     UINT                Rand (UINT uMax);
  60.     BOOL                PickWallSeed (UINT &x, UINT &y);
  61.     BYTE                GetNextWallBlockOptions (UINT x, UINT y);
  62.     void                PickNextWallBlock (UINT &x, UINT &y, BYTE bDirectionOptions);
  63.     void                ErectWalls (UINT uComplexityLevel);
  64.     void                PlaceObstacle (UINT uComplexityLevel, UINT uImageID, TerrainType);
  65.     BOOL                FindAndMarkBlockLocation (UINT &x, UINT &y, 
  66.                                                   UINT uBlocksWidth, UINT uBlocksHeight, TerrainType);
  67.     UINT                BlockSize (UINT uPixelSize);
  68.     BOOL                InBoard (UINT x, UINT y);
  69.     HIMAGE    m_hImage;
  70.     CRect     m_EmptyRect;  // To return at GetUpdateRectangle
  71.     BYTE     *m_pMap; 
  72.     BYTE      m_bPrevDir;
  73. };
  74. #include <GameBoard.inl>
  75. #endif