예제 #1
0
파일: main.cpp 프로젝트: 9pa636/game
int main()
{
	sf::Clock clock;
	
	sf::RenderWindow window(sf::VideoMode(1000, 701), "Game");
	GameSystem sys = GameSystem(&window, clock);
	
	while (window.isOpen())
	{
		sf::Event evt;
		while (window.pollEvent(evt))
		{
			if (evt.type == sf::Event::Closed)
			{
				window.close();
			}
		}
		
		window.clear();
		sys.Update(1e-2f);
		sys.Draw();
		window.display();

	}
	return 0;
}
예제 #2
0
void system_manager_init_systems(SystemManager* SM)
{
	GameSystem* System = SM->FirstSystem;
	while(System)
	{
		System->SystemPointer = System->Init(SM);
		System = System->NextSystem;
	}
}
예제 #3
0
파일: main.cpp 프로젝트: zveale/game-clones
int main(int argc, char* argv[]) {  // LINUX
// int SDL_main(int argc, char* argv[]) {  // WINDOWS

  GameSystem gameSystem;
  gameSystem.Startup();
  gameSystem.Run();
  gameSystem.Shutdown();

  return 0;
} 
예제 #4
0
void system_manager_shutdown_systems(SystemManager* SM)
{
	GameSystem* System = SM->FirstSystem;
	while(System)
	{
		System->Destroy(System->SystemPointer);
		System->SystemPointer = NULL;
		System = System->NextSystem;
	}
}
예제 #5
0
  /* -------------------------------------------------------------------------------------------
   *
   * ------------------------------------------------------------------------------------------- */
  QStringList Field::getOptions() {
    Q_ASSERT(this->getFieldType() == LookupField);
    GameSystem *system = this->group->getCharacter()->getGameSystem();
    Table *table = system->getTable(this->lookupTableName);

    if(table != 0x0) {
      return table->getOptions();
    } else {
      qDebug() << "WARNING: no table specified for: " << this->getLookupTableName();
      return QStringList();
    }
  }
