Strzyk

układ

Jan 25th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #define W 800
  3. #define H 600
  4. #define OFF 10
  5. int main()
  6. {
  7. int xx[]={OFF,OFF,W-OFF,W-OFF,OFF};
  8. int yy[]={OFF,H-OFF,H-OFF,OFF,OFF};
  9. int i;
  10. sf::VertexArray linie(sf::Lines);
  11. for(i=0;i<4;i++){
  12. linie.append(sf::Vector2f(xx[i],yy[i]));
  13. linie.append(sf::Vector2f(xx[i+1],yy[i+1]));
  14. }
  15. linie.append(sf::Vector2f(OFF,H/2));
  16. linie.append(sf::Vector2f(W-OFF,H/2));
  17. linie.append(sf::Vector2f(W/2,H-OFF));
  18. linie.append(sf::Vector2f(W/2,OFF));
  19. sf::VertexArray strzalki(sf::Triangles);
  20. strzalki.append(sf::Vector2f(W/2-10,OFF+10));
  21. strzalki.append(sf::Vector2f((W/2),OFF));
  22. strzalki.append(sf::Vector2f((W/2)+10,OFF+10));
  23. strzalki.append(sf::Vector2f(W-OFF-10,(H/2)+10));
  24. strzalki.append(sf::Vector2f(W-OFF,H/2));
  25. strzalki.append(sf::Vector2f(W-OFF-10,(H/2)-10));
  26.  
  27. // Create the main window
  28. sf::RenderWindow window(sf::VideoMode(W,H), "SFML window");
  29.  
  30.  
  31.  
  32. // Start the game loop
  33. while (window.isOpen())
  34. {
  35. // Process events
  36. sf::Event event;
  37. while (window.pollEvent(event))
  38. {
  39. // Close window : exit
  40. if (event.type == sf::Event::Closed)
  41. window.close();
  42. }
  43.  
  44. // Clear screen
  45. window.clear();
  46.  
  47. window.draw(linie);
  48. window.draw(strzalki);
  49.  
  50. // Update the window
  51. window.display();
  52. }
  53.  
  54. return EXIT_SUCCESS;
  55. }
Add Comment
Please, Sign In to add comment