コード例 #1
0
ファイル: main.cpp プロジェクト: akrutsinger/Cards
void Initialize() // must be called only once
{
	//do some initialization and create the regions in here

	SDL_WM_SetCaption("Scorpion", NULL); // Set the window title
	font1 = initFont("font/data/font1");
	font2 = initFont("font/data/font2");

	InitDeck(screen);
	Scorpion.Initialize(screen);

	//index 0: The Stock
 	Scorpion.CreateRegion(CRD_STOCK,
						CRD_VISIBLE|CRD_3D,
						0,
						0,
						CRD_OSYMBOL,
						(SCREEN_WIDTH / 2) - (CARDWIDTH / 2), 400,
						2, 2);

	//index 1-7: The tableau
	for(int i=1; i <= 7; i++){
		Scorpion.CreateRegion(CRD_TABLEAU,
							CRD_VISIBLE|CRD_FACEUP|CRD_DODRAG|CRD_DODROP,
							CRD_DOLOWER|CRD_DOKING,
							CRD_DRAGCARDS,
							CRD_HSYMBOL,
							(CARDWIDTH * (i - 1)) + (i * 35), 10,
							0, 25);
	}
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Brulogaz/gaz-engine
int main(int argc, char *argv[])
{	
	COpenGlDevice::Start(1024,768,0);
	CGame game;
	game.Initialize();

	game.PushState(new CGamePlayState());
	
	//Main Loop
	double loop = 0, nextTick = 0;
	float interpolation = 0;
	while (game.IsRunning())
	{
		//Constant Game Speed independent of Variable FPS
		//Physic running at 50 updates per seconds
		loop = 0;
		while( SDL_GetTicks() >= nextTick && loop < 10)
		{
			game.Input();
			game.Update();
			nextTick = SDL_GetTicks() +  1000/50;
			loop++;
		}

		interpolation = float( GetTickCount() + (1000/60) - nextTick )/ float(1000/60);
		game.Draw(interpolation);
		SDL_GL_SwapBuffers();
	}

	//Cleanup
	return 0;
}
コード例 #3
0
ファイル: gamecontroller.cpp プロジェクト: mahaserver/MHSVLC
// -----------------------------------------------------------------------------
// CGameController::StartGameL
// Intializes the Game and Starts the game loop.
// -----------------------------------------------------------------------------
//
void CGameController::StartGameL( CGame& aGame )
{    
    iGame = &aGame;   
    
    // Allow the game to initialize itself.
    // The opengl es state intialization is done here.
    aGame.Initialize( iWindow->Size().iWidth, iWindow->Size().iHeight );
    
    TTime currentTime;
    TTime lastTimeVisited;
    lastTimeVisited.HomeTime();    
        
    while( 1 ) // Loop until the Game wants to exit.
    {       
        // Process any pending tasks.
        // This runs any Active objects that are waiting for 
        // some processing. 
        // The CWsEventReceiver Active Object gets a chance to
        // run here (on a key event for example).
        ProcessBackgroundTasks( EFalse );
                
        // If the application is not in focus or is not visible.
        // Block until it regains focus.
        while( EFalse == iIsAppInFocus || EFalse == iIsVisible )
            ProcessBackgroundTasks( ETrue );
                
        // Get the current time.
        currentTime.HomeTime();       
        TTimeIntervalMicroSeconds dur 
                    = currentTime.MicroSecondsFrom( lastTimeVisited );                        
                
        // The game renders itself using opengl es apis.
        // A return value of EFalse signifies an exit from the game.
        // Pass in the time (in micro secs) elapsed since last call. 
        if( EFalse == aGame.RenderFrame( dur.Int64() ) )
        {
            break;
        }                                

        // Call eglSwapBuffers, which blits the graphics to the window.
        eglSwapBuffers( iEglDisplay, iEglSurface );    

        // To keep the background light on.
        if( !( ( iGame->GetCurrentFrame() )%100 ) )
        {
            User::ResetInactivityTime();
        }
        
        // Store the last time the Game was rendered.
        lastTimeVisited = currentTime;
    }
    
    // Cleanup.
    aGame.Cleanup();    
}
コード例 #4
0
ファイル: main.cpp プロジェクト: weimingtom/gal-demo
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd )
{

#ifdef _DEBUG
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 
#endif // _DEBUG
	
	CGame *game = CGame::GetInstance();
	
	if (!game->Initialize())
	{
		MessageBox(NULL, "³õʼ»¯Ê§°Ü!", "´íÎó", MB_OK | MB_ICONWARNING);
		return 1;
	}
	game->Start();
	game->Finalize();
	return 0;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: Fixtone/Ogre_HellHavenFx
void main(int argc, char **argv)
{
	try
	{
		CGame* theBestGame = new CGame();
		theBestGame->Initialize();
		theBestGame->Start();
		delete theBestGame;
	} 
	catch(Ogre::Exception& e ) 
	{
		MessageBoxA(NULL, e.what(),"CronoCasException : ", MB_OK | MB_ICONERROR | MB_TASKMODAL);
	} catch(...)
	{
		MessageBoxA(NULL, "Unhandled Exception","CronoCasException : ", MB_OK | MB_ICONERROR | MB_TASKMODAL);
	}

	exit(0);
}
コード例 #6
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);
}
コード例 #7
0
ファイル: WinMain.cpp プロジェクト: TheGoctor/falconfish-scd
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);
}
コード例 #8
0
ファイル: WinMain.cpp プロジェクト: SmegheadSev/fortisrenes3
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);
}