AllenYuan

chop rect

May 24th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <time.h>
  3. using namespace sf;
  4.  
  5. int main()
  6. {
  7.   RenderWindow window(VideoMode(320, 480), "The Game!"); // window config
  8.  
  9.   Texture t;
  10.   t.loadFromFile("/Users/alleyuan/code-snippets/16_games/01 Tetris/images/tiles.png"); // load sprite. replace my absolute path
  11.  
  12.   Sprite s(t);
  13.   s.setTextureRect(IntRect(0,0,18,18));
  14.  
  15.   while (window.isOpen()) // game loop
  16.   {
  17.     Event e;
  18.     while (window.pollEvent(e)) // close window
  19.     {
  20.       if (e.type == Event::Closed)
  21.         window.close();
  22.     }
  23.  
  24.     window.clear(Color::White); // draw tiles
  25.     window.draw(s);
  26.     window.display();
  27.   }
  28.  
  29.   return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment