La simu multi-agents qui repeint une image, mais en c++ Boilerplate pompé ici : https://github.com/andrew-r-king/sfml-vscode-boilerplate
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

test_RenderWindow.cpp 961B

123456789101112131415161718192021222324252627282930313233
  1. #include <catch2/catch.hpp>
  2. // This example is a bit silly, but you get the idea
  3. TEST_CASE("sf::RenderWindow", "[renderwindow]") {
  4. sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
  5. REQUIRE(window.getSize().x == 200);
  6. REQUIRE(window.getSize().y == 200);
  7. sf::CircleShape shape(window.getSize().x/2);
  8. shape.setFillColor(sf::Color::White);
  9. REQUIRE(shape.getRadius() == 100.0f);
  10. REQUIRE(shape.getFillColor() == sf::Color::White);
  11. REQUIRE(static_cast<int>(shape.getLocalBounds().width) == 198); // 🤔
  12. REQUIRE(static_cast<int>(shape.getLocalBounds().height) == 200);
  13. sf::Texture shapeTexture;
  14. shapeTexture.loadFromFile("content/sfml.png");
  15. shape.setTexture(&shapeTexture);
  16. REQUIRE(shapeTexture.getSize().x == 256);
  17. REQUIRE(shapeTexture.getSize().y == 256);
  18. REQUIRE(shape.getTexture() == &shapeTexture);
  19. // Show the RenderWindow once
  20. window.clear();
  21. window.draw(shape);
  22. window.display();
  23. REQUIRE(window.isOpen() == true);
  24. }