console.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:4k
源码类别:

游戏

开发平台:

Visual C++

  1. #ifndef _ASIDER_TANK_ALPHA3_CONSOLE_H_
  2. #define _ASIDER_TANK_ALPHA3_CONSOLE_H_
  3. #include "msglist.h"
  4. #include "object.h"
  5. #include "mapinfo.h"
  6. #include "aigenerator.h"
  7. enum ConsoleStat { CONSTAT_NOTHING, CONSTAT_WAITCONNECT, CONSTAT_WAITMORE,
  8. CONSTAT_WAITBEGIN, CONSTAT_RUNNING, CONSTAT_WAITPLAYER,
  9. CONSTAT_WAITERROR, CONSTAT_ENDGAME };
  10. #define DEFTANKNUM 20
  11. #define DEFAINUM 4
  12. //-----------------------------------------------------------------------------
  13. // Console version
  14. //-----------------------------------------------------------------------------
  15. #define ASIDER_GAME_TANK_VER_ALPHA2 0x20030215
  16. #define ASIDER_GAME_TANK_VER_ALPHA3 0x20030325
  17. //-----------------------------------------------------------------------------
  18. // Error code
  19. //-----------------------------------------------------------------------------
  20. #define ERRCODE_NOERROR 0
  21. #define ERRCODE_UNKNOWN 1
  22. #define ERRCODE_ILLEGALSCREEN 2
  23. #define ERRCODE_UNABLELOADMAP 3
  24. #define ERRCODE_UNABLEDISPLAY 4
  25. #define ERRCODE_UNABLEFOUNDCMD 5
  26. //-----------------------------------------------------------------------------
  27. // Classes defined in this header file 
  28. //-----------------------------------------------------------------------------
  29. class Console;
  30. class ConsoleNet;
  31. //-----------------------------------------------------------------------------
  32. // Name: class Console
  33. // Desc: Class to handle all data of the game and control the operations
  34. // in a game cycle
  35. //-----------------------------------------------------------------------------
  36. class Console
  37. {
  38. protected:
  39. unsigned long con_version;
  40. unsigned int err_code;
  41. public:
  42. Console();
  43. ~Console();
  44. // Status function
  45. bool IsError() { return err_code != 0; }
  46. // Access functions
  47. unsigned long GetConsoleVer() { return con_version; }
  48. unsigned int GetError() { return err_code; }
  49. // Methods
  50. virtual void ErrorTrigger( unsigned int error );
  51. };
  52. //-----------------------------------------------------------------------------
  53. // Name: class Console
  54. // Desc: Class to handle all data of the game and control the operations
  55. // in a game cycle
  56. //-----------------------------------------------------------------------------
  57. class ConsoleNet : public Console
  58. {
  59. protected:
  60. DWORD m_dwStatus;
  61. unsigned int m_nPlayers;
  62. unsigned int m_nComputers;
  63. unsigned int m_nComPerTeam;
  64. int m_nLocal;
  65. bool m_bHomeTeam;
  66. int m_nNumTanks;
  67. int m_nNumRiver;
  68. CObjTank *m_ppTanks[DEFTANKNUM];
  69. CObjBullet *m_ppBullets[DEFTANKNUM];
  70. CAiGenerator m_ppAiGen[DEFAINUM];
  71. CObjBase *m_ppBases[2];
  72. CObjBlock *m_pRiver;
  73. CObjFood *m_pFood;
  74. int m_pProCounter[2];
  75. int m_nMsgCounter;
  76. bool *m_pMsgFlag;
  77. CMapInfo MapInfo;
  78. public:
  79. ConsoleNet();
  80. ~ConsoleNet();
  81. // Status function
  82. // Access functions
  83. bool IsHomeTeam() { return m_bHomeTeam; }
  84. // Creation/destruction methods
  85. bool CreateConsole( HWND hwnd, const char *mapname, bool hometeam );
  86. bool LoadMap( const char *mapname );
  87. bool RenderMap( bool hometeam );
  88. bool InitDisplay( HWND hwnd );
  89. bool InitSound( HWND hwnd );
  90. bool InitObjects();
  91. // Methods
  92. void CreateAICmd();
  93. void MsgProcessor( CMsgList *ml );
  94. void GameMain();
  95. // Screen methods
  96. bool RollBlockObjects(  CObjBlock *poblk, int num );
  97. void BlitTanks( CObjTank **pptks, int num );
  98. void BlitBullets( CObjBullet **ppbts, int num );
  99. bool BlitBases( CObjBase **ppbs, int num );
  100. void BlitFood();
  101. // Override methods
  102. void ErrorTrigger( unsigned int error );
  103. protected:
  104. int BulletsProc();
  105. int TanksProc();
  106. void FoodProc();
  107. };
  108. #endif // _ASIDER_TANK_ALPHA3_CONSOLE_H_