//----------------------------------------------------------------- // Game Engine Object // C++ Header - GameEngine.h //----------------------------------------------------------------- #pragma once //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include #include "Resource.h" //----------------------------------------------------------------- // Windows Function Declarations //----------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow); LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); //----------------------------------------------------------------- // Game Engine Function Declarations //----------------------------------------------------------------- BOOL GameInitialize(HINSTANCE hInstance); void GameStart(HWND hWindow); void GameEnd(); void GameActivate(HWND hWindow); void GameDeactivate(HWND hWindow); void GamePaint(HDC hDC); void GameCycle(); void HandleKeys(); void MouseButtonDown(int x, int y, BOOL bLeft); void MouseButtonUp(int x, int y, BOOL bLeft); void MouseMove(int x, int y); void Expand(); void Contract(); void ShowHome(); struct PosElements{ POINT ptStart; POINT ptEnd; char szName[64]; }; //----------------------------------------------------------------- // GameEngine Class //----------------------------------------------------------------- class GameEngine { protected: // Member Variables static GameEngine* m_pGameEngine; HINSTANCE m_hInstance; HWND m_hWindow; TCHAR m_szWindowClass[32]; TCHAR m_szTitle[32]; WORD m_wIcon, m_wSmallIcon; int m_iWidth, m_iHeight; int m_iFrameDelay; BOOL m_bSleep; HDC _hOffscreenDC; UINT idImages[9]; bool menuSystemOpened; bool menuSystemMouseDown; unsigned int WhoOpened; int iCmdShow; bool bButtonHold; bool bExercise; bool bHiding; bool bIsMenuExpanded; bool bMouseDown; bool isEnglish; bool isSoundOn; bool bSaveRecords; bool bSaveLastView; char szStudentName[128]; char szProfilePath[128]; char szLastLesson[128]; char szLastExercise[128]; char szRecordString[4];//not used void GetSettings(); bool SetSettings(); char szReadingFile[128]; public: void SetValuesForSettings(bool isEnglish,bool isSoundOn,bool bSaveRecords,bool bSaveLasttView, char *szStudentName); // Constructor(s)/Destructor GameEngine(HINSTANCE hInstance, LPTSTR szWindowClass, LPTSTR szTitle, WORD wIcon, WORD wSmallIcon, int iWidth = 640, int iHeight = 480); virtual ~GameEngine(); // General Methods static GameEngine* GetEngine() { return m_pGameEngine; }; BOOL Initialize(int iCmdShow); LRESULT HandleEvent(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT HandleEvent2(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam); void ErrorQuit(LPTSTR szErrorMsg); unsigned int WhoOpenedMenu(unsigned int iam=0){ unsigned int temp=WhoOpened; if(iam!=0) WhoOpened=iam; return WhoOpened; } // Accessor Methods HINSTANCE GetInstance() { return m_hInstance; }; HWND GetWindow() { return m_hWindow; }; void SetWindow(HWND hWindow) { m_hWindow = hWindow; }; LPTSTR GetTitle() { return m_szTitle; }; WORD GetIcon() { return m_wIcon; }; WORD GetSmallIcon() { return m_wSmallIcon; }; int GetWidth() { return m_iWidth; }; int GetHeight() { return m_iHeight; }; int GetFrameDelay() { return m_iFrameDelay; }; void SetFrameRate(int iFrameRate) { m_iFrameDelay = 1000 / iFrameRate; }; BOOL GetSleep() { return m_bSleep; }; void SetSleep(BOOL bSleep) { m_bSleep = bSleep; }; void setOffScreenDC(HDC _hOff){_hOffscreenDC=_hOff;} HDC getOffScreenDC(){return _hOffscreenDC;} UINT getIDImage(int x){ return idImages[x];} void SetManuOpen(bool bOpned){menuSystemOpened=bOpned;} void SetManuMouseDown(bool bMouseDown){menuSystemMouseDown=bMouseDown;} BOOL GetMenuOpen(){return menuSystemOpened;} BOOL GetMenuMouseDown(){return menuSystemMouseDown;} void InvalidateBuffer(){GamePaint(_hOffscreenDC);} void SetiCmdShow(int iCmdShow){GameEngine::iCmdShow=iCmdShow;} int GetiCmdShow(){return iCmdShow;} void SetButtonHold(bool bValue){bButtonHold=bValue;} bool IsButtonHold(){return bButtonHold;} void SetExercise(bool bValue){ if(bValue){ bExercise=bValue; Expand(); } else if(bExercise){ bExercise=bValue; Contract(); } } bool IsExercise(){return bExercise ;} void SetHiding(bool bValue){bHiding=bValue;} bool IsHiding(){return bHiding;} void SetMenuExpanded(bool bValue){bIsMenuExpanded=bValue;} bool IsMenuExpanded(){return bIsMenuExpanded;} void SetCmdMenuMouseDown(bool bValue){bMouseDown=bValue;} bool IsCmdMenuMouseDown(){return bMouseDown;} bool IsEnglish(){return isEnglish;} bool IsSoundOn(){return isSoundOn;} bool IsSaveRecords(){return bSaveRecords;} bool IsSaveLastView(){return bSaveLastView;} char* GetStudentName(){return szStudentName;} char* GetLastLesson(){return bSaveLastView?szLastLesson:NULL;} char* GetLastExercise(){return bSaveLastView?szLastExercise:NULL;} char* ReadRecords(){return bSaveRecords?szRecordString:NULL;} char * GetProfilePath(){return szProfilePath;} void SetRecord(char *cValue){strcpy(szRecordString,cValue);} void SetLast(){ if(*szReadingFile==0)return; if(IsExercise()){ strcpy(szLastExercise,szReadingFile); SetSettings(); } else{ strcpy(szLastLesson,szReadingFile); SetSettings(); } } void ReadingFile(char *cValue){strcpy(szReadingFile,cValue);} };