コード例 #1
0
int main (int argc, char* argv[])
{
	CGame Game;
	Uint32 frameStart;
    Uint32 frameTime;

	Game.Init();

	// load the intro
	Game.ChangeState( CMainMenuState::Instance() );

	// main loop
	while ( Game.Running() )
	{
	    frameStart = SDL_GetTicks();

		Game.HandleEvents();
		Game.Update();
		Game.Render();

		frameTime = SDL_GetTicks() - frameStart;

        if (frameTime < DELAY_TIME)
        {
            SDL_Delay((int) (DELAY_TIME - frameTime));
        }
	}

	// cleanup the engine
	Game.Cleanup();

	return 0;
}
コード例 #2
0
ファイル: matejjon.cpp プロジェクト: jonatan1024/Battleship
int main() {
	initCurses();
	CGame game;
	game.Init();
	while(game.GameLoop()) {}
	stopCurses();
	return 0;
}
コード例 #3
0
ファイル: CGame.cpp プロジェクト: NojiriMisoten/OMTT
//*****************************************************************************
// クリエイト
//*****************************************************************************
CGame* CGame::Create(MODE_PHASE mode, LPDIRECT3DDEVICE9* pDevice)
{
	CGame* pGame = NULL;

	// 作成
	pGame = new CGame;

	// 初期化
	pGame->Init(mode, pDevice);

	return pGame;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: mar7cel/openpong
int main ( int argc, char** argv )
{
    game.Init();    //Spiel Initialisieren

    while (!pMenu->start)
    {
        game.Menu();    //Menu Starten

        //Solgange wie done == False ist läuft die Schleife
        while (!pFramework->done)
        {
            game.Play();     //Spiel laufen lassen
        }
    }
    cout << "Spiel Beendet !" << endl;
    return 0;
}
コード例 #5
0
ファイル: Main.cpp プロジェクト: wardh/ZeldaClone
void Init() 
{ 
	CGame myGame;
	    
	int version[] = { PRODUCTVER }; 
	std::string versionNumber;   
	 
	int count = sizeof(version) / sizeof(version[0]);  
	for (int i = 0; i < count; i++)
	{
		versionNumber += std::to_string(version[i]); 
		versionNumber += ",";
	} 
	versionNumber.pop_back();  

	myGame.Init(CharArrayToLPCWSTR(versionNumber.c_str())); 

}
コード例 #6
0
ファイル: WinMain.cpp プロジェクト: CSPshala/Bulletsponge
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	MSG		msg;	//	Generic message.
	HWND	hWnd;	//	Main Window Handle.

#ifdef _DEBUG
	//////////////// MEMORY LEAK STUFF FOR DEBUG MODE
	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	// this function call will set a breakpoint at the location of a leaked block
	// set the parameter to the identifier for a leaked block
	//	_CrtSetBreakAlloc(338);
#endif

	//	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->Init(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
ファイル: Main.cpp プロジェクト: cyberaa/Battle-City
/*
===========
WinMain
===========
*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;

    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(ICO_BC));
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(ICO_BC), ICO_BC, 16, 16, 0);

    if(!RegisterClassEx(&wc)) {
        MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    int X, Y;
        
    X = (GetSystemMetrics(SM_CXSCREEN) / 2) - (Game.ResolutionX / 2);
    Y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (Game.ResolutionY / 2);

    Game.Options->LoadOptions();
    if (Game.Options->fullscreen == 1) {
        hwnd = CreateWindowEx(
            0,
            g_szClassName,
            "Battle City",
            WS_POPUP,
            X, Y, Game.ResolutionX, Game.ResolutionY,
            NULL, NULL, hInstance, NULL);
    }

    else {
        Game.DDraw->XOff = 4;
        Game.DDraw->YOff = 30;
        hwnd = CreateWindowEx(
            0,
            g_szClassName,
            "Battle City",
            WS_DLGFRAME,
            X, Y, Game.ResolutionX + 7, Game.ResolutionY + 33,
            NULL, NULL, hInstance, NULL);
    }

    if(hwnd == NULL) {
        MessageBox(NULL, "Window Creation Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    Game.Init(hwnd, hInstance);

    while(GetMessage(&Msg, NULL, 0, 0) > 0) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    return (int)Msg.wParam;
}