Esempio n. 1
0
int main() {
  App::Get();
  SceneManager manager;
  while (App::Get().isOpen()) {
    App::Get().begin();
    
    manager.Update();
    manager.Draw();

    App::Get().end();
  }
}
Esempio n. 2
0
int main() 
{
	Env();

	SceneManager sceneManager;

  while (Env().isOpen()) 
  {
	Env().begin();

	sceneManager.Update();

	sceneManager.Draw();

	Env().end();
  }
}
Esempio n. 3
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmaLine, int  nCmaShow)
{
	if (DxLib_Init() == -1)return -1;
	ChangeWindowMode(TRUE);
	SetDrawScreen(DX_SCREEN_BACK);
	SetGraphMode((int)Window::WIDTH, (int)Window::HEIGHT, GetColor(0, 0, 0));

	SceneManager sceneManager;
	int currentScene = (int)SceneID::NON;
	int nextScene = (int)SceneID::TITLE;
	
	char key[256];

	while (ScreenFlip() == 0 && ProcessMessage() == 0 && GetHitKeyStateAll(key) == 0)
	{
		ClearDrawScreen();

		if (nextScene != currentScene)
		{
			currentScene = nextScene;
			sceneManager.SetScene(currentScene);
		}

		sceneManager.Update();
		sceneManager.Draw();

		nextScene = sceneManager.SceneEnd();

		if (isPresskey(KEY_INPUT_ESCAPE))
		{
			DxLib_End();
		}
	}

	return 0;
}
Esempio n. 4
0
int main()
{
	srand(time(NULL));
	std::chrono::steady_clock myClock;
	const auto timePerTick = std::chrono::milliseconds(16);
	auto timeOfLastTick = myClock.now();

	/** Prepare the window */
	//int screenWidth = VideoMode::getDesktopMode().width;
	//int screenHeight = VideoMode::getDesktopMode().height;	

	int screenWidth = 1280;
	int screenHeight = 720;
	window = new RenderWindow(VideoMode(screenWidth, screenHeight, 32), "FYP");
	window->setFramerateLimit(60);
	window->setVerticalSyncEnabled(true);
	View view = View(FloatRect(0, 0, screenWidth, screenHeight));
	window->setView(view);

	b2Vec2 Gravity(0.f, 0.f);
	world = new b2World(Gravity);
	world->SetAllowSleeping(false);
	ContactListener contactListener = ContactListener();
	world->SetContactListener(&contactListener);

	lightRenderStates = new sf::RenderStates();
	lightRenderStates->blendMode = sf::BlendMultiply;

	sf::Texture penumbraTexture;
	penumbraTexture.loadFromFile("assets/penumbraTexture.png");
	penumbraTexture.setSmooth(true);

	unshadowShader = new sf::Shader();
	lightOverShapeShader = new sf::Shader();
	normalsShader = new sf::Shader();
	unshadowShader->loadFromFile("assets/unshadowShader.frag", sf::Shader::Fragment);
	lightOverShapeShader->loadFromFile("assets/lightOverShapeShader.frag", sf::Shader::Fragment);
	normalsShader->loadFromFile("assets/normalsShader.frag", sf::Shader::Fragment);

	ltbl::LightSystem::GetInstance()->create(sf::FloatRect{ { 0.f, 0.f }, Vector2f(view.getSize().x,  view.getSize().y) }, Vector2u(view.getSize().x, view.getSize().y), penumbraTexture, *unshadowShader, *lightOverShapeShader, *normalsShader);
	ltbl::LightSystem::GetInstance()->normalsEnabled(false);

	sf::Sprite sprite(ltbl::LightSystem::GetInstance()->getLightingTexture());
	sprite.setPosition(window->getView().getCenter());

	SFMLDebugDraw debugDraw(*window);
	world->SetDebugDraw(&debugDraw);
	debugDraw.SetFlags(b2Draw::e_shapeBit);
	//setting up the managers
	InputManager::GetInstance();
	AudioManager::GetInstance();
	SceneChanger::GetInstance();
	SettingsManager::GetInstance();

	SceneManager* sceneManager = new SceneManager();
	SceneChanger::GetInstance()->ChangeScene(GameState::GAME);

	ml = new tmx::MapLoader("Maps");
	ml->Load("myMap.tmx");

	Network::GetInstance();

	while (window->isOpen())
	{
		//while (myClock.now() - timeOfLastTick >= timePerTick) {
		timeOfLastTick = myClock.now();

		float32 timeStep = 1 / 20.0;      //the length of time passed to simulate (seconds)
		int32 velocityIterations = 200;   //how strongly to correct velocity
		int32 positionIterations = 100;   //how strongly to correct position

		world->Step(timeStep, velocityIterations, positionIterations);

		//checking for bodies that need to be destroyed (Using their user data)
		//Consider threading this operation 
		/*b2Body* bodyList = world->GetBodyList();
		for (; bodyList != NULL; bodyList = bodyList->GetNext()) {
			if (bodyList->GetFixtureList()->GetUserData() == "Destroy") {
				world->DestroyBody(bodyList);
				break;
			}
		}*/

		//InputManager::GetInstance()->Update();
		//AudioManager::GetInstance()->update();
		sceneManager->Update();
		//Network::GetInstance()->Update();
		//}  

		window->clear();
		window->draw(*ml);
		sceneManager->Draw();
		//world->DrawDebugData();  

		window->display();

	}
}
Esempio n. 5
0
void gameMain(void)
{	
	sceneManager.Update();
}