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


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

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


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

示例1: draw

void MainMenu::draw(sf::RenderWindow &window)
{
	window.clear(sf::Color::Black);

	highlight.setPosition(text[selected].getPosition().x - 15, text[selected].getPosition().y);

	window.draw(highlight);

	window.draw(text[0]);
	window.draw(text[1]);
	window.draw(text[2]);
}
开发者ID:Sumolutions,项目名称:Sumo-Slammers,代码行数:12,代码来源:MainMenu.cpp

示例2: main

int main()
{  
  sf::Clock clock;


  //NEVER SYNC WITH COMPUTER AND USE THIS AT THE SAME TIME! EVER!
  window.setFramerateLimit(60);

  window.clear();
  window.display();
  
  //Window loop
  while (window.isOpen())
    {
      /***********************v Keyboard v*********************/
      //keyboard for outside of gameloop stuff
      if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
	left = true;
      }
      else
	left = false;
      if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
	right = true;
      }
      else
	right = false;
      /***********************^ Keyboard ^*********************/

      //handles events
      sf::Event event;
      while (window.pollEvent(event)) {
	switch (event.type) {
	case sf::Event::Closed:
	  window.close();
	  break;
	}
      }

      //Main Menu
      //By default, start at the menu.
      
      //if (something happens)
      running = true;

      if (running) {
	gameLoop(clock,frameGap);
      }
    }
  

  return 0;
}
开发者ID:zhoubw,项目名称:2d-development,代码行数:52,代码来源:main.cpp

示例3: startMenu

bool startMenu(sf::Text title, sf::Text anyKey, sf::Text credits, sf::RenderWindow& window)
{
  // create and load texture for earth.png
  sf::Texture earth;
  if(!earth.loadFromFile("img/earth2.png")) cout << "Error, could not load earth.png" << endl;

  sf::Sprite earthSprite;
  earthSprite.setTexture(earth);
  earthSprite.setPosition(WINDOW_WIDTH / 4 , WINDOW_HEIGHT / 4);

  // set title color, position, size and style
  title.setColor(sf::Color::Black);
  title.setPosition(WINDOW_WIDTH / 5, 0);
  title.setCharacterSize(50);
  title.setStyle(sf::Text::Bold);

  // set anyKey position and color
  anyKey.setPosition(WINDOW_WIDTH / 4.5, 410);
  anyKey.setColor(sf::Color::Black);

  credits.setPosition(WINDOW_WIDTH / 2.6, 450);
  credits.setCharacterSize(10);
  credits.setColor(sf::Color::Black);

  while(window.isOpen())
  {
    sf::Event event;
    while (window.pollEvent(event)) // process events
    {
      // QUIT
      if (event.type == sf::Event::Closed)
      {
          window.close(); // close the window
          return false;
      }

      // if the user presses any key
      if(event.type == sf::Event::KeyPressed || event.type == sf::Event::MouseButtonPressed)
        return true;
    }

    window.clear(sf::Color(255, 255, 235, 0));

    window.draw(earthSprite);
    window.draw(title);
    window.draw(anyKey);
    window.draw(credits);
    window.display();
  }

  return false;
}
开发者ID:Joshalexjacobs,项目名称:Mikylas-Big-Country-Quiz,代码行数:52,代码来源:main.cpp

示例4: start

void Exterieur::start(sf::RenderWindow &app)
{
	(*Kurt)->setPosition(sf::Vector2f(-100, (*Kurt)->getPosition().y), DROITE);

	while((*Kurt)->getPosition().x < 50)
	{
		update();
		(*Kurt)->deplacer(DROITE, (*Kurt)->getVitesse());
		app.clear(sf::Color::Black);
		afficher(app);
		app.display();
	}
}
开发者ID:Matthieu-Riou,项目名称:Kurt-The-Last-Key,代码行数:13,代码来源:Exterieur.cpp

示例5: draw

