当前位置: 首页>>代码示例>>C++>>正文


C++ StateManager::draw方法代码示例

本文整理汇总了C++中StateManager::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ StateManager::draw方法的具体用法?C++ StateManager::draw怎么用?C++ StateManager::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StateManager的用法示例。


在下文中一共展示了StateManager::draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

		void run() {
			double lastFPSTime = glfwGetTime();
			int fps = 0;

			while (!m_win->shouldClose()) {
				glfwPollEvents();

				double now = glfwGetTime();

				m_stateManager.update();
				m_stateManager.draw();

				m_win->swapBuffers();

				if (now - lastFPSTime > 1) {
					char fpsString[200];
					sprintf(
						fpsString, "Pxljm 2015 [%d FPS @%dx%d]",
						fps, m_win->width(), m_win->height());
					m_win->title(fpsString);
					fps = 0;
					lastFPSTime = now;
				}
				fps++;
			}

			delete m_win;

			glfwTerminate();
		}
开发者ID:Golden-Eagle,项目名称:pxljm15,代码行数:30,代码来源:Game.hpp

示例2: main

int main(int argc, const char* argv[])
{


	ResourceLoader loader(argv[0] + std::string("\\..\\..\\Resources"));
	


	StateManager states;
	states.setState(std::unique_ptr<MenuScreen>(new MenuScreen(loader)));


	sf::RenderWindow app(sf::VideoMode(768, 768, 32), "Ethan Game");
	app.EnableKeyRepeat(false);
	
	sf::Clock clock;
	double timeForSimulation = 0;

	while (app.IsOpened())
	{
		
		sf::Event event;
		while (app.GetEvent(event))
		{
			switch(event.Type)
			{
			case sf::Event::Closed:
				app.Close();
				break;

			default:
				states.handleEvent(event);
			}
				
		}
		timeForSimulation+= clock.GetElapsedTime();
		clock.Reset();

		while (timeForSimulation >= 1.0/60.0)
		{
			states.update(1.0/60.0);
			timeForSimulation -= 1.0/60;
		}

	

		states.draw(app);


		app.Display();

	}



	return 0;
}
开发者ID:Lalaland,项目名称:EthanSteinbergFinalProject,代码行数:57,代码来源:Main.cpp

示例3: main

int main() {

    srand((long)time(0));

    //load screen stuff like resolution, sound settings, ETC
    GameConfiguration gameConfiguration;
    gameConfiguration.load();

    sf::RenderWindow window(sf::VideoMode(DEFAULT_SCREEN_RESOLUTION.x, DEFAULT_SCREEN_RESOLUTION.y), "Contra");
    sf::Event event;

    StateManager stateManager;

    shared_ptr<GameState> mainMenu = make_shared<GameStateMainMenu>(window, stateManager);

    if(mainMenu) {

        stateManager.push(mainMenu);
    }

    sf::Clock timer;
    const sf::Time maxDeltaTime = sf::seconds(0.025);

    while(window.isOpen()) {

        while(window.pollEvent(event)) {

            //handle other window events first
            if(event.type == sf::Event::Closed) {

                window.close();
            }

            //window resized so reset default view
            if(event.type == sf::Event::Resized) {

                sf::Vector2f newSize(event.size.width, event.size.height);
                sf::View newView;
                newView.setSize(newSize);

                window.setView(newView);
            }

            stateManager.handleInputEvents(event, window);
        }

        stateManager.handleStateEvents(window);

        sf::Time delta = timer.restart();

        if(delta > maxDeltaTime) {

            delta = maxDeltaTime;
        }

        stateManager.update(delta.asSeconds(), window);

        window.clear();

        stateManager.draw(window);

        window.display();

        if(stateManager.isEmpty()) {

            //no states left to handle so may as well clsoe the game
            break;
        }
    }

    //do some cleanup crap
}
开发者ID:Irelevance,项目名称:Contra,代码行数:72,代码来源:Main.cpp


注:本文中的StateManager::draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。