fork download
  1. #include <SFML/Graphics.hpp>
  2. #include <string>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using namespace sf; using namespace std;
  7.  
  8. class Obj {
  9. public:
  10. string path;
  11. Sprite sprite;
  12. Texture texture;
  13. Obj(string Path) : path(Path)
  14. {
  15. if (!texture.loadFromFile(Path))
  16. {
  17. cout << "load texture fail" << endl;
  18. }
  19. sprite.setTexture(texture);
  20. }
  21.  
  22. Obj(const Obj& o): path(o.path), texture(o.texture)
  23. {
  24. this->sprite.setTexture(this->texture);
  25. }
  26.  
  27. Obj(Obj&& o): path(o.path)
  28. {
  29. swap(this->texture, o.texture);
  30. this->sprite.setTexture(this->texture);
  31. }
  32. };
  33.  
  34. vector<Obj> obj;
  35.  
  36. int countObjects = 0;
  37.  
  38. void createObject(string Path){
  39. countObjects++;
  40. obj.emplace_back(Path);
  41. }
  42.  
  43.  
  44. int main() {
  45. RenderWindow window(VideoMode(800, 600), L"name", Style::Default);
  46. createObject("res/obj1.png");
  47. createObject("res/obj2.png");
  48.  
  49.  
  50. Event event;
  51. while (window.isOpen()){
  52. while (window.pollEvent(event)) {
  53. if (event.type == Event::Closed ||
  54. (event.type == sf::Event::KeyPressed && event.key.code == Keyboard::Escape))
  55. window.close();
  56. }
  57.  
  58.  
  59. window.clear();
  60. window.draw(obj[0].sprite);
  61. window.display();
  62. }
  63. return 0;
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:29: fatal error: SFML/Graphics.hpp: No such file or directory
compilation terminated.
stdout
Standard output is empty