コード例 #1
0
ファイル: main.cpp プロジェクト: CMcLaine92/The-Exile
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, int cmdShow)
{
	//Dump File
	#if !NICK_STATE
		SetUnhandledExceptionFilter(CrashDumpToFile);
	#endif

	// Memory Leak Detection //
	#if _DEBUG
		_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
		_CrtSetBreakAlloc(-1);
	#endif

	// Window Initialization //
	MSG message;
	RECT rScreen;
	WNDCLASSEX windowClass;

	// Grab Screen Resolution //
	GetWindowRect(GetDesktopWindow(), &rScreen);
	gScreenWidth = rScreen.right;
	gScreenHeight = rScreen.bottom;

	gWindowWidth = gCustomWidth = DEFAULT_WINDOWED_WIDTH;
	gWindowHeight = gCustomHeight = DEFAULT_WINDOWED_HEIGHT;

	// Fill Window Properties //
	ZeroMemory(&message, sizeof(message));
	ZeroMemory(&windowClass, sizeof(windowClass));
	windowClass.cbSize = sizeof(WNDCLASSEX);
	windowClass.lpfnWndProc = WndProc;
	windowClass.cbClsExtra = 0;
	windowClass.cbWndExtra = 0;
	windowClass.hInstance = hInstance;
	windowClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(107));
	windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
	windowClass.lpszMenuName = MAKEINTRESOURCE(107);
	windowClass.lpszClassName = L"The Exile";

	RegisterClassEx(&windowClass);

	STICKYKEYS wStickyKeys;
	wStickyKeys.cbSize = sizeof(STICKYKEYS);
	wStickyKeys.dwFlags = NULL;
	HRESULT result = SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &wStickyKeys, NULL);

	// Create Window //
	hWindow = CreateWindow(L"The Exile", L"The Exile", WINDOW_STYLE,
						   WINDOW_START_X, WINDOW_START_Y, WINDOW_WIDTH , WINDOW_HEIGHT, 
						   NULL, NULL, hInstance, NULL);

	if (!hWindow) // If creation of window fails
		return false;

	ShowWindow(hWindow, cmdShow);
	UpdateWindow(hWindow);

	// Intialize Global Classes //
	//CAssetManager::GetInstance();
	CTime cTime;
	CRenderer cRenderer(hWindow);

	// Main Loop /
	bool Alive = true;
	float wakeupTime = 0;
	float sleepOffset = 1; // Because Sleep is so inaccurate // Thanks Obama
	srand((unsigned int)(CURRENT_TIME()));

	// Set Startup State //
	#if NICK_STATE
		CNickState cNickState;
		cNickState.Enter();
		GRAPHICS->GetDebugCamera() = true;
	#else
		g_cStateMachine = CStateMachine::GetInstance();
		//g_cStateMachine->GiveAlive(&Alive);
		g_cStateMachine->PushState(eMAINMENU);
		ShowCursor(false);
	#endif

	while (Alive && message.message != WM_QUIT)
	{
		if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&message);
			DispatchMessage(&message);
		}
		else
		{
			// Game Update //
			TICK();

			#if NICK_STATE
				cNickState.Input();
				cNickState.Update();
				GRAPHICS->Update();
			#else
			if (g_cStateMachine->Update())
				GRAPHICS->Update();
			else if (g_cStateMachine->IsEmpty())
				Alive = false;

			#endif

		}

		// FPS Cap // - Prevents unnecessarily burning up CPU time
		#ifdef FPS
		
		float currentTime = CURRENT_TIME();

		if (currentTime <= wakeupTime) // Are we early for the next frame
			Sleep(DWORD(((wakeupTime - currentTime) * 1000.0f) + sleepOffset)); // Sleep until next frame

		wakeupTime = CURRENT_TIME() + FRAME_TIME;

		#endif
	}

#if NICK_STATE
	cNickState.Exit();
#endif
	#if !NICK_STATE
		g_cStateMachine->DeleteInstance();
	#endif

#if _DEBUG && !NICK_STATE
	//_CrtDumpMemoryLeaks();
		
