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


C++ Level::Update方法代码示例

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


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

示例1: Update

bool Update(float dt){dt;
	if (isEditingSpaceship){
		editor.Update();

		if (editor.IsExited() || editor.IsSpaceshipReady()){
			isEditingSpaceship = false;

			if (editor.IsSpaceshipReady()){
		//		ship = editor.GetSpaceship();
			}

			editor.Reset();
		}
	}
	else{
		if(!isMainMenu && !isControls){
			lvl.Update(dt);
			manager->Update(false, 0.0f, Vector2(), dt);

			if (lvl.IsWin() || lvl.IsGameOver()){
				isMainMenu = true;
			}
		}
		else if (isControls){
			isControls = Controls::Update();
			if (!isControls){
				isMainMenu = true;
			}
		}
		else{
			menu.Update(dt);
			UpdateGameState();
		}
	}

	if (Input::IsPressed('O')){
		isEditingSpaceship = true;
	}

	bool requestedExit = (Input::IsPressed(Input::KEY_ESCAPE));
	if (requestedExit){
		profiler.WriteToFile();
		END_LOG
	}

	return requestedExit;
}
开发者ID:nickredmond,项目名称:CSC190Nick_Redmond,代码行数:47,代码来源:main.cpp

示例2: Update

bool GameStateA::Update(float deltatime, sf::RenderWindow &m_window, Level& level)
{
	sf::Event event;
	while (m_window.pollEvent(event))
	{
		if (event.type == sf::Event::Closed)
		{
			m_window.close();
			return false;
		}

		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
		{
			m_window.close();
			return false;

		}

	}

	if (m_first_run)
	{
		
		m_first_run = false;
	}
	
	

	
	m_window.clear(sf::Color(104, 50, 3, 0));
	if(level.Update(m_window, deltatime)){
		m_next_state = "CombatState";
		m_continue = false;
	}
	m_window.display();

	return m_continue;
};
开发者ID:bobn94,项目名称:summerproject,代码行数:38,代码来源:GameState.cpp

示例3: main

int main()
{
    srand(time(0));
    sf::ContextSettings settings;
    settings.antialiasingLevel = 8;

    // create the window
    sf::RenderWindow window(sf::VideoMode(928, 448), "Labshooter", sf::Style::Default, settings);

    sf::Clock clock;

    sf::Texture playerTexture;
    playerTexture.loadFromFile("assets/player.png");

    sf::Texture tileTexture;
    tileTexture.loadFromFile("assets/tile.png");

    sf::Sprite playerSprite;
    playerSprite.setTexture(playerTexture);

    sf::Sprite tileSprite;
    tileSprite.setTexture(tileTexture);

    SoundManager::LoadSound("shoot", "assets/shoot.wav");
    SoundManager::LoadSound("shoot2", "assets/shoot2.wav");
    SoundManager::LoadSound("hurt", "assets/hurt.wav");

    level.LoadLevel("assets/level1");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        sf::Time elapsed = clock.restart();

        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
        level.Update(elapsed.asMilliseconds());
        /*if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
            move(0.5 * elapsed.asMilliseconds(), 0, playerSprite, tileSprite);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
            move(-0.5 * elapsed.asMilliseconds(), 0, playerSprite, tileSprite);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
            move(0, -0.5 * elapsed.asMilliseconds(), playerSprite, tileSprite);
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
            move(0, 0.5 * elapsed.asMilliseconds(), playerSprite, tileSprite);
        }*/

        tileSprite.setPosition(50, 50);

        // clear the window with black color
        window.clear(sf::Color::White);

        // draw everything here...
        //window.draw(playerSprite);
        //window.draw(tileSprite);
        level.Render(&window);

        // end the current frame
        window.display();
    }

    return 0;
}
开发者ID:esenti,项目名称:labshooter,代码行数:72,代码来源:main.cpp


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