Advertisement
Guest User

Untitled

a guest
May 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. //Xadrez
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. enum pecaXadrez {
  7.     peao = 1,
  8.     rei = 2,
  9.     rainha = 3,
  10.     bispo = 4,
  11.     cavalo = 5,
  12.     torre = 6
  13. };
  14.  
  15. class posicao {
  16.     public:
  17.         int x, y;
  18.         int peca;
  19.         posicao() {
  20.             x = 0.0f;
  21.             y = 0.0f;
  22.             peca = 0;
  23.         }
  24.         posicao(int a, int b, int nPeca) {
  25.             x = a;
  26.             y = b;
  27.             peca = nPeca;
  28.         }
  29.         posicao(int a, int b) {
  30.             x = a;
  31.             y = b;
  32.             peca = 0;
  33.         }
  34. };
  35.  
  36. const int tamanhoTabuleiro = 4;
  37.  
  38. void Render(posicao tabuleiro[]) {
  39.     int cont = 0;
  40.     for (int x = 0; x < tamanhoTabuleiro; ++x) {
  41.         for (int y = 0; y < tamanhoTabuleiro; ++y) {
  42.             ++cont;
  43.             cout << "[" << tabuleiro[cont].peca << "]";
  44.         }
  45.     }
  46. }
  47.  
  48. void CriarTabuleiro(posicao tabuleiro[]) {
  49.     int cont = 0;
  50.     for (int x = 0; x < tamanhoTabuleiro; ++x) {
  51.         for (int y = 0; y < tamanhoTabuleiro; ++y) {
  52.             ++cont;
  53.             tabuleiro[cont] = posicao(x, y, 0);
  54.         }
  55.     }
  56. }
  57.  
  58. int main() {
  59.     posicao tabuleiro[tamanhoTabuleiro*tamanhoTabuleiro];
  60.     CriarTabuleiro(tabuleiro);
  61.     Render(tabuleiro);
  62.     cout << "Teste\n";
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement