SHOW:
|
|
- or go back to the newest paste.
1 | #include <iostream> | |
2 | #include<stdio.h> | |
3 | using namespace std; | |
4 | ||
5 | int pionkiBiale = 12; | |
6 | int pionkiCzarne = 12; | |
7 | ||
8 | void rysuj(int plansza[8][8], bool ruchBialy) | |
9 | { | |
10 | cout << "Pozostale biale pionki:" << pionkiBiale << endl <<"Pozostale czarne pionki:" << pionkiCzarne << endl; | |
11 | if (ruchBialy) | |
12 | { | |
13 | cout << "Ruch wykonuja biale" << endl; | |
14 | } | |
15 | else | |
16 | { | |
17 | cout << "Ruch wykonuja czarne" << endl; | |
18 | } | |
19 | ||
20 | cout << " ABCDEFGH" << endl; | |
21 | for (int i = 0; i < 8; i++) | |
22 | { | |
23 | printf("\033[37m"); | |
24 | cout << i+1; | |
25 | for (int j = 0; j < 8; j++) | |
26 | { | |
27 | if (plansza[i][j]==0) | |
28 | { | |
29 | //rysowanie białego pola | |
30 | printf("\033[37m"); | |
31 | cout << '\xFE'; | |
32 | } | |
33 | else if (plansza[i][j]==1) | |
34 | { | |
35 | //rysowanie czarnego pola | |
36 | printf("\033[30m"); | |
37 | cout << ' '; | |
38 | } | |
39 | else if (plansza[i][j] == 2) | |
40 | { | |
41 | //rysowanie czerwonego(czarnego) pionka | |
42 | printf("\033[31m"); | |
43 | cout << "X"; | |
44 | } | |
45 | else if (plansza[i][j] == 3) | |
46 | { | |
47 | //rysowanie bialego pionka | |
48 | printf("\033[37m"); | |
49 | cout << "X"; | |
50 | } | |
51 | } | |
52 | cout << endl; | |
53 | } | |
54 | } | |
55 | ||
56 | ||
57 | int main() | |
58 | { | |
59 | bool ruchBialy = true; | |
60 | ||
61 | int plansza[8][8]; | |
62 | int kolumnaSkad; | |
63 | int wierszSkad; | |
64 | int kolumnaDokad; | |
65 | int wierszDokad; | |
66 | for (int i = 0; i < 8; i++) | |
67 | { | |
68 | for (int j = 0; j < 8; j++) | |
69 | { | |
70 | if ((i + j) % 2 == 0) | |
71 | { | |
72 | //pola biale | |
73 | plansza[i][j] = 0; | |
74 | } | |
75 | else | |
76 | { | |
77 | if (i < 3) | |
78 | { | |
79 | //pionki czarne | |
80 | plansza[i][j] = 2; | |
81 | } | |
82 | else if (i >= 5) | |
83 | { | |
84 | //pionki biale | |
85 | plansza[i][j] = 3; | |
86 | } | |
87 | else | |
88 | { | |
89 | //pola czarne | |
90 | plansza[i][j] = 1; | |
91 | } | |
92 | } | |
93 | } | |
94 | } | |
95 | ||
96 | ||
97 | while (pionkiBiale > 0 and pionkiCzarne > 0) | |
98 | { | |
99 | printf("\033[H\033[J"); | |
100 | rysuj(plansza, ruchBialy); | |
101 | cout << "Podaj litere z ktorej kolumny pionek chcesz poruszyc" << endl; | |
102 | char tmp; | |
103 | cin >> tmp; | |
104 | kolumnaSkad = int(tmp) - 65; | |
105 | cout << "Podaj cyfre z ktorego wiersza pionek chcesz poruszyc" << endl; | |
106 | cin >> wierszSkad; | |
107 | wierszSkad = wierszSkad - 1; | |
108 | ||
109 | cout << "Podaj litere do ktorej kolumny pionek chcesz poruszyc" << endl; | |
110 | cin >> tmp; | |
111 | kolumnaDokad = int(tmp) - 65; | |
112 | cout << "Podaj cyfre do ktorego wiersza pionek chcesz poruszyc" << endl; | |
113 | cin >> wierszDokad; | |
114 | wierszDokad = wierszDokad - 1; | |
115 | } | |
116 | if (pionkiBiale > 0) | |
117 | { | |
118 | cout << "Wygraly biale" << endl; | |
119 | } | |
120 | else | |
121 | { | |
122 | cout << "Wygraly czarne" << endl; | |
123 | } | |
124 | ||
125 | } | |
126 | ||
127 |