Ejemplo n.º 1
0
int main()
{
	//Synchonisation coordonnée à l'écran!
	mainWin.setVerticalSyncEnabled(true);


	

	Menu mainMenu;
	mainMenu.draw(mainWin);
	
		

	while (mainWin.isOpen())
	{
		Event event;
	

		while (mainWin.pollEvent(event))
		{
			switch (event.type)
			{
				case sf::Event::Closed:
					mainWin.close();
					break;
				case sf::Event::KeyPressed:
					if (event.key.code == sf::Keyboard::Down)
					{
						mainMenu.MoveCursor("Down", mainWin);
					}
					else if (event.key.code == sf::Keyboard::Up)
					{
						mainMenu.MoveCursor("Up", mainWin);
					}
					else if (event.key.code == sf::Keyboard::Space)
					{
						mainMenu.SelectItem(mainWin);
					}
					break;


			}
		}

	}

	

	return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
int main(int argc, char** argv) {
    
    

    
    globalvariables->running = true;

    
    
    window.create(VideoMode(800,600),"Quadcopter Project");
    
    window.setVerticalSyncEnabled(true);
    

    
   
    
     
    //thread CaptureThread(Capture);
    
    LoadingRender loadingrender(globalvariables);
    loadingrender.Load();
    
    globalvariables->currentrenderer = &loadingrender;
    Clock fps;
    while (globalvariables->running)
    {
        globalvariables->currentrenderer->Tick(window);
        
        

        
    }

    delete globalvariables;
    window.close();
    exit(EXIT_SUCCESS);



}
Ejemplo n.º 3
0
	bool init() {
		VideoMode videoMode(width, height);
		window.create(videoMode, "Break Out");
		window.setVerticalSyncEnabled(true);
		window.setFramerateLimit(FRAMES_PER_SECOND);

		 if (!font.loadFromFile("res\\stocky.ttf"))
            return false;  
 
        if (!soundBuffer1.loadFromFile("res\\blip.wav"))
            return false;
         
        if (!soundBuffer2.loadFromFile("res\\blam.wav"))
            return false;
         
        if (!soundBuffer3.loadFromFile("res\\blap.wav"))
            return false;
 
        if (!soundBuffer4.loadFromFile("res\\blop.wav"))
            return false;

		setup();
		return true;
	}
Ejemplo n.º 4
0
int main()
{
#ifdef __GNUC__
	XInitThreads();
#endif

	xb::Joystick::isAnyXBox360ControllerConnected();

	bool isSmall;
	sf::View v(sf::FloatRect(0,0,sf::VideoMode::getDesktopMode().width,sf::VideoMode::getDesktopMode().height));

	RenderWindow *window;

	HEIGHT = 800;
	WIDTH = 1280;

	if (sf::VideoMode::getDesktopMode().height > 800)
	{
		window = new RenderWindow(VideoMode(WIDTH, HEIGHT), "Grief Trigger Turbo HD", sf::Style::Titlebar | sf::Style::Close);
		isSmall = false;
	}
	else
	{
		//HEIGHT = sf::VideoMode::getDesktopMode().width;
		//WIDTH = sf::VideoMode::getDesktopMode().height;

		window = new RenderWindow(VideoMode(sf::VideoMode::getDesktopMode().width, sf::VideoMode::getDesktopMode().height), "Grief Trigger Turbo HD", sf::Style::Titlebar | sf::Style::Close);
		isSmall = true;

		window->setSize(sf::Vector2u(sf::VideoMode::getDesktopMode().width/2, 800/2));
		v = window->getView();
		//v.zoom(2.f);
		window->setView(v);

		
	}
	//window->setFramerateLimit(60);
	window->setVerticalSyncEnabled(true);
//	window.setKeyRepeatEnabled(false);

	sf::Clock frameClock;
	sf::Clock updateClock;
	sf::Int32 nextUpdate = updateClock.getElapsedTime().asMilliseconds();
	float updateRate(1.0f / 15.f);
	float maxUpdates = 1;

	Level::instance().setDay(0);  // Menu
	Level::instance().setScene(0);//

	GameData::instance().getPlayer().getWeapon().init(L"Клеймор x");
	GameData::instance().getEmber().getWeapon().init(L"Посох x");
	GameData::instance().getThunder().getWeapon().init(L"Катана x");

	running = true;
	
	isMenu = true;

	

	while (running && window->isOpen())
	{
		sf::Int32 updateTime = updateClock.getElapsedTime().asMilliseconds();
		Uint32 updates = 0;

		sf::Event event;
		while (window->pollEvent(event))
		{
			if (event.type == sf::Event::Closed) window->close();

			if (!isMenu) SceneManager::instance().input(event);
			else mm.input(event);
		}	

		while((updateTime - nextUpdate) >= updateRate && updates++ < maxUpdates)
		{
			if (!isMenu)SceneManager::instance().update(sf::seconds(updateRate));
			else mm.update(sf::seconds(updateRate));		
			nextUpdate += updateRate;
		} 		

		//float lt, rt;
		//xb::Joystick::getTriggers(0, lt, rt);

		//// Triggers controls the vibration
		//xb::Joystick::setVibration(0, lt, rt);

		if (Level::instance().getDay()==0 && Level::instance().getScene()==0)
		{
			isMenu = true;
		}
		if (Level::instance().getDay()==0 && Level::instance().getScene()==0)
		{
			isMenu = true;
		}

		window->clear();
		if (isSmall)
		{		
			if (!isMenu) SceneManager::instance().draw(*window);
			else mm.draw(*window);
		}
		else
		{
			if (!isMenu) SceneManager::instance().draw(*window);
			else mm.draw(*window);
		}	
		window->display();
	}

	//xb::Joystick::setVibration(0);

	return 0;
}