void Game::draw() {

        m_window.clear(sf::Color(50, 50, 50));

        for (const auto& wall: m_walls)
                m_window.draw(wall);

        m_window.draw(m_start);
        m_window.draw(m_end);

        m_window.draw(m_pointer);

}
开发者ID:joanrieu,项目名称:ld23-tiny-maze,代码行数:13,代码来源:TinyMaze.cpp

示例6: render

	void render(){
		sf::Vector2f vec1(1, 0), vec2(0, 0);
		gameWindow.clear();
		gameWindow.draw(p1Paddle);
		gameWindow.draw(p2Paddle);

		gameWindow.draw(p1ScoreText);

		gameWindow.draw(p2ScoreText);

		gameWindow.draw(ball);
		gameWindow.display();
	}
开发者ID:minhoolee,项目名称:id-Tech-Files,代码行数:13,代码来源:Main.cpp

示例7: Tips

void TWindows:: Tips(sf::RenderWindow& oknoAplikacji)
{
	//tribe=0;
	option=1;
	while( oknoAplikacji.isOpen() )
	{
		bool fake=false;
		//CZYSZCZENIE OKNA
		oknoAplikacji.clear(sf::Color( 0, 0, 0));

		sf::Texture tlo;
			bool tlolad=tlo.loadFromFile("tlo.png");
			if(tlolad==true)
			{
				sf::Sprite sprit1;
				sprit1.setColor(sf::Color(255, 255, 255, 20));
				sprit1.setPosition(0,0);
				sprit1.setTexture(tlo);
				sprit1.setScale(10,10);
				oknoAplikacji.draw(sprit1);
			}

			tlolad=tlo.loadFromFile("spacja.png");
			if(tlolad==true)
			{
				sf::Sprite sprit1;
				sprit1.setPosition(0,0);
				sprit1.setTexture(tlo);
				oknoAplikacji.draw(sprit1);
			}

		EventsWin(oknoAplikacji, tribe, option, fake, 9);
		if(option==0)
			break;
		oknoAplikacji.display();
	}
	oknoAplikacji.clear(sf::Color( 10, 10, 10 ));
	option=0;
}
开发者ID:WakeCaine,项目名称:TeTTris,代码行数:39,代码来源:TWindows.cpp

示例8: Run

int ScreenOption::Run( sf::RenderWindow& App)
{
	bool running = true;

    App.resetGLStates();

    m_window->SetPosition(sf::Vector2f(App.getSize().x / 2.0f - m_window->GetAllocation().width /2.0f, App.getSize().y / 2.0f - m_window->GetAllocation().height /2.0f));
    m_window->Show(true);
	while(running)
	{
		sf::Event event;
		//Verifing events
		while(App.pollEvent(event))
		{
            m_window->HandleEvent( event );

            if(event.type == sf::Event::Closed)
            {
                running = false;
                App.close();
            }

            if( event.type == sf::Event::KeyPressed)
            {
                if( event.key.code == sf::Keyboard::Escape)
                {
                     m_window->Show(false);
                     return MENU;
                }
            }

            if(m_quit)
            {

                m_window->Show(false);
                m_quit = false;
                return MENU;
            }
        }

        m_desktop.Update( 0.f );

		App.clear();
		App.draw(m_background);
		m_sfgui.Display( App );
		App.draw(currentChoice);
		App.display();
        currentChoice.Update();
	}
return (SCREEN_EXIT);
}
开发者ID:guillaume-gomez,项目名称:MathGame,代码行数:51,代码来源:ScreenOption.cpp

示例9: hshow

void hshow(sf::RenderWindow & window, int tetris, int snake, int tCar){
    Texture hsBackground;
	hsBackground.loadFromFile("images/background.jpg");
	Sprite hSBg(hsBackground);
    Font font;
    font.loadFromFile("game_over.ttf");
    Text hs1("Tetris: "+intToStr(tetris) , font, 20);
    Text hs2("Snake: "+intToStr(snake) , font, 20);
    Text hs3("Tetro car: "+intToStr(tCar) , font, 20);
    Text backB("Back ", font, 20);
    hs1.setPosition(120, 80);
	hs2.setPosition(120, 120);
	hs3.setPosition(120, 160);
	backB.setPosition(120, 200);
	hSBg.setPosition(0, 0);
	bool isHs=1;
	int btNum=0;
    while(isHs){
        hs1.setColor(Color::Magenta);
		hs2.setColor(Color::Magenta);
		hs3.setColor(Color::Magenta);
		if(btNum!=1)
		backB.setColor(Color::Magenta);
		window.clear(Color(129, 181, 221));
		if (IntRect(120, 200, 100, 20).contains(Mouse::getPosition(window))) { backB.setColor(Color::Blue); btNum = 1; }
		sf::Event event;
        while (window.pollEvent(event)){
            if (event.type == sf::Event::Closed){
                window.close();
                return;
        }
            if(event.type == sf::Event::KeyPressed&&(event.key.code==sf::Keyboard::Down||event.key.code==sf::Keyboard::Up)){
                backB.setColor(Color::Blue);
                btNum=1;
            }
            if (Mouse::isButtonPressed(Mouse::Left)||(event.type == sf::Event::KeyPressed&&event.key.code==sf::Keyboard::Return))
		{
		    if (btNum == 1) return;
		    continue;
		}
            continue;
        }
        window.draw(hSBg);
		window.draw(hs1);
		window.draw(hs2);
		window.draw(hs3);
		window.draw(backB);
		window.display();
    }
}
开发者ID:Danshcherbina,项目名称:Software-programing-basics,代码行数:50,代码来源:main.cpp

示例10: redraw

void redraw(bool cells[31][31], sf::RenderWindow &window)
{
	window.clear();
	draw_grid(window);
	for (int i=1;i<30;i++)
		for (int j=1;j<30;j++)
			if (cells[i][j] == true)
			{
				sf::RectangleShape rect(sf::Vector2f(20, 20));
				rect.setPosition(i * 20, j * 20);
				window.draw(rect);
			}
	window.display();
}
开发者ID:MAD-G,项目名称:GOL,代码行数:14,代码来源:main.cpp

示例11: drawGameOverText

void drawGameOverText(sf::RenderWindow &window, int score)			//draw Game Over screen
{
	sf::Font Font;
	Font.loadFromFile("../../assets/MilasianCircaThinPERSONAL.ttf");

	sf::Font FontArial;
	FontArial.loadFromFile("../../assets/arial.ttf");

	sf::Text textGO;
	textGO.setFont(Font);
	textGO.setString("Game Over");
	textGO.setPosition(220, 150);
	textGO.setCharacterSize(100);
	textGO.setColor(sf::Color::Red);
	textGO.setStyle(sf::Text::Bold);


	sf::Text textHS;
	textHS.setFont(FontArial);
	textHS.setString("High Score:");
	textHS.setPosition(500, 100);
	textHS.setCharacterSize(35);
	textHS.setColor(sf::Color::Magenta);
	textHS.setStyle(sf::Text::Bold);


	sf::Text finalScore;
	finalScore.setFont(FontArial);
	finalScore.setString(to_string(score));
	finalScore.setPosition(750, 100);
	finalScore.setCharacterSize(35);
	finalScore.setColor(sf::Color::Magenta);
	finalScore.setStyle(sf::Text::Bold);


	sf::Text reset;
	reset.setFont(Font);
	reset.setString("Press 'A' to play again");
	reset.setPosition(225, 450);
	reset.setCharacterSize(50);
	reset.setColor(sf::Color::White);
	reset.setStyle(sf::Text::Italic);

	window.clear();						//clear every pixel on the screen 
	window.draw(textGO);
	window.draw(reset);
	window.draw(finalScore);
	window.draw(textHS);
	window.display();
}
开发者ID:vihanchaudhry,项目名称:Cookie-game,代码行数:50,代码来源:GameOver.cpp

示例12:

// Draw all resources to the screen.
void screen0::Draw(sf::RenderWindow &window) {
	// Clear the screen.
	window.clear();
	// Draw all resources.
	window.draw(backgroundSprite);
	window.draw(screenTitle);
	window.draw(buttonStart.sprite);
	window.draw(buttonHelp.sprite);
	window.draw(buttonSettings.sprite);
	window.draw(buttonQuit.sprite);
	window.draw(name);
	// Display all changes to the screen.
	window.display();
}
开发者ID:DanielCordell,项目名称:MathsRevisionTool-Coursework-2015,代码行数:15,代码来源:Screen0.cpp

示例13: run

int Menu::run(sf::RenderWindow &window) {
    if (!initialized) {
        initialized = true;
        if (!init_buttons()) return -1;
    }
    if (text[0] == "Easy") {
        cursor_loc = 1;
        blist[1].toggleHighlight(sf::Color::Yellow);
    } else {
        cursor_loc = 0;
        blist[0].toggleHighlight(sf::Color::Yellow);
    } 
    bool selecting = true;
    while (selecting) {
        sf::Event e;
        while (window.pollEvent(e)) {
            if (e.type == sf::Event::Closed) {
                selecting = false;
                cursor_loc = -1;
            } else if (e.type == sf::Event::KeyPressed) {
                if (e.key.code == sf::Keyboard::Up) {
                    if (cursor_loc > 0) {
                        blist[cursor_loc--].toggleHighlight(sf::Color::Yellow);
                        blist[cursor_loc].toggleHighlight(sf::Color::Yellow);
                    }
                } else if (e.key.code == sf::Keyboard::Down) {
                    if (cursor_loc < blist.size() - 1) {
                        blist[cursor_loc++].toggleHighlight(sf::Color::Yellow);
                        blist[cursor_loc].toggleHighlight(sf::Color::Yellow);
                    }
                } else if (e.key.code == sf::Keyboard::Z) {
                    blist[cursor_loc].toggleHighlight(sf::Color::Yellow);
                    selecting = false;
                } else if (e.key.code == sf::Keyboard::X) {
                    blist[cursor_loc].toggleHighlight(sf::Color::Yellow);
                    selecting = false;
                    cursor_loc = numbuttons - 1;
                }
            }
        }

        window.clear(sf::Color::White);
        for (int i = 0; i < blist.size(); i++) {
            blist[i].draw(window);
        }
        window.display();
    }
    return ret_signal[cursor_loc];
}
开发者ID:kikiotsuka,项目名称:TouhouClone,代码行数:49,代码来源:menu.cpp

示例14: display_world

    void display_world(b2World& world,sf::RenderWindow& render)
    {
        world.Step(1.0/60,int32(8),int32(3));

        render.clear();

        for (b2Body* body=world.GetBodyList(); body!=nullptr; body=body->GetNext())
        {   
            sf::Shape* shape = static_cast<sf::Shape*>(body->GetUserData());
            shape->setPosition(converter::meters_to_pixels(body->GetPosition().x),converter::meters_to_pixels(body->GetPosition().y));
            shape->setRotation(converter::rad_to_deg<double>(body->GetAngle()));
            render.draw(*shape);
        }

        render.display();
    }
开发者ID:Krozark,项目名称:SFML-book,代码行数:16,代码来源:main.cpp

示例15: DrawGame

void DrawGame()
{
	GameWin.clear();

	GameWin.draw(PauseText);
	
	GameWin.draw(ground);

	GameWin.draw(wall);
	GameWin.draw(wall2);

	GameWin.draw(box);
	GameWin.draw(box2);

	GameWin.display();
}
开发者ID:gAndy50,项目名称:Misc,代码行数:16,代码来源:main.cpp


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