DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
//#include "DXUT.h" #include "DarkPuzzle.h" #include "GameEngine.h" using namespace DarkBattle; #include "fcntl.h" #include "io.h" #include
#include "conio.h" namespace DarkBattle{ //init all the default values float GameEngine::SpotLightRange = 30.0f; float GameEngine::SpotLightRadius = 15.0f; float GameEngine::PointLightRange = 40.0f; float GameEngine::RunVelocity = 10.0f; float GameEngine::RunVelocityEpsilon = 1.0f; float GameEngine::RunAcceleration = 2.0f; float GameEngine::lightDirectionalDir[3] = {0.6f,0.2f,0.3f}; float GameEngine::RangeEpsilon = 0.1f; double GameEngine::PreferedFrameRate = 40; GameEngine::Mouse GameEngine::storedMouse = GameEngine::Mouse(); CRITICAL_SECTION GameEngine::cs_mousePos; void GameEngine::LightDirectionalDir(float vals[3]){ memcpy(GameEngine::lightDirectionalDir,vals,3*sizeof(float)); } IDirect3DDevice9* GetD3DDevice(){ return DXUTGetD3D9Device(); }; //GameLevel* theGameLevel = NULL; #ifdef _DEBUG FILE* fdebug; FILE* fdebugIn; #endif // _DEBUG #ifdef _DEBUG void GameEngine::initConsole(){ //int hConHandle; //long lStdHandle; //CONSOLE_SCREEN_BUFFER_INFO coninfo; ////FILE *fp; //// allocate a console for this app //AllocConsole(); //// set the screen buffer to be big enough to let us scroll text //GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), // &coninfo); //coninfo.dwSize.Y = 40; //SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), // coninfo.dwSize); //// redirect unbuffered STDOUT to the console //lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); //hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); //fdebug = _fdopen( hConHandle, "w" ); //*stdout = *fdebug; //setvbuf( stdout, NULL, _IONBF, 0 ); //// redirect unbuffered STDIN to the console //lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); //hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); //fdebugIn = _fdopen( hConHandle, "r" ); //*stdin = *fdebugIn; //setvbuf( stdin, NULL, _IONBF, 0 ); //ios::sync_with_stdio(); AllocConsole(); int hCrtIn; hCrtIn = _open_osfhandle((long) GetStdHandle(STD_INPUT_HANDLE), _O_TEXT ); assert(hCrtIn!=-1); fdebugIn = _fdopen( hCrtIn, "r" ); *stdin = *fdebugIn; setvbuf( fdebugIn, NULL, _IONBF, 0 ); std::cin.clear(); int hCrt; hCrt = _open_osfhandle( (long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT ); assert(hCrt!=-1); fdebug = _fdopen( hCrt, "w" ); *stdout = *fdebug; //uncomment this line for capturing all printf or cout outputs to stdout setvbuf( fdebug, NULL, _IONBF, 0 ); std::cout.clear(); DEBUG_OUTPUT("Debug console started!\n"); //char* aa; //fscanf(fdebugIn,"%s\n",&aa); //DEBUG_OUTPUT("%d",23); //DEBUG_OUTPUT("Hi!\n"); //myConsole = ConStream(); } #endif // _DEBUG GameEngine* GameEngine::theGameEngine = NULL; GameEngine::GameEngine(IDirect3DDevice9* pd3dDevice):GameScreen(pd3dDevice){ CDXUTIMEEditBox::Initialize( DXUTGetHWND() ); assert(theGameEngine==NULL); theGameEngine = this; InitializeCriticalSection(&cs_mousePos); this->pCurrentScreen = NULL; this->pOverlayUI = NULL; #ifdef _DEBUG initConsole(); #endif // _DEBUG pCurrentScreen = new GameLevel(pd3dDevice); //theGameLevel = (GameLevel*)pCurrentScreen; pOverlayUI = new GameUI(pd3dDevice); myEngine = new ScriptEngine(); myEngine->ReLoadConstants(); //TODO: init everything here //pCurrentScreen->OnCreateDevice(); ((GameLevel*)pCurrentScreen)->LoadContent(pd3dDevice,"level3"); }; GameEngine::~GameEngine(){ SAFE_DELETE(pCurrentScreen); SAFE_DELETE(pOverlayUI); SAFE_DELETE(myEngine); DeleteCriticalSection(&cs_mousePos); assert(theGameEngine!=NULL); theGameEngine = NULL; } void GameEngine::KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext ){ if (GameUI::GetInstance()->IsEditing()) return; if (bKeyDown){ switch(nChar){ case 'S': GameLevel::GetInstance()->controllableCharacter->Move(Character::Direction::DOWN); break; case 'W': GameLevel::GetInstance()->controllableCharacter->Move(Character::Direction::UP); break; case 'A': GameLevel::GetInstance()->controllableCharacter->Move(Character::Direction::LEFT); break; case 'D': GameLevel::GetInstance()->controllableCharacter->Move(Character::Direction::RIGHT); break; case VK_SPACE: GameLevel::GetInstance()->controllableCharacter->Jump(); break; case 'Q': GameLevel::GetInstance()->angle -= 90*DXUTGetElapsedTime(); break; case 'E': GameLevel::GetInstance()->angle += 90*DXUTGetElapsedTime(); break; case 'F': if (bAltDown){ DXUTToggleFullScreen(); } break; } } } void GameEngine::MouseProc( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext ){ float width = (float)DXUTGetD3D9BackBufferSurfaceDesc()->Width; float height = (float)DXUTGetD3D9BackBufferSurfaceDesc()->Height; //RECT rect = DXUTGetWindowClientRect(); //xPos -= rect.left; //yPos -= rect.top; EnterCriticalSection(&cs_mousePos); storedMouse.x = (float)(xPos-width/2)/width*2; storedMouse.y = (float)(yPos-height/2)/height*2; storedMouse.leftOld = storedMouse.leftButtonDown; storedMouse.rightOld = storedMouse.rightButtonDown; storedMouse.leftButtonDown = bLeftButtonDown; storedMouse.rightButtonDown = bRightButtonDown; LeaveCriticalSection(&cs_mousePos); if (bLeftButtonDown){ GameUI::GetInstance()->isEditing = false; } } GameEngine::Mouse GameEngine::GetMouseState(){ EnterCriticalSection(&cs_mousePos); Mouse ret = storedMouse; LeaveCriticalSection(&cs_mousePos); return ret; } void GameEngine::OnResetDevice(IDirect3DDevice9* pd3dDevice){ pOverlayUI->OnResetDevice(pd3dDevice); pCurrentScreen->OnResetDevice(pd3dDevice); } void GameEngine::OnFrameMove(float elapsedTime){ pCurrentScreen->OnFrameMove(elapsedTime); pOverlayUI->OnFrameMove(elapsedTime); //TODO: console input handling //if (kbhit()){ // char* str = new char[200]; // char* strHead = str; // char ch; // do{ // ch = getch(); // *str = ch; // str++; // }while (ch!='\n'); // *str = 0; // ReadConsoleInputA() // SAFE_DELETE_ARRAY(str); //} //INPUT_RECORD inputRecord; //DWORD eventRead; //PeekConsoleInputA(stdin,&inputRecord,1,&eventRead); //if (eventRead!=0){ // int aa; // aa=0; //} } void GameEngine::OnRender(IDirect3DDevice9* pd3dDevice){ HRESULT hr; // Clear the render target and the zbuffer V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0) ); // Render the scene if( SUCCEEDED( pd3dDevice->BeginScene() ) ) { pCurrentScreen->OnRender(pd3dDevice); pOverlayUI->OnRender(pd3dDevice); V( pd3dDevice->EndScene() ); } } void GameEngine::OnLostDevice(){ pCurrentScreen->OnLostDevice(); pOverlayUI->OnLostDevice(); } void GameEngine::SetNewScreen(GameScreen* newScreen){ //TODO: set new screen here delete pCurrentScreen; pCurrentScreen = newScreen; } }
GameEngine.cpp
Page URL
File URL
Prev
29/65
Next
Download
( 7 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.