#include "Presentation.h" BOOL GameInitialize(HINSTANCE hInstance){ _pGame=new GameEngine(hInstance,"Reaction Simulator","Reaction Simulator",IDI_PRESENTER,IDI_PRESENTER,800,600); if(!_pGame) return false; _pGame->SetFrameRate(12); _hInstance=hInstance; bCaptured=false; return true; } void GameStart(HWND hWindow){ // Create the offscreen device context and bitmap HDC hDC=GetDC(hWindow); _hOffscreenDC = CreateCompatibleDC(hDC); _hOffscreenBitmap = CreateCompatibleBitmap(hDC,_pGame->GetWidth(), _pGame->GetHeight()); SelectObject(_hOffscreenDC, _hOffscreenBitmap); _pGame->setOffScreenDC(_hOffscreenDC); GameEngine::GetEngine()->setCountCompounds(0); sideBar=new CSideBar(20,20,200,560,200,560,IDB_TREE_BG_LEFTTOP); sideBar->setEnable(true); _pGame->SetSleep(TRUE); ReleaseDC(hWindow,hDC); } void GameEnd(){ // Cleanup the offscreen device context and bitmap DeleteObject(_hOffscreenBitmap); DeleteDC(_hOffscreenDC); //delete[] pGrid; delete _pGame; } void GamePaint(HDC hDC) { HBRUSH hOrangeBrush = CreateSolidBrush(RGB(255, 255, 255)); HBRUSH hBrush = (HBRUSH)SelectObject(_hOffscreenDC, hOrangeBrush); Rectangle(_hOffscreenDC,0,0,800,600); SelectObject(_hOffscreenDC, hBrush); DeleteObject(hOrangeBrush); sideBar->DrawScreen(_hOffscreenDC); BitBlt(hDC, 0, 0, _pGame->GetWidth(), _pGame->GetHeight(), _hOffscreenDC, 0, 0, SRCCOPY); } void GameCycle(){ HWND hWindow = _pGame->GetWindow(); HDC hDC = GetDC(hWindow); GamePaint(hDC); ReleaseDC(hWindow, hDC); } void MouseButtonDown(int x, int y, BOOL bLeft,WPARAM wParam){ sideBar->MouseButtonDown(x,y,bLeft,wParam); HWND hWindow=GameEngine::GetEngine()->GetWindow(); HDC hDC=GetDC(hWindow); GamePaint(hDC); ReleaseDC(hWindow,hDC); hwndPreviousCaptured=SetCapture(hWindow); bCaptured=true; } void MouseButtonUp(int x, int y, BOOL bLeft){ sideBar->MouseButtonUp(x,y,bLeft); HWND hWindow=GameEngine::GetEngine()->GetWindow(); HDC hDC=GetDC(hWindow); GamePaint(hDC); ReleaseDC(hWindow,hDC); if(bCaptured){ SetCapture(hwndPreviousCaptured); } } void MouseMove(int x, int y){ sideBar->MouseMove(x,y); } void GameActivate(HWND hWindow){ _pGame->SetSleep(FALSE); } void GameDeactivate(HWND hWindow){ _pGame->SetSleep(TRUE); } void HandleKeys(){}