예제 #6
0
/// Windows application entry point.
///
/// @param[in] hInstance      Handle to the current instance of the application.
/// @param[in] hPrevInstance  Handle to the previous instance of the application (always null; ignored).
/// @param[in] lpCmdLine      Command line for the application, excluding the program name.
/// @param[in] nCmdShow       Flags specifying how the application window should be shown.
///
/// @return  Result code of the application.
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nCmdShow )
{
    HELIUM_TRACE_SET_LEVEL( TRACE_DEBUG );

    int32_t result = 0;

    {
        // Initialize a GameSystem instance.
        CommandLineInitializationWin commandLineInitialization;
        Example::ObjectTypeRegistration< ObjectTypeRegistrationWin > objectTypeRegistration;
        MemoryHeapPreInitialization memoryHeapPreInitialization;
        ObjectLoaderInitializationWin objectLoaderInitialization;
        ConfigInitializationWin configInitialization;
        WindowManagerInitializationWin windowManagerInitialization( hInstance, nCmdShow );
        RendererInitializationWin rendererInitialization;
        //NullRendererInitialization rendererInitialization;

        GameSystem* pGameSystem = GameSystem::CreateStaticInstance();
        HELIUM_ASSERT( pGameSystem );
        bool bSystemInitSuccess = pGameSystem->Initialize(
            commandLineInitialization,
            objectTypeRegistration,
            memoryHeapPreInitialization,
            objectLoaderInitialization,
            configInitialization,
            windowManagerInitialization,
            rendererInitialization,
            NULL );
        if( bSystemInitSuccess )
        {
            // Run the application.
            result = pGameSystem->Run();
        }

        // Shut down and destroy the system.
        pGameSystem->Shutdown();
        System::DestroyStaticInstance();
    }

    // Perform final cleanup.
    ThreadLocalStackAllocator::ReleaseMemoryHeap();

#if HELIUM_ENABLE_MEMORY_TRACKING
    DynamicMemoryHeap::LogMemoryStats();
    ThreadLocalStackAllocator::ReleaseMemoryHeap();
#endif

    return result;
}
예제 #7
0
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
	MSG msg = { 0 };

	GameSystem game;

	AllocConsole();

	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	//_CrtSetBreakAlloc(780);
	HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
	int hCrt = _open_osfhandle((long)handle_out, _O_TEXT);
	FILE* hf_out = _fdopen(hCrt, "w");
	setvbuf(hf_out, NULL, _IONBF, 1);
	*stdout = *hf_out;

	HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
	hCrt = _open_osfhandle((long)handle_in, _O_TEXT);
	FILE* hf_in = _fdopen(hCrt, "r");
	setvbuf(hf_in, NULL, _IONBF, 128);
	*stdin = *hf_in;
	//game

	game.StartGame(0.0f,0.0f,hInstance);
	ShowWindow(game.getMainHwnd(), nCmdShow);
	while (WM_QUIT != msg.message)
	{

		if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			game.Render();
		}
	}

	return (int)msg.wParam;
}
예제 #8
0
void RemoveEntityFromSystem(GameSystem system, Entity entity) {
    system->RemoveEntity(entity);
}
예제 #9
0
void AddEntityToSystem(GameSystem system, Entity entity) {
    system->AddEntity(entity);
}
예제 #10
0
int main( int argc, const char* argv[] )
#endif
{
	HELIUM_TRACE_SET_LEVEL( TraceLevels::Debug );

	Helium::GetComponentsDefaultHeap();
	Helium::GetBulletDefaultHeap();

#if HELIUM_TOOLS
	Helium::GetEditorSupportDefaultHeap();
#endif

	int32_t result = 0;

	{
		// Initialize a GameSystem instance.
		CommandLineInitializationImpl commandLineInitialization;
		MemoryHeapPreInitializationImpl memoryHeapPreInitialization;
		AssetLoaderInitializationImpl assetLoaderInitialization;
		ConfigInitializationImpl configInitialization;
#if HELIUM_DIRECT3D
		WindowManagerInitializationImpl windowManagerInitialization( hInstance, nCmdShow );
#else
		WindowManagerInitializationImpl windowManagerInitialization;
#endif
		RendererInitializationImpl rendererInitialization;
		//NullRendererInitialization rendererInitialization;
		AssetPath systemDefinitionPath( "/ExampleGames/PhysicsDemo:System" );

		GameSystem* pGameSystem = GameSystem::CreateStaticInstance();
		HELIUM_ASSERT( pGameSystem );
		bool bSystemInitSuccess = pGameSystem->Initialize(
			commandLineInitialization,
			memoryHeapPreInitialization,
			assetLoaderInitialization,
			configInitialization,
			windowManagerInitialization,
			rendererInitialization,
			systemDefinitionPath);
		
		if( bSystemInitSuccess )
		{
			World *pWorld = NULL; 

			{
				AssetLoader *pAssetLoader = AssetLoader::GetStaticInstance();
				SceneDefinitionPtr spSceneDefinition;

				AssetPath scenePath( TXT( "/ExampleGames/PhysicsDemo/Scenes/TestScene:SceneDefinition" ) );
				pAssetLoader->LoadObject(scenePath, spSceneDefinition );

				HELIUM_ASSERT( !spSceneDefinition->GetAllFlagsSet( Asset::FLAG_BROKEN ) );

				pWorld = pGameSystem->LoadScene(spSceneDefinition.Get());
			}

			HELIUM_ASSERT( pWorld );

			if ( pWorld )
			{
				AssetLoader *pAssetLoader = AssetLoader::GetStaticInstance();

				EntityDefinitionPtr spCubeDefinition;
				EntityDefinitionPtr spSphereDefinition;

				AssetPath spCubePath( TXT( "/ExampleGames/PhysicsDemo:Cube" ) );
				AssetPath spSpherePath( TXT( "/ExampleGames/PhysicsDemo:Sphere" ) );

				pAssetLoader->LoadObject(spCubePath, spCubeDefinition );
				pAssetLoader->LoadObject(spSpherePath, spSphereDefinition );

				Helium::StrongPtr< ParameterSet_InitLocated > locatedParamSet( new ParameterSet_InitLocated() );
				locatedParamSet->m_Position = Simd::Vector3::Zero;
				locatedParamSet->m_Rotation = Simd::Quat::IDENTITY;

				Simd::Vector3 &position = locatedParamSet->m_Position;
				Simd::Quat &rotation = locatedParamSet->m_Rotation;

				for (int i = 0; i < 25; ++i)
				{
					position = Simd::Vector3(
						50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f), 
						Helium::Ran(150.0f, 200.0f), 
						50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
					pWorld->GetRootSlice()->CreateEntity(spCubeDefinition, locatedParamSet.Get());
				}

				for (int i = 0; i < 25; ++i)
				{
					position = Simd::Vector3(
						50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f), 
						Helium::Ran(250.0f, 300.0f), 
						50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
					pWorld->GetRootSlice()->CreateEntity(spSphereDefinition, locatedParamSet.Get());
				}

				for (int i = 0; i < 25; ++i)
				{
					position = Simd::Vector3(
						50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f), 
						Helium::Ran(350.0f, 400.0f), 
						50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
					pWorld->GetRootSlice()->CreateEntity(spCubeDefinition, locatedParamSet.Get());
				}

				for (int i = 0; i < 25; ++i)
				{
					position = Simd::Vector3(
						50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f), 
						Helium::Ran(450.0f, 500.0f), 
						50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
					pWorld->GetRootSlice()->CreateEntity(spSphereDefinition, locatedParamSet.Get());
				}

				for (int i = 0; i < 25; ++i)
				{
					position = Simd::Vector3(
						50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f), 
						Helium::Ran(550.0f, 600.0f), 
						50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
					pWorld->GetRootSlice()->CreateEntity(spCubeDefinition, locatedParamSet.Get());
				}

				Window::NativeHandle windowHandle = rendererInitialization.GetMainWindow()->GetNativeHandle();
				Input::Initialize(windowHandle, false);
				Input::SetWindowSize( 
					rendererInitialization.GetMainWindow()->GetWidth(),
					rendererInitialization.GetMainWindow()->GetHeight());

				// Run the application.
				result = pGameSystem->Run();
			}
		}

		// Shut down and destroy the system.
		pGameSystem->Shutdown();
		System::DestroyStaticInstance();
	}

	// Perform final cleanup.
	ThreadLocalStackAllocator::ReleaseMemoryHeap();

#if HELIUM_ENABLE_MEMORY_TRACKING
	DynamicMemoryHeap::LogMemoryStats();
	ThreadLocalStackAllocator::ReleaseMemoryHeap();
#endif

	return result;
}
예제 #11
0
int main()
{
    GameSystem g;
    Scorpion x;
    Snake s;
    Ant a;
    Bug b;
    Worm w;
    Ant a2;
    Bug b2;
    Worm w2;
    Ant a3;
    Bug b3;
    Worm w3;
    s.putrand(g);
    x.putrand(g);
    a.putrand(g);
    a2.putrand(g);
    a3.putrand(g);
    b.putrand(g);
    b2.putrand(g);
    b3.putrand(g);
    w.putrand(g);
    w2.putrand(g);
    w3.putrand(g);

    // Ant q[4];
    short int choice=g.choose();
    if (choice==2)
    {
        while ( !key[KEY_ESC])
        {
            g.WinLose();
            x.alive(g,'X');
            s.alive(g,'S');
            g.showscore();
            g.showturn();
            //   g.cheat(x);
            if (!x.getdead())
            {
                x.movep(g);
                x.show();
                /*  // Scorpion *p=x.Breed(g); breed
                   Scorpion *p = new Scorpion;
                   if(x.getcounter2()%24==0&&x.getcounter2()!=0){
                   {
                   p->putxy(g,p->getx(),p->gety());
                   p->alive(g,'X');*/
                //   }}

            }
            if (!s.getdead())
            {
                s.moveRand(g);
                s.show();
            }
            /*  for (int i=0;i<10;i++)
              {
                  q[i].alive();
                  x.eat(q[i]);
              }*/
            //   q[0].breed();
            // breed(q,x);
            x.eat(a,g);
            x.eat(b,g);
            x.eat(a2,g);
            x.eat(b2,g);
            x.eat(a3,g);
            x.eat(b3,g);
            s.eat(b,g);
            s.eat(w,g);
            s.eat(b2,g);
            s.eat(w2,g);
            s.eat(b3,g);
            s.eat(w3,g);
            //        g.updatescore(x);
            g.updateturn();
        }
    }
    else if (choice==1)
    {
        while ( !key[KEY_ESC])
        {
            g.WinLose();
            s.alive(g,'S');
            x.alive(g,'X');
            g.showscore();
            g.showturn();
            //     g.cheat(s);
            if (!s.getdead())
            {
                s.movep(g);
                s.show();
                /*        Snake *p = new Snake; breed
                        if(x.getcounter2()%24==0&&x.getcounter2()!=0){
                        {
                        p->putxy(g,p->getx(),p->gety());
                        p->alive(g,'X');
                        }}
                        p->moveRand(g);
                        p->show();*/
            }
            if (!x.getdead())
            {
                x.moveRand(g);
                x.show();
            }
            x.eat(a,g);
            x.eat(b,g);
            x.eat(a2,g);
            x.eat(b2,g);
            x.eat(a3,g);
            x.eat(b3,g);
            s.eat(b,g);
            s.eat(w,g);
            s.eat(b2,g);
            s.eat(w2,g);
            s.eat(b3,g);
            s.eat(w3,g);
            g.updateturn();
        }
    }
    return 0;
}
예제 #12
0
int main( int argc, const char* argv[] )
#endif
{
    HELIUM_TRACE_SET_LEVEL( TraceLevels::Debug );

    Helium::GetComponentsDefaultHeap();
    Helium::GetBulletDefaultHeap();

#if HELIUM_TOOLS
    Helium::GetEditorSupportDefaultHeap();
#endif

    int32_t result = 0;

    {
        // Initialize a GameSystem instance.
        CommandLineInitializationImpl commandLineInitialization;
        MemoryHeapPreInitializationImpl memoryHeapPreInitialization;
        AssetLoaderInitializationImpl assetLoaderInitialization;
        ConfigInitializationImpl configInitialization;
#if HELIUM_DIRECT3D
        WindowManagerInitializationImpl windowManagerInitialization( hInstance, nCmdShow );
#else
        WindowManagerInitializationImpl windowManagerInitialization;
#endif
        RendererInitializationImpl rendererInitialization;
        AssetPath systemDefinitionPath( "/ExampleGames/Empty:System" );
        //NullRendererInitialization rendererInitialization;

        GameSystem* pGameSystem = GameSystem::CreateStaticInstance();
        HELIUM_ASSERT( pGameSystem );
        bool bSystemInitSuccess = pGameSystem->Initialize(
                                      commandLineInitialization,
                                      memoryHeapPreInitialization,
                                      assetLoaderInitialization,
                                      configInitialization,
                                      windowManagerInitialization,
                                      rendererInitialization,
                                      systemDefinitionPath);

        {
            Helium::AssetLoader *pAssetLoader = AssetLoader::GetStaticInstance();
            Helium::SceneDefinitionPtr spSceneDefinition;

            AssetPath scenePath( TXT( "/ExampleGames/Empty/Scenes/TestScene:SceneDefinition" ) );
            pAssetLoader->LoadObject(scenePath, spSceneDefinition );

            pGameSystem->LoadScene(spSceneDefinition.Get());
        }

        if( bSystemInitSuccess )
        {
            Window::NativeHandle windowHandle = rendererInitialization.GetMainWindow()->GetNativeHandle();
            Input::Initialize(windowHandle, false);

            // Run the application.
            result = pGameSystem->Run();
        }

        // Shut down and destroy the system.
        pGameSystem->Shutdown();
        System::DestroyStaticInstance();
    }

    // Perform final cleanup.
    ThreadLocalStackAllocator::ReleaseMemoryHeap();

#if HELIUM_ENABLE_MEMORY_TRACKING
    DynamicMemoryHeap::LogMemoryStats();
    ThreadLocalStackAllocator::ReleaseMemoryHeap();
#endif

    return result;
}