Пример #1
0
	bool Init() {

		Current = Structure::INTRO;

		//Inicializacion de SDL
		if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
			return false;

		//Inicializacion de Display
		if ((Display = SDL_SetVideoMode(1024, 768, 32,
				SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL)
			return false;

		//Inicializacion de ventanas
		if (!intro->Init())
			return false;
		if (!menu->Init())
			return false;
		if (!help->Init())
			return false;
		if (!ingame->Init())
			return false;
		if (!story->Init())
			return false;

		return true;
	}
Пример #2
0
void SceneCredits::initMenu()
{
	m_menu = new CCredits();

	int buttonCount = 0;
	const float HEIGHT_OFFSET = m_window_height * 0.1f;
	const Vector3 BUTTON_SIZE(m_window_width * 0.25f, m_window_height * 0.08f);

	// Menu creation
	Vector3 startPos = Vector3((m_window_width * 0.15f) - (BUTTON_SIZE.x * 0.5f), (m_window_height * 0.05f));// -(BUTTON_SIZE.y * 0.5f));

	Menu* newMenu = new Menu();
	newMenu->Init(Menu::MENU_CREDITS, NULL);
	// Button creation
	newMenu->AddButton(new UIButton(UIButton::BUTTON_RETURN_TO_MAIN_MENU, m_meshList[MESH_RETURN_TO_MAIN_MENU_OFF], m_meshList[MESH_RETURN_TO_MAIN_MENU_ON], startPos - Vector3(0.f, HEIGHT_OFFSET * buttonCount), BUTTON_SIZE));
	++buttonCount;

	m_menu->AddMenu(newMenu);

	m_menu->AssignCurrent(Menu::MENU_CREDITS, UIButton::BUTTON_RETURN_TO_MAIN_MENU);
}
Пример #3
0
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
	g_hInstance = hInstance;	// Store application handle
	g_bWindowed = true;			// Windowed mode or full-screen

	// Init the window
	InitWindow();

	// Use this msg structure to catch window messages
	MSG msg; 
	ZeroMemory(&msg, sizeof(msg));
	//perform the count for frames per second
	_int64 cntsPerSec = 0;
	QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);//perform function QueryPerformanceFrequency: returns a BOOL value; true if timer exist
	float secsPerCnt = 1.0f / (float)cntsPerSec; //typecast the long int into a float
	//create an int for prev time
	_int64 prevTimeStamp = 0;
	QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);

	//*************************************************************************
	// Initialize DirectX/Game here (call the Init method of your framwork)
	DXObj.Init(g_hWnd, g_hInstance, g_bWindowed);
	MenuObj.Init(g_hWnd, g_hInstance, g_bWindowed);
	//*************************************************************************

	// Main Windows/Game Loop
	while(msg.message != WM_QUIT)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		//begin current time stamp counter
		_int64 currTimeStamp = 0;
		//receive counter performance
		QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
		float dt = (currTimeStamp - prevTimeStamp)*secsPerCnt;
		if(MenuObj.GetState() == 0) // Intro movie
		{
				DXObj.Update(dt);
				if(DXObj.GetMovieState() == true)
				{
					MenuObj.SetState(1);
				}
		}
		if(MenuObj.GetState() == 1)
		{
				//menu
				MenuObj.Update();
				MenuObj.Draw();
		}
		if(MenuObj.GetState() == 2)
		{
				//options
			MenuObj.Update();
			MenuObj.Draw();
		}
		if(MenuObj.GetState() == 3)
		{
				//game
			if(!g_bIsEnabled)
			{
				PFObj.Init(g_hWnd, g_hInstance, g_bWindowed);
				g_bIsEnabled = true;
			}
				PFObj.Update(dt);
				PFObj.Draw();
				if(PFObj.GetMenuBool())
				{
					MenuObj.SetState(1);
				}
		}
		if(MenuObj.GetState() == 4)
		{
				//credits
			MenuObj.Update();
			MenuObj.Draw();
		}
		if(MenuObj.GetState() == 5)
		{
				//quit game
				DXObj.Shutdown();
				PostQuitMessage(0);
		}
		//*************************************************************************
		// This is where you call your DirectXFramework/Game render/update calls
		
		//MenuObj.Draw();
		//PSObj.Draw();
		//*************************************************************************
		//Prepare for the next iteration: The current time
		//stamp becomes the previous time stamp for the next iteration
		
		prevTimeStamp = currTimeStamp; 

	}

	//*************************************************************************
	//Shutdown DirectXFramework/Game here
	DXObj.Shutdown();

	//*************************************************************************

	// Unregister window
	UnregisterClass(WINDOW_TITLE, g_hInstance);

	// Return successful
	return 0;
}