#endif
	return 0;
}
コード例 #2
0
ファイル: LevelLoader.cpp プロジェクト: CMcLaine92/The-Exile
/*****************************************************************
* LoadLevel()			Returns the only instance of the MessageManager
*
* Ins:					szFilePath
*
* Outs:					None
*
* Returns:				bool
*
* Mod. Date:		    09/02/2015
* Mod. Initials:	    NH
*****************************************************************/
bool CLevelLoader::LoadLevel(string file_name)
{

#pragma region FBX initialize

	// Get an FBX manager
	FbxManager* manager = FbxManager::Create();
	if (manager == 0)
	{
		return false;
	}

	// Create IO settings
	FbxIOSettings* io_settings = FbxIOSettings::Create(manager, IOSROOT);
	if (io_settings == 0)
	{
		manager->Destroy();
		return false;
	}

	manager->SetIOSettings(io_settings);

	// Create importer
	FbxImporter* importer = FbxImporter::Create(manager, "");
	if (importer == 0)
	{
		io_settings->Destroy();
		manager->Destroy();

		return false;
	}

	// Initialize importer
	if (importer->Initialize(file_name.c_str(), -1, io_settings) == false)
	{
		io_settings->Destroy();
		manager->Destroy();
		importer->Destroy();
		return false;
	}

	// Create a scene
	FbxScene* scene = FbxScene::Create(manager, "myScene");
	if (scene == 0)
	{
		io_settings->Destroy();
		manager->Destroy();
		importer->Destroy();
		return false;
	}

	// Load the scene with contents from the file
	if (importer->Import(scene) == false)
	{
		io_settings->Destroy();
		manager->Destroy();
		importer->Destroy();
		scene->Destroy();
		return false;
	}

	// No longer need the importer

	// Traverse the scene
	FbxNode* root_node = scene->GetRootNode();
	if (ProcessLevelNode(root_node, m_cvMeshes) == false)
	{
		importer->Destroy();
		io_settings->Destroy();
		root_node->Destroy();
		scene->Destroy();
		manager->Destroy();
		return false;
	}

	importer->Destroy();
	io_settings->Destroy();
	root_node->Destroy();
	scene->Destroy();
	manager->Destroy();
	


#pragma endregion

#pragma region Exit Door Objects
	srand((unsigned int)(CURRENT_TIME()));
	unsigned int ExitDoorIndex = rand() % 4;

	//for (unsigned int i = 0; i < m_cvExitDoorMeshes.size(); i++)
	//{
	//	m_cvExitDoorMeshes[i].ConvertVertices();
	//	m_cvExitTeleporterMeshes[i].ConvertVertices();

	//	if (i == ExitDoorIndex)
	//	{
	//		//this is the exit door
	//		m_cpTheExitDoor = new CExitDoorObject("ExitDoor");
	//		m_cpTheExitDoor->AddCollider(new CCollider(true, Bounds::AABB, m_cvExitDoorMeshes[i].GetVertices()));
	//		m_cpTheExitDoor->SetRenderMesh(new CRenderMesh(&m_cvExitDoorMeshes[i], GRAPHICS->GetVertexShader(), GRAPHICS->GetPixelShader(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Door.dds"));

	//		m_cpEnvironmentObjects.push_back(m_cpTheExitDoor);
	//		m_cpObjectManager->AddObject(m_cpTheExitDoor, CObjectManager::eObjectType::Dynamic);

	//		//set up teleporter
	//		m_cpTheExitTeleporter = new CWaypointObject("ExitTeleporter");
	//		m_cpTheExitTeleporter->SetPosition(GetAABBCentroid(m_cvExitTeleporterMeshes[i].GetVertices()));

	//		continue;
	//	}

	//	//thse are not exit doors anymore. now they are standard walls
	//	CWallObject* newWall = new CWallObject("Wall");
	//	newWall->AddCollider(new CCollider(false, Bounds::AABB, m_cvExitDoorMeshes[i].GetVertices()));
	//	newWall->SetRenderMesh(new CRenderMesh(&m_cvExitDoorMeshes[i], GRAPHICS->GetVertexShader(), GRAPHICS->GetPixelShader(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Maze_Wall.dds"));

	//	m_cpEnvironmentObjects.push_back(newWall);
	//	m_cpObjectManager->AddObject(newWall, CObjectManager::eObjectType::Static);
	//}

#pragma endregion

	CNavGraphManager::GetReference().AddNavGraph("MinotaurNavGraph", m_cpMinotaurNavGraph);

	return true;
}
コード例 #3
0
ファイル: lang_CPP.cpp プロジェクト: SuperRiderTH/enigma-dev
syntax_error *lang_CPP::definitionsModified(const char* wscode, const char* targetYaml)
{
  cout << "Parsing settings..." << endl;
    parse_ide_settings(targetYaml);
  
  cout << targetYaml << endl;
  
  cout << "Creating swap." << endl;
  delete main_context;
  main_context = new jdi::context();
  
  cout << "Dumping whiteSpace definitions..." << endl;
  FILE *of = wscode ? fopen((makedir +"Preprocessor_Environment_Editable/IDE_EDIT_whitespace.h").c_str(),"wb") : NULL;
  if (of) fputs(wscode,of), fclose(of);
  
  cout << "Opening ENIGMA for parse..." << endl;
  
  llreader f("ENIGMAsystem/SHELL/SHELLmain.cpp");
  int res = 1;
  DECLARE_TIME_TYPE ts, te;
  if (f.is_open()) {
    CURRENT_TIME(ts);
    res = main_context->parse_C_stream(f, "SHELLmain.cpp");
    CURRENT_TIME(te);
  }
  
  jdi::definition *d;
  if ((d = main_context->get_global()->look_up("variant"))) {
    enigma_type__variant = d;   
    if (!(d->flags & jdi::DEF_TYPENAME))
      cerr << "ERROR! ENIGMA's variant is not a type!" << endl;
    else
      cout << "Successfully loaded builtin variant type" << endl;
  } else cerr << "ERROR! No variant type found!" << endl;
  if ((d = main_context->get_global()->look_up("var"))) {
    enigma_type__var = d;
    if (!(d->flags & jdi::DEF_TYPENAME))
      cerr << "ERROR! ENIGMA's var is not a type!" << endl;
    else
      cout << "Successfully loaded builtin var type" << endl;
  } else cerr << "ERROR! No var type found!" << endl;
  if ((d = main_context->get_global()->look_up("enigma"))) {
    if (d->flags & jdi::DEF_NAMESPACE) {
      if ((d = ((jdi::definition_scope*)d)->look_up("varargs"))) {
        enigma_type__varargs = d;
        if (!(d->flags & jdi::DEF_TYPENAME))
          cerr << "ERROR! ENIGMA's varargs is not a type!" << endl;
        else
          cout << "Successfully loaded builtin varargs type" << endl;
      } else cerr << "ERROR! No varargs type found!" << endl;
    } else cerr << "ERROR! Namespace enigma is... not a namespace!" << endl;
  } else cerr << "ERROR! Namespace enigma not found!" << endl;
  
  if (res) {
    cout << "ERROR in parsing engine file: The parser isn't happy. Don't worry, it's never happy.\n";
    cout << heaping_pile_of_dog_shit;
    
    ide_passback_error.set(0,0,0,"Parse failed; details in stdout. Bite me.");
    cout << "Continuing anyway." << endl;
    // return &ide_passback_error;
  } else {    
    cout << "Successfully parsed ENIGMA's engine (" << PRINT_TIME(ts,te) << "ms)\n"
    << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    //cout << "Namespace std contains " << global_scope.members["std"]->members.size() << " items.\n";
  }
  
  cout << "Creating dummy primitives for old ENIGMA" << endl;
  for (jdip::tf_iter it = jdip::builtin_declarators.begin(); it != jdip::builtin_declarators.end(); ++it) {
    main_context->get_global()->members[it->first] = new jdi::definition(it->first, main_context->get_global(), jdi::DEF_TYPENAME);
  }
  
  cout << "Initializing EDL Parser...\n";
  
  parser_init();
  
  cout << "Grabbing locals...\n";
  
  shared_locals_load(requested_extensions);
  
  cout << "Determining build target...\n";
  
  extensions::determine_target();
  
  cout << " Done.\n";
  
  return &ide_passback_error;
}