AllenYuan

Untitled

May 30th, 2020
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. using namespace sf;
  3.  
  4. int main()
  5. {
  6. RenderWindow app(VideoMode(640, 480), "Car Racing Game!");
  7. app.setFramerateLimit(60);
  8.  
  9. Texture t1, t2;
  10. t1.loadFromFile("/Users/alleyuan/code-snippets/16_games/07 Top Down Racing/images/background.png");
  11. t2.loadFromFile("/Users/alleyuan/code-snippets/16_games/07 Top Down Racing/images/car.png");
  12.  
  13. Sprite sBackground(t1), sCar(t2);
  14. sCar.setPosition(300, 300);
  15.  
  16. while (app.isOpen())
  17. {
  18. Event e;
  19. while (app.pollEvent(e))
  20. {
  21. if (e.type == Event::Closed)
  22. app.close();
  23. }
  24.  
  25. app.clear(Color::White);
  26. app.draw(sBackground);
  27.  
  28. sCar.setColor(Color::Red);
  29. app.draw(sCar);
  30.  
  31. app.display();
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment