www.pudn.com > ATimeToKill.rar > winmain.cpp


#define WIN32_MEAN_AND_LEAN 
#define WIN32_EXTRA_LEAN 
 
/* 
	WINMAIN.CPP 
 
	Contains WinMain, the main windows function 
 
	Author: Kevin Hawkins 
	Date: 3/19/2001 
	Description: 
 
*/ 
 
 
#include  
 
#include "oglwindow.h"		// the OpenGL window class 
#include "vector.h" 
#include "engine.h"			// the engine's main class 
#include "simpengine.h" 
 
 
WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow) 
{ 
	int loopRet; 
	bool fscreen; 
	char str[700]; 
 
	CoInitialize(NULL); 
 
	if (!COGLWindow::RegisterWindow(hInst)) 
	{ 
		MessageBox(NULL, "Failed to register window class", "Error", MB_OK); 
		return -1; 
	} 
 
	CSimpEngine *engine = NULL; 
 
	sprintf(str, "Welcome to A Time to Kill!\n\nKeys:\nW - Forward\nS - Backward\nA - Left Strafe\nD - Right Strafe"); 
	strcat(str, "\n\nLeft mouse button fires rockets.\nMove mouse to look around\n\n"); 
	strcat(str, "Numpad '+' - Increase mouse sensitivity\nNumpad '-' - Decrease mouse sensitivity\n\n"); 
	strcat(str, "Created for OpenGL Game Programming\nby Kevin Hawkins and Dave Astle.\n"); 
		 
	MessageBox(NULL, str, "Welcome!", MB_OK); 
 
	sprintf(str, "A Time to Kill\n\n\nYou have 5 minutes to kill all of the enemies on the terrain using your searching skills\n"); 
	strcat(str, "and your rockets. Can you do it?"); 
	MessageBox(NULL, str, "Welcome!", MB_OK); 
 
	try 
	{	 
		if (MessageBox(NULL, "We are going to run in 800x600x16 mode, would you like to run in fullscreen?", "Fullscreen?", MB_YESNO) == IDYES) 
			fscreen = true; 
		else 
			fscreen = false; 
 
		engine = new CSimpEngine("OpenGL Game", fscreen, 800, 600, 16); 
 
		loopRet = engine->EnterMessageLoop(); 
 
		delete engine; 
 
		return loopRet; 
	} 
	catch(char *sz) 
	{	 
		MessageBox(NULL, sz, 0, 0); 
		delete engine; 
	} 
 
	CoUninitialize(); 
 
	return -1; 
}