Advertisement
Guest User

ches

a guest
Oct 19th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.62 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <iostream>
  3. #include <stdlib.h>
  4.  
  5. int main(){
  6.     sf::RenderWindow window(sf::VideoMode(600, 600), "Chess");
  7. //brancas
  8.     sf::RectangleShape brancopeao1(sf::Vector2f(75.f, 75.f));
  9.     sf::RectangleShape brancopeao2(sf::Vector2f(75.f, 75.f));
  10.     sf::RectangleShape brancopeao3(sf::Vector2f(75.f, 75.f));
  11.     sf::RectangleShape brancopeao4(sf::Vector2f(75.f, 75.f));
  12.     sf::RectangleShape brancopeao5(sf::Vector2f(75.f, 75.f));
  13.     sf::RectangleShape brancopeao6(sf::Vector2f(75.f, 75.f));
  14.     sf::RectangleShape brancopeao7(sf::Vector2f(75.f, 75.f));
  15.     sf::RectangleShape brancopeao8(sf::Vector2f(75.f, 75.f));
  16.     sf::RectangleShape brancotorre1(sf::Vector2f(75.f, 75.f));
  17.     sf::RectangleShape brancotorre2(sf::Vector2f(75.f, 75.f));
  18.     sf::RectangleShape brancobispo1(sf::Vector2f(75.f, 75.f));
  19.     sf::RectangleShape brancobispo2(sf::Vector2f(75.f, 75.f));
  20.     sf::RectangleShape brancocavalo1(sf::Vector2f(75.f, 75.f));
  21.     sf::RectangleShape brancocavalo2(sf::Vector2f(75.f, 75.f));
  22.     sf::RectangleShape brancorainha(sf::Vector2f(75.f, 75.f));
  23.     sf::RectangleShape brancorei(sf::Vector2f(75.f, 75.f));
  24. //pretas
  25.     sf::RectangleShape pretopeao1(sf::Vector2f(75.f, 75.f));
  26.     sf::RectangleShape pretopeao2(sf::Vector2f(75.f, 75.f));
  27.     sf::RectangleShape pretopeao3(sf::Vector2f(75.f, 75.f));
  28.     sf::RectangleShape pretopeao4(sf::Vector2f(75.f, 75.f));
  29.     sf::RectangleShape pretopeao5(sf::Vector2f(75.f, 75.f));
  30.     sf::RectangleShape pretopeao6(sf::Vector2f(75.f, 75.f));
  31.     sf::RectangleShape pretopeao7(sf::Vector2f(75.f, 75.f));
  32.     sf::RectangleShape pretopeao8(sf::Vector2f(75.f, 75.f));
  33.     sf::RectangleShape pretotorre1(sf::Vector2f(75.f, 75.f));
  34.     sf::RectangleShape pretotorre2(sf::Vector2f(75.f, 75.f));
  35.     sf::RectangleShape pretobispo1(sf::Vector2f(75.f, 75.f));
  36.     sf::RectangleShape pretobispo2(sf::Vector2f(75.f, 75.f));
  37.     sf::RectangleShape pretocavalo1(sf::Vector2f(75.f, 75.f));
  38.     sf::RectangleShape pretocavalo2(sf::Vector2f(75.f, 75.f));
  39.     sf::RectangleShape pretorainha(sf::Vector2f(75.f, 75.f));
  40.     sf::RectangleShape pretorei(sf::Vector2f(75.f, 75.f));
  41.     //tabuleiro
  42.     sf::RectangleShape board(sf::Vector2f(600.f, 600.f));
  43.     sf::Texture whitepiecesTexture;
  44.     sf::Texture blackpiecesTexture;
  45.     sf::Texture boardTexture;
  46.     whitepiecesTexture.loadFromFile("pieceswhite.png");
  47.     blackpiecesTexture.loadFromFile("piecesblack.png");
  48.     boardTexture.loadFromFile("board.png");
  49.     brancopeao1.setTexture(&whitepiecesTexture);
  50.  
  51.     sf::Vector2u textureSize = whitepiecesTexture.getSize();
  52.     textureSize.x /= 3;
  53.     textureSize.y /= 2;
  54. //brancas
  55.     brancopeao1.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  56.     brancopeao2.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  57.     brancopeao3.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  58.     brancopeao4.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  59.     brancopeao5.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  60.     brancopeao6.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  61.     brancopeao7.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  62.     brancopeao8.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  63.     brancotorre1.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 1, textureSize.x, textureSize.y));
  64.     brancotorre2.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 1, textureSize.x, textureSize.y));
  65.     brancobispo1.setTextureRect(sf::IntRect(textureSize.x * 2, textureSize.y * 1, textureSize.x, textureSize.y));
  66.     brancobispo2.setTextureRect(sf::IntRect(textureSize.x * 2, textureSize.y * 0, textureSize.x, textureSize.y));
  67.     brancocavalo1.setTextureRect(sf::IntRect(textureSize.x * 1, textureSize.y * 0, textureSize.x, textureSize.y));
  68.     brancocavalo2.setTextureRect(sf::IntRect(textureSize.x * 1, textureSize.y * 0, textureSize.x, textureSize.y));
  69.     brancorainha.setTextureRect(sf::IntRect(textureSize.x * 1, textureSize.y * 1, textureSize.x, textureSize.y));
  70.     brancorei.setTextureRect(sf::IntRect(textureSize.x * 2, textureSize.y * 1, textureSize.x, textureSize.y));
  71. //pretas
  72.     pretopeao1.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  73.     pretopeao2.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  74.     pretopeao3.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  75.     pretopeao4.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  76.     pretopeao5.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  77.     pretopeao6.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  78.     pretopeao7.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  79.     pretopeao8.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 0, textureSize.x, textureSize.y));
  80.     pretotorre1.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 1, textureSize.x, textureSize.y));
  81.     pretotorre2.setTextureRect(sf::IntRect(textureSize.x * 0, textureSize.y * 1, textureSize.x, textureSize.y));
  82.     pretobispo1.setTextureRect(sf::IntRect(textureSize.x * 2, textureSize.y * 1, textureSize.x, textureSize.y));
  83.     pretobispo2.setTextureRect(sf::IntRect(textureSize.x * 2, textureSize.y * 0, textureSize.x, textureSize.y));
  84.     pretocavalo1.setTextureRect(sf::IntRect(textureSize.x * 1, textureSize.y * 0, textureSize.x, textureSize.y));
  85.     pretocavalo2.setTextureRect(sf::IntRect(textureSize.x * 1, textureSize.y * 0, textureSize.x, textureSize.y));
  86.     pretorainha.setTextureRect(sf::IntRect(textureSize.x * 1, textureSize.y * 1, textureSize.x, textureSize.y));
  87.     pretorei.setTextureRect(sf::IntRect(textureSize.x * 2, textureSize.y * 1, textureSize.x, textureSize.y));
  88.  
  89.     while (window.isOpen())
  90.     {
  91.         sf::Event event;
  92.         while (window.pollEvent(event))
  93.         {
  94.             if (event.type == sf::Event::Closed)
  95.                 window.close();
  96.         }
  97.  
  98.         window.clear(sf::Color::Black);
  99.         brancopeao1.setPosition(0,0);
  100.         window.draw(brancopeao1);
  101.        
  102.         window.draw(board);
  103.         window.display();
  104.     }
  105.  
  106.     return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement