int main(int argc, char* argv[]) { if (argc>1) { game.name_of_player = argv[1]; string letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for (int a=0;a<game.name_of_player.size();a++) { if (letters.find(game.name_of_player[a])==-1) { game.name_of_player = ""; break; } } } game.Begin(); game.Main(); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { srand((unsigned int)time(NULL)); ///////////////////////////////////////////// // Do any program wide Initialization here //_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //_CrtSetBreakAlloc(45755); ///////////////////////////////////////////// MSG msg; // Generic message. HWND hWnd; // Main Window Handle. // if in release mode set the exception filter to write out a dump file #ifndef _DEBUG SetUnhandledExceptionFilter(Handler); #endif // Don't let more than one instance of the application exist // // NOTE: Comment out the following section of code if your game needs to have more // than one instance running on the same computer (i.e. client/server) //////////////////////////////////////////////////////////////////////// if (!hPrevInstance) { if (CheckIfAlreadyRunning()) return FALSE; } //////////////////////////////////////////////////////////////////////// // Register the window class if (!RegisterWindowClass(hInstance)) return 0; // Create the window hWnd = MakeWindow(hInstance); if (!hWnd) return 0; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); ////////////////////////////////////////// // Initialize Game here ////////////////////////////////////////// CGame* pGame = CGame::GetInstance(); pGame->Initialize(hWnd,hInstance, g_nWINDOW_WIDTH, g_nWINDOW_HEIGHT, g_bIS_WINDOWED); ////////////////////////////////////////// // Enter main event loop while (TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Test if this is a quit if (msg.message == WM_QUIT) break; // Translate any accelerator keys TranslateMessage(&msg); // Send the message to the window proc DispatchMessage(&msg); } ////////////////////////////////// // Put Game Logic Here ////////////////////////////////// if(pGame->Main() == false) PostQuitMessage(0); ////////////////////////////////// } ///////////////////////////////////////// // Shutdown Game Here ///////////////////////////////////////// pGame->Shutdown(); ///////////////////////////////////////// // Unregister the window class UnregisterClass(g_szWINDOW_CLASS_NAME, hInstance); // Return to Windows like this. return (int)(msg.wParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR /*lpCmdLine*/, int nCmdShow) { MSG msg; // Generic message. HWND hWnd; // Main Window Handle. // Don't let more than one instance of the application exist // // NOTE: Comment out the following section of code if your game needs to have more // than one instance running on the same computer (i.e. client/server) //////////////////////////////////////////////////////////////////////// if (!hPrevInstance) { if (CheckIfAlreadyRunning()) return FALSE; } //////////////////////////////////////////////////////////////////////// SetUnhandledExceptionFilter(errorFunc); #ifdef _DEBUG short bufferWidth = 80; short bufferHeight = 300; short windowWidth = 80; short windowHeight = 24; // Set up the console window. CONSOLE_SCREEN_BUFFER_INFO coninfo; FILE *pFile; int conHandle; HANDLE stdHandle; SMALL_RECT window = {0,}; // Allocate console AllocConsole(); // reset console properties GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); coninfo.dwSize.Y = bufferHeight; coninfo.dwSize.X = bufferWidth; window.Left = 0; window.Top = 0; window.Right = windowWidth - 1; window.Bottom = windowHeight - 1; SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), true, &window); // Redirect standard output to the console window. stdHandle = GetStdHandle(STD_OUTPUT_HANDLE); conHandle = _open_osfhandle((intptr_t)stdHandle, _O_TEXT); pFile = _fdopen(conHandle, "w" ); *stdout = *pFile; setvbuf(stdout, NULL, _IONBF, 0); // unbuffered // Redirect standard input to console stdHandle = GetStdHandle(STD_INPUT_HANDLE); conHandle = _open_osfhandle((intptr_t)stdHandle, _O_TEXT); pFile = _fdopen(conHandle, "r"); *stdin = *pFile; setvbuf(stdin, NULL, _IONBF, 0); // unbuffered // Redirect standard error to the console window. stdHandle = GetStdHandle(STD_ERROR_HANDLE); conHandle = _open_osfhandle((intptr_t)stdHandle, _O_TEXT); pFile = _fdopen(conHandle, "w"); *stderr = *pFile; setvbuf(stderr, NULL, _IONBF, 0); // unbuffered // Allow C++ code to benefit from console redirection. // route cout, wcout, cin, wcin, wcerr, cerr, wclog & clog as well ios::sync_with_stdio(); #endif // Register the window class if (!RegisterWindowClass(hInstance)) return 0; // Create the window hWnd = MakeWindow(hInstance); if (!hWnd) return 0; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); ////////////////////////////////////////// // Initialize Game here ////////////////////////////////////////// //_CrtSetBreakAlloc(198); CGame* pGame = CGame::GetInstance(); pGame->Initialize(hWnd, hInstance, g_nWINDOW_WIDTH, g_nWINDOW_HEIGHT, g_bIS_WINDOWED); ////////////////////////////////////////// // Enter main event loop while (TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Test if this is a quit if (msg.message == WM_QUIT) break; // Translate any accelerator keys TranslateMessage(&msg); // Send the message to the window proc DispatchMessage(&msg); } ////////////////////////////////// // Put Game Logic Here ////////////////////////////////// if (pGame->Main() == false) { PostQuitMessage(0); break; } ////////////////////////////////// } ///////////////////////////////////////// // Shutdown Game Here ///////////////////////////////////////// pGame->Shutdown(); ///////////////////////////////////////// // Unregister the window class UnregisterClass(g_szWINDOW_CLASS_NAME, hInstance); // Return to Windows like this. return (int)(msg.wParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; // Generic message. HWND hWnd; // Main Window Handle. // Don't let more than one instance of the application exist // // NOTE: Comment out the following section of code if your game needs to have more // than one instance running on the same computer (i.e. client/server) //////////////////////////////////////////////////////////////////////// if (!hPrevInstance) { if (CheckIfAlreadyRunning()) return FALSE; } //////////////////////////////////////////////////////////////////////// // Register the window class if (!RegisterWindowClass(hInstance)) return 0; // Create the window hWnd = MakeWindow(hInstance); if (!hWnd) return 0; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); ////////////////////////////////////////// // Initialize Game here ////////////////////////////////////////// CGame* pGame = CGame::GetInstance(); pGame->Initialize( hWnd, hInstance, g_nWINDOW_WIDTH, g_nWINDOW_HEIGHT, g_bIS_WINDOWED ); ////////////////////////////////////////// // Enter main event loop while (TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Test if this is a quit if (msg.message == WM_QUIT) break; // Translate any accelerator keys TranslateMessage(&msg); // Send the message to the window proc DispatchMessage(&msg); } ////////////////////////////////// // Put Game Logic Here ////////////////////////////////// if( pGame->Main() == false ) PostQuitMessage(0); ////////////////////////////////// } ///////////////////////////////////////// // Shutdown Game Here ///////////////////////////////////////// pGame->Shutdown(); ///////////////////////////////////////// // Unregister the window class UnregisterClass(g_szWINDOW_CLASS_NAME, hInstance); // Return to Windows like this. return (int)(msg.wParam); }