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

游戏

开发平台:

Visual C++

  1. /*****************************************************************************
  2. *                                                                             
  3. *   Tanks.h
  4. *                                                                             
  5. *   Electrical Engineering Faculty - Software Lab                             
  6. *   Spring semester 1998                                                      
  7. *                                                                             
  8. *   Tanks game                                                                
  9. *                                                                             
  10. *   Module description: Interface of the main application class.
  11. *                       
  12. *                                                                             
  13. *   Authors: Eran Yariv - 28484475                                           
  14. *            Moshe Zur  - 24070856                                           
  15. *                                                                            
  16. *                                                                            
  17. *   Date: 23/09/98                                                           
  18. *                                                                            
  19. ******************************************************************************/
  20. #if !defined(AFX_TANKS_H__22F0A6A5_E0C9_11D1_9738_E570871C4325__INCLUDED_)
  21. #define AFX_TANKS_H__22F0A6A5_E0C9_11D1_9738_E570871C4325__INCLUDED_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif // _MSC_VER >= 1000
  25. #ifndef __AFXWIN_H__
  26. #error include 'stdafx.h' before including this file for PCH
  27. #endif
  28. #include "resource.h" // main symbols
  29. #include <ImageManager.h>
  30. #include <ManouverSet.h>
  31. #include <KbdManager.h>
  32. #include <GameManager.h>
  33. #include <Timer.h>
  34. #include <MsgQueue.h>
  35. #include <CommManager.h>
  36. #include <SoundManager.h>
  37. // Registry sections
  38. #define     GAME_SETUP_SECTION      "GameSetup"
  39. #define     KEYBOARD_SECTION        "Keyboard mapping"
  40. #define     COMM_SECTION            "Communication setting"
  41. // Registry entries
  42. #define     TANK_TYPE_ENTRY         "TankType"
  43. #define     MAP_DIFF_ENTRY          "MapComplexity"
  44. #define     RIGHT_KEY_ENTRY         "Key-Right"
  45. #define     LEFT_KEY_ENTRY          "Key-Left"
  46. #define     FORWARD_KEY_ENTRY       "Key-Forward"
  47. #define     BACKWARD_KEY_ENTRY      "Key-Backward"
  48. #define     SHELL_KEY_ENTRY         "Key-Shell"    
  49. #define     BULLET_KEY_ENTRY        "Key-Bullet"
  50. #define     MINE_KEY_ENTRY          "Key-Mine"
  51. #define     AERIAL_KEY_ENTRY        "Key-Aerial"
  52. #define     PLAYER_NAME_ENTRY       "Player name"
  53. #define     IS_HOST_ENTRY           "Is Host"
  54. #define     CONNECTION_GUID_ENTRY   "Connection GUID"
  55. #define     MAX_RTT_ENTRY           "Max RTT (ms)"
  56. #define     MUTE_MODE_ENTRY         "Game Sound"
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CTanksApp:
  59. // See Tanks.cpp for the implementation of this class
  60. //
  61. class CTanksApp : public CWinApp
  62. {
  63. public:
  64. CTanksApp();
  65.     ~CTanksApp();
  66.     BOOL StartGameThreads ();
  67.     void EndGameThreads ();
  68.     // Persistence :
  69.     UINT GetStoredPreferedTankID ()
  70.         { return GetProfileInt (GAME_SETUP_SECTION, TANK_TYPE_ENTRY, 0); }
  71.     UINT GetStoredMapComplexity ()
  72.         { return GetProfileInt (GAME_SETUP_SECTION, MAP_DIFF_ENTRY, 10); }
  73.     UINT GetStoredRightKey (UINT uDefault)
  74.         { return GetProfileInt (KEYBOARD_SECTION, RIGHT_KEY_ENTRY, uDefault); }
  75.     BOOL SetStoredRightKey (UINT uKey)
  76.         { return WriteProfileInt (KEYBOARD_SECTION, RIGHT_KEY_ENTRY, uKey); }
  77.     UINT GetStoredLeftKey (UINT uDefault)
  78.         { return GetProfileInt (KEYBOARD_SECTION, LEFT_KEY_ENTRY, uDefault); }
  79.     BOOL SetStoredLeftKey (UINT uKey)
  80.         { return WriteProfileInt (KEYBOARD_SECTION, LEFT_KEY_ENTRY, uKey); }
  81.     UINT GetStoredForwardKey (UINT uDefault)
  82.         { return GetProfileInt (KEYBOARD_SECTION, FORWARD_KEY_ENTRY, uDefault); }
  83.     BOOL SetStoredForwardKey (UINT uKey)
  84.         { return WriteProfileInt (KEYBOARD_SECTION, FORWARD_KEY_ENTRY, uKey); }
  85.     UINT GetStoredBackwardKey (UINT uDefault)
  86.         { return GetProfileInt (KEYBOARD_SECTION, BACKWARD_KEY_ENTRY, uDefault); }
  87.     BOOL SetStoredBackwardKey (UINT uKey)
  88.         { return WriteProfileInt (KEYBOARD_SECTION, BACKWARD_KEY_ENTRY, uKey); }
  89.     UINT GetStoredShellKey (UINT uDefault)
  90.         { return GetProfileInt (KEYBOARD_SECTION, SHELL_KEY_ENTRY, uDefault); }
  91.     BOOL SetStoredShellKey (UINT uKey)
  92.         { return WriteProfileInt (KEYBOARD_SECTION, SHELL_KEY_ENTRY, uKey); }
  93.     UINT GetStoredBulletKey (UINT uDefault)
  94.         { return GetProfileInt (KEYBOARD_SECTION, BULLET_KEY_ENTRY, uDefault); }
  95.     BOOL SetStoredBulletKey (UINT uKey)
  96.         { return WriteProfileInt (KEYBOARD_SECTION, BULLET_KEY_ENTRY, uKey); }
  97.     UINT GetStoredMineKey (UINT uDefault)
  98.         { return GetProfileInt (KEYBOARD_SECTION, MINE_KEY_ENTRY, uDefault); }
  99.     BOOL SetStoredMineKey (UINT uKey)
  100.         { return WriteProfileInt (KEYBOARD_SECTION, MINE_KEY_ENTRY, uKey); }
  101.     UINT GetStoredAerialKey (UINT uDefault)
  102.         { return GetProfileInt (KEYBOARD_SECTION, AERIAL_KEY_ENTRY, uDefault); }
  103.     BOOL SetStoredAerialKey (UINT uKey)
  104.         { return WriteProfileInt (KEYBOARD_SECTION, AERIAL_KEY_ENTRY, uKey); }
  105.     CString GetStoredPlayerName ()
  106.         { return GetProfileString (COMM_SECTION, PLAYER_NAME_ENTRY, "Anonymous"); }
  107.     BOOL SetStoredPlayerName (CString strName)
  108.         { return WriteProfileString (COMM_SECTION, PLAYER_NAME_ENTRY, strName); }
  109.     BOOL GetStoredIsHostFlag ()
  110.         { return (0 != GetProfileInt (COMM_SECTION, IS_HOST_ENTRY, 1)); }
  111.     BOOL SetStoredIsHostFlag (UINT uKey)
  112.         { return WriteProfileInt (COMM_SECTION, IS_HOST_ENTRY, uKey); }
  113.     BOOL GetStoredMuteMode ()
  114.         { return (0 != GetProfileInt (GAME_SETUP_SECTION, MUTE_MODE_ENTRY, 1)); }
  115.     BOOL SetStoredMuteMode (BOOL bMuteMode)
  116.         { return WriteProfileInt (GAME_SETUP_SECTION, MUTE_MODE_ENTRY, bMuteMode); }
  117.     void SetMaxRTT (UINT uDefault)
  118.     { 
  119.         m_uMaxRTT = GetProfileInt (COMM_SECTION, MAX_RTT_ENTRY, uDefault); 
  120.         WriteProfileInt (COMM_SECTION, MAX_RTT_ENTRY, m_uMaxRTT);
  121.     }
  122.     UINT GetMaxRTT ()
  123.         { return m_uMaxRTT; }
  124.     BOOL GetStoredGUID (GUID *pGUID);
  125.     BOOL SetStoredGUID (GUID& GUID);
  126. void SetMapHWND (HWND h) {m_gHwndMap = h;}
  127. // Overrides
  128. // ClassWizard generated virtual function overrides
  129. //{{AFX_VIRTUAL(CTanksApp)
  130. public:
  131. virtual BOOL InitInstance();
  132. //}}AFX_VIRTUAL
  133. // Implementation
  134. //{{AFX_MSG(CTanksApp)
  135. //}}AFX_MSG
  136. DECLARE_MESSAGE_MAP()
  137. private:
  138.     BOOL                IsOnlyInstance ();
  139.     HANDLE              m_hSingleInstanceSemaphore;
  140.     UINT                m_uMaxRTT;       // Init from reg.when starting new game
  141. public:
  142.     CImageManager       m_gImageManager;
  143.     CManouverSet        m_gManouverSets[MAX_TANKS];
  144.     UINT                m_guRemoteTanksDirs[MAX_TANKS];
  145.     CKbdManager         m_gKbdManager;
  146.     CGameManager        m_gGameManager;
  147.     TIMER_CLASS         m_gTimer;
  148.     CMsgQueue           m_gIncomingMsgQueue;
  149.     CMsgQueue           m_gOutgoingMsgQueue;
  150.     CCommManager        m_gCommManager;
  151.     HWND                m_gHwndMap;
  152.     CDrawDib            m_gDrawDIB;      // DIB drawing mechanism
  153.     CSoundManager       m_gSoundManager;
  154. };
  155. #define TANKS_APP   ((CTanksApp*)AfxGetApp())
  156. /////////////////////////////////////////////////////////////////////////////
  157. //{{AFX_INSERT_LOCATION}}
  158. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  159. #endif // !defined(AFX_TANKS_H__22F0A6A5_E0C9_11D1_9738_E570871C4325__INCLUDED_)