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


C++ RenderWindow::display方法代码示例

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


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

示例1: Show

void SplashScreen::Show(sf::RenderWindow& renderWindow)
{
	sf::Texture image;
	if (!image.loadFromFile("media/images/rekt.png"))
	{
		return;
	}

	sf::Sprite sprite(image);

	renderWindow.draw(sprite);
	renderWindow.display();

	sf::Event event;
	while(true)
	{
		while(renderWindow.pollEvent(event))
	    {
        if(event.type == sf::Event::EventType::KeyPressed || event.type == sf::Event::EventType::MouseButtonPressed 
        	|| event.type == sf::Event::EventType::Closed )
       	{
        	return;
       	}
	}
}
}
开发者ID:epiehl,项目名称:Training,代码行数:26,代码来源:SplashScreen.cpp

示例2: update

void DialogueMode::update(sf::RenderWindow &rw, sf::Clock &clock)
{
    float elapsed = clock.restart().asSeconds();
    rw.clear(sf::Color::White);                                     //should this be in highest loop?
    
    //handle all input
    sf::Event event;
    while (rw.pollEvent(event)) {
        if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Space) {
            current = current->getNext();
            if (current == nullptr) {
                deletionOrder = true;
                return;
            }
        }
        else current->handleInput(event);
    }
    current->update(elapsed);
    
    //put into drawAll function?
    rw.setView(mapView);
    
    currentMap->drawAllObjects(rw, playerSprite);
    
    rw.setView(HUD);
    rw.draw(messageBox);
    current->draw(rw);
    rw.display();
}
开发者ID:NoahKittleson,项目名称:RPG-Engine,代码行数:29,代码来源:DialogueMode.cpp

示例3: WindowFunctions

void RenderEngine::WindowFunctions(sf::RenderWindow& window)
{	
	//create textures

	// run the program as long as the window is open
	while (window.isOpen())
	{
		// 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();
		}

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

		// draw everything here...
		//draws the stack of sprites
		for (unsigned int i = 0; i < stackOfSprites.size(); i++)
		{
			window.draw(stackOfSprites[i]);
		}

		// window.draw(...);

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

}
开发者ID:xephoran,项目名称:GameProjects,代码行数:34,代码来源:RenderEngine.cpp

示例4: show

    MainMenu::MenuResult MainMenu::show( sf::RenderWindow &window )
    {
        // load menu image
        sf::Texture texture;
        texture.loadFromFile( "images/MainMenu.png" );
        sf::Sprite sprite( texture );

        /********************************
        * setup clickable regions
        *********************************/

        // Play menu item coordinates
        MenuItem playButton;
        playButton.rect.top = 0;
        playButton.rect.height = 290;
        playButton.rect.left = 0;
        playButton.rect.width = SCREEN_WIDTH - 1;
        playButton.action = PLAY;

        // Quit menu item coordinates
        MenuItem quitButton;
        quitButton.rect.top = 310;
        quitButton.rect.height = 599;
        quitButton.rect.left = 0;
        quitButton.rect.width = SCREEN_WIDTH - 1;
        quitButton.action = EXIT;

        _menuItems.push_back( playButton );
        _menuItems.push_back( quitButton );

        window.draw( sprite );
        window.display();

        return menuResponse( window );
    }
开发者ID:geecode,项目名称:Spades,代码行数:35,代码来源:MainMenu.cpp

示例5: run

        inline void run()
        {
            SSVU_ASSERT(gameEngine != nullptr);

            while(gameEngine->isRunning())
            {
                if(mustRecreate) recreateWindow();

                renderWindow.setActive(true);
                this->clear();

                gameEngine->refreshTimer();

                auto tempMs(HRClock::now());
                {
                    runEvents();
                    gameEngine->runUpdate();
                }
                msUpdate = std::chrono::duration_cast<FTDuration>(
                               HRClock::now() - tempMs)
                               .count();

                tempMs = HRClock::now();
                {
                    gameEngine->runDraw();
                    renderWindow.display();
                }
                msDraw = std::chrono::duration_cast<FTDuration>(
                             HRClock::now() - tempMs)
                             .count();

                gameEngine->runFPS();
            }
        }
开发者ID:,项目名称:,代码行数:34,代码来源:

示例6: drawBoids

void drawBoids() {
    world.moveAllBoidsToNewPosition();

    for(int j = 0; j<5; j++) {
        window.clear(sf::Color::White);
        for(int i = 0; i<numberOfBoids; i++) {
            int x_velocity = world.Boids[i].velocity.x;
            int x = (sgn(x_velocity))*abs(x_velocity/5);

            int y_velocity = world.Boids[i].velocity.y;
            int y = (sgn(y_velocity))*abs(y_velocity/5);

            boidsShapes[i].setPosition(boidsShapes[i].getPosition().x+x, boidsShapes[i].getPosition().y+y);
            window.draw(boidsShapes[i]);
        }
        window.display();
    }
    /*


    window.clear(sf::Color::White);
    for(int i = 0; i<numberOfBoids; i++){
        boidsShapes[i].setPosition(world.Boids[i].position.x, world.Boids[i].position.y);
        window.draw(boidsShapes[i]);
    }
    window.display();
     */

}
开发者ID:AlexKashuba,项目名称:Boids,代码行数:29,代码来源:main.cpp

示例7: loading_screen

//fake loading screen for smooth transition purposes
int loading_screen(std::string filePath) {
	//std::cout << "load\n"; //debug

	sf::SoundBuffer buffer;
	if (!buffer.loadFromFile(filePath + ".ogg")) {
		std::cout << "Cannot load " << filePath << ".ogg"; //debug
	}
	sf::Sound sound;
	sound.setBuffer(buffer);
	sound.play();

	sf::Clock clock;

	/*
	while (clock.getElapsedTime().asMilliseconds() < 1000) {
		//window.clear(sf::Color(0, 0, 0));
		window.draw()
		window.display();
	}*/

	while (sound.getStatus() != 0) {
		window.clear(sf::Color(0, 0, 0));
		window.display();
	}

	return 0;
}
开发者ID:wgwong,项目名称:akb48_ongaku_geimu,代码行数:28,代码来源:main.cpp

示例8: Show

MainMenu::MenuResult MainMenu::Show(sf::RenderWindow& window)
{ 
	//Load menu image from file
	sf::Texture image;
	image.loadFromFile("assets/images/mainMenu-background.png");
	sf::Sprite sprite(image);
 
	//Setup clickable regions
 
	//Play menu item coordinates
	MenuItem playButton;
	playButton.rect.top= 200;
	playButton.rect.height= 100;
	playButton.rect.left = 0;
	playButton.rect.width = 800;
	playButton.action = Play;
 
	//Exit menu item coordinates
	MenuItem exitButton;
	exitButton.rect.left = 0;
	exitButton.rect.width = 600;
	exitButton.rect.top = 400;
	exitButton.rect.height = 100;
	exitButton.action = Exit;
 
	_menuItems.push_back(playButton);
	_menuItems.push_back(exitButton);
 
	window.draw(sprite);
	window.display();
 
	return GetMenuResponse(window);
}
开发者ID:jggaspar,项目名称:orion,代码行数:33,代码来源:mainMenu.cpp

示例9: mainLoop

void mainLoop() {
    //The first time you run TackFPS it will return a trash value, so get it out of the way now
    TackFPS(true);

    //Pre-emptively call the resize and draw functions to get the cycle going
    reshape(miWidth, miHeight);

    bool running = true;
    sf::Event event;
    while(running) {
        draw();
        while(window.pollEvent(event)) {
            switch(event.type) {
                case sf::Event::Closed: running = false; break;
                case sf::Event::Resized: reshape(event.size.width, event.size.height); break;
                case sf::Event::KeyPressed: keyDown(event.key.code); break;// TODO codes
                case sf::Event::MouseMoved: mouseDrag(event.mouseMove.x, event.mouseMove.y); break;
                case sf::Event::MouseButtonPressed: mousePress(event.mouseButton.button, 1, event.mouseButton.x, event.mouseButton.y); break;
                case sf::Event::MouseButtonReleased: mousePress(event.mouseButton.button, 0, event.mouseButton.x, event.mouseButton.y); break;
                case sf::Event::TextEntered: charTyped(event.text.unicode); break;
                default: cout << "unhandled event:" << event.type << endl; break;
            }
        }
        window.display();
    }
}
开发者ID:Danthekilla,项目名称:noeuclid,代码行数:26,代码来源:noeuclid.cpp

示例10: show

void SplashScreen::show(sf::RenderWindow& window)
{
    sf::Image image;
    std::string imageFile = "/Users/ankithbti/Development/gameBasics/bin/pang.png";
    if (!image.loadFromFile(imageFile))
    {
        return;
    }
    sf::Texture texture;
    texture.loadFromImage(image);
    sf::Sprite sprite(texture);
    
    window.clear(sf::Color::Green);
    window.draw(sprite);
    window.display();

    sf::Event e;
    while (true)
    {
        while (window.pollEvent(e))
        {
            if (e.type == sf::Event::Closed ||
                    e.type == sf::Event::MouseButtonPressed ||
                    e.type == sf::Event::KeyPressed)
            {
                return;
            }
        }
    }
}
开发者ID:ankithbti,项目名称:gameBasicsCpp,代码行数:30,代码来源:SplashScreen.cpp

