Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Xadrez
- #include <iostream>
- using namespace std;
- enum pecaXadrez {
- peao = 1,
- rei = 2,
- rainha = 3,
- bispo = 4,
- cavalo = 5,
- torre = 6
- };
- class posicao {
- public:
- int x, y;
- int peca;
- posicao() {
- x = 0.0f;
- y = 0.0f;
- peca = 0;
- }
- posicao(int a, int b, int nPeca) {
- x = a;
- y = b;
- peca = nPeca;
- }
- posicao(int a, int b) {
- x = a;
- y = b;
- peca = 0;
- }
- };
- const int tamanhoTabuleiro = 4;
- void Render(posicao tabuleiro[]) {
- int cont = 0;
- for (int x = 0; x < tamanhoTabuleiro; ++x) {
- for (int y = 0; y < tamanhoTabuleiro; ++y) {
- ++cont;
- cout << "[" << tabuleiro[cont].peca << "]";
- }
- }
- }
- void CriarTabuleiro(posicao tabuleiro[]) {
- int cont = 0;
- for (int x = 0; x < tamanhoTabuleiro; ++x) {
- for (int y = 0; y < tamanhoTabuleiro; ++y) {
- ++cont;
- tabuleiro[cont] = posicao(x, y, 0);
- }
- }
- }
- int main() {
- posicao tabuleiro[tamanhoTabuleiro*tamanhoTabuleiro];
- CriarTabuleiro(tabuleiro);
- Render(tabuleiro);
- cout << "Teste\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement