//----------------------------------------------------------------- // Game Engine Object // C++ Header - GameEngine.h //----------------------------------------------------------------- #pragma once //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include #include "Resource.h" #define NUMBER_OF_TOGLLE_BUTTON 12 #define NUMBER_OF_BONDS 3 #define NUMBER_OF_CONTROLS 6 #define INORG_COMPOUNDS 26 #define ADDN_CONDITIONS 12 //----------------------------------------------------------------- // 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,WPARAM ); void MouseButtonUp(int x, int y, BOOL bLeft); void MouseMove(int x, int y); /*struct POINT{ int x; int y; };*/ struct OrgBond{ POINT start; POINT end; int iType; bool selected; int StartBondIndex; int EndBondIndex; }; struct OrgElement{ int x; int y; int iType; bool selected; OrgBond** bonds; int bondsCount; }; struct OrgChain{ int startElementIndex; int endElementIndex; OrgElement** elements; OrgBond** bonds; OrgChain** chains; int countElements; int countBonds; int countChains; int levels[16]; bool selected; }; struct OrgCompound{ POINT start; POINT end; POINT length; int elementsCount; int bondsCount; OrgElement** elements; OrgBond ** bonds; OrgChain * mainChain; char name[256]; bool selected; }; struct Link{ int elementIndex; char baseName[32]; char subName[32]; int level; bool noNumber; }; struct Entity{ int x; int y; int iType; }; struct Arrow{ POINT ptStart; POINT ptEnd; }; struct CompoundCollection{ POINT start; POINT end; POINT length; OrgCompound** compounds; int countCompounds; Entity ** inorgCompounds; int countInorgCompounds; Entity ** conditions; int countConditions; int iCursor; Arrow arrow; }; //----------------------------------------------------------------- // 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 selectedElement; int selectedBond; int selectedControl; int countCompounds; OrgElement **orgElements; OrgBond **orgBonds; int countElements; int countBonds; public: // 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); 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;} void Repaint(){ GamePaint(GetDC(GetWindow())); } int getSelectedElement(){return selectedElement;} void setSelectedElement(int selectedElement){GameEngine::selectedElement=selectedElement;} int getSelectedBond(){return selectedBond;} void setSelectedBond(int selectedBond){GameEngine::selectedBond=selectedBond;} int getSelectedControl(){return selectedControl;} void setSelectedControl(int selectedControl){GameEngine::selectedControl=selectedControl;} int getCountCompounds(){return countCompounds;} void setCountCompounds(int countCompounds){GameEngine::countCompounds=countCompounds;} OrgElement** getOrgElements(){return orgElements;} void setOrgElements(OrgElement** orgElement){GameEngine::orgElements=orgElement;} OrgBond** getOrgBonds(){return orgBonds;} void setOrgBonds(OrgBond** orgBond){GameEngine::orgBonds=orgBond;} int getCountElements(){return countElements;} void setCountElements(int countElements){GameEngine::countElements=countElements;} int getCountBonds(){return countBonds;} void setCountBonds(int countBonds){GameEngine::countBonds=countBonds;} };