示例11: show

// Represents the rules
void Rules::show(sf::RenderWindow &window)
{
	// Loads
	sf::Texture texture;
	if(texture.loadFromFile("images/Rules.png") != true) {
		return;
	}

	sf::Sprite sprite(texture);
	window.draw(sprite);
	window.display();

	sf::Event currentEvent;
	while(true)
	{
		while(window.pollEvent(currentEvent))
		{
			// Close the screen if close is clicked
			if(currentEvent.type == sf::Event::Closed) { 
				exit(0);
			}

			if(currentEvent.type == sf::Event::EventType::KeyPressed 
				|| currentEvent.type == sf::Event::EventType::Closed)
			{
				return;
			}
		}
	}
}
开发者ID:AndersOLDahl,项目名称:sfml_game,代码行数:31,代码来源:Rules.cpp

示例12: render

    void Game::render() {

        mWindow.clear();

        Game::generacion_mapa();
//
        while(!MapIsChecked){

            if(Game::mapa_valido(Game::mPlayer.getPosition().y / 50, Game::mPlayer.getPosition().x / 50)){

                this->MapIsChecked = true;

            }else{

                this->pasos_entre_objetos = 0;
                this->mIsMapGenerate = true;
                Game::generacion_mapa();
//                Game::cambiar_posicion_objectos();
            }
        }
//        mWindow.draw(mText);
//        mWindow.draw(mText2);
        mWindow.draw(mPlayer);
        mWindow.draw(mPlayerObj);
//        mWindow.draw(mPlayerObs);
        mWindow.display();

    }
开发者ID:camuschino,项目名称:SFML,代码行数:28,代码来源:main.cpp

示例13: Show

MainMenu::MenuResult MainMenu::Show(sf::RenderWindow & window) {
    sf::Texture texture;
    if (!texture.loadFromFile("img/mainMenu.png"))
        std::cout << "Error loading main menu image\n";
    sf::Sprite sprite(texture);

    // Play menu item coordinates
    MenuItem play_button;
    play_button.rect.top= 145;
    play_button.rect.height = 380;
    play_button.rect.left = 0;
    play_button.rect.width = 1023;
    play_button.action = Play;
    play_button.alt_key = sf::Keyboard::S;

    // Exit menu item coordinates
    MenuItem exit_button;
    exit_button.rect.left = 0;
    exit_button.rect.height = 1023;
    exit_button.rect.top = 383;
    exit_button.rect.width = 560;
    exit_button.action = Exit;
    exit_button.alt_key = sf::Keyboard::Escape;

    _menu_items.push_back(play_button);
    _menu_items.push_back(exit_button);

    window.clear();
    window.draw(sprite);
    window.display();

    return GetMenuResponse(window);
}
开发者ID:hlilje,项目名称:sfml-game,代码行数:33,代码来源:main_menu.cpp

示例14: runGame

void  cbEngine::runGame(sf::RenderWindow &window, sf::Event &event){
    stateManager sManager; //Create instance of stateManager class
    splashScreen splaScreen;


    while(window.isOpen()){
            if (runonce == true){
            std::cout << "Window open" << std::endl;
            }
            //---Do Only if Debugging---//
    // Check to see if runonce is true; if true output to console that game is starting. //
    while (debug == true){
        if (runonce != false){
            std::cout << "Starting game..." << std::endl;
            runonce = false;
        }
        break;
    }
    // End of Debug Section //

    // Loop Structure 1.Clear window (Color = black) 2. Call stateManager 3. Display window //
    eventLoop(window, e); // Call event loop Initialize it with window and Event object
    window.clear(sf::Color::White); //Clear window black
    sManager.selectState(window, event);
    window.display(); // Display everything to screen
    }
}
开发者ID:Sianide4000,项目名称:Code-Blue-Engine,代码行数:27,代码来源:cbEngine.cpp

示例15: show

void SplashScreen::show(sf::RenderWindow &window)
{

	sf::Texture image;
	if (image.loadFromFile("images/SplashScreen.png") != true)
		return;

	sf::Sprite sprite(image);

	window.draw(sprite);
	window.display();

	sf::Event event;
	while (true)
	{
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::EventType::KeyPressed || event.type == sf::Event::EventType::MouseButtonPressed)
				return;
			else if (event.type == sf::Event::EventType::Closed)
			{
				window.close();
				exit(0);
			}
		}
	}
}
开发者ID:luckyk7,项目名称:Chess,代码行数:27,代码来源:SplashScreen.cpp


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