So I was trying to make a c++ ping pong game for school and it has no errors and when I click f5 it reveals 4 errors on the lines: 99,221,287,312 please if anyone can help me I would be happy (✿◠‿◠)
program:
1 #include <iostream>
2 #include <dos.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <windows.h>
6 #include <time.h>
7 #include <conio.h>
8
9
10
11 using namespace std;
12 char l[] = "ººººº";
13 int i;
14
15 HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
16 COORD CursorPosition;
17
18 void gotoxy(int x, int y)
19 {
20 CursorPosition.X = x;
21 CursorPosition.Y = y;
22 SetConsoleCursorPosition(console, CursorPosition);
23 }
24
25 void setcursor(bool visible, DWORD size){
27 if (size == 0)
28 {
29 size = 20;
30 }
31 CONSOLE_CURSOR_INFO lpCursor;
32 lpCursor.bVisible = visible;
33 lpCursor.dwSize = size;
34 SetConsoleCursorInfo(console, &lpCursor);
35 }
36
37 void printBorder() {
38
39 for (i = 2; i <= 79; i++) {
40 gotoxy(i, 1);
41 cout << '-';
42 gotoxy(i, 25);
43 cout << '-';
44
45 }
46 for (i = 1; i <= 25; i++) {
47 gotoxy(2, i);
48 cout << '|';
49 gotoxy(79, i);
50 cout << '|';
51
52 }
53
54
55
56 }
57
58
59 void setplayers() {
60 system("cls");
61 printBorder();
62 gotoxy(4, 3);
63 cout << "Pontuação: 0";
64 gotoxy(50, 3);
65 cout << " precione Esc para sair do jogo";
66 for (i = 3; i <= 78; i++) {
67 gotoxy(i, 4);
68 cout << '-';
69
70 }
71 for (i = 0; i <= strlen(l); i++) {
72 gotoxy(5, 5 + 1);
73 cout << '-';
74
75 }
76
77 for (i = 0; i <= strlen(l); i++) {
78 gotoxy(76, 5 + i);
79 cout << l[i];
80
81 }
82
83 }
84
85 void gameplay() {
86
87 setplayers();
88
89 void displayMenu();
90 int sc = 0, pp = 0, st = 1;
91 int c = 5, k = 5, x = 73, y = 6 + rand() % 15;
92 int d = rand() % 2, px, py;
93 int op = 1, go = 1;
94 int rld = 0, rlu = 0, lru = 0, lrd = 0;
95
96 while (1) {
97
98 if (go == 1) {
99 while (!kbhit() && op) {
100 px = x;
101 py = y;
102 gotoxy(x, y);
103 cout << "O";
104 Sleep(50);
105 gotoxy(x, y);
106 cout << " ";
107
108 if (st == 1) {
109 st = 0;
110 if (d == 0) {
111 x--;
112 y++;
113
114 }
115 else {
116 x--;
117 y--;
118 }
119
120 }
121
122 if (rld) {
123 x--;
124 y++;
125 }
126 if (rld) {
127 x--;
128 y++;
129 }
130 if (rlu) {
131 x--;
132 y++;
133 }
134 if (lru) {
135 x--;
136 y++;
137 }
138 if (lrd) {
139 x--;
140 y++;
141 }
142 if (x < px && y > py) rld = 1;
143 if (x < px && y > py) rlu = 1;
144 if (y == 5 && rlu) {
145 rld = 1;
146 rlu = 0;
147 }
148 if (y == 24 && rld) {
149 rld = 1;
150 rlu = 0;
151 }
152 if (x == 6 && rlu) {
153 rld = 1;
154 rlu = 0;
155 }
156 if (x == 6 && rld) {
157 rld = 1;
158 rlu = 0;
159 }
160 if (x == 5 && lru) {
161 rld = 1;
162 rlu = 0;
163 }
164 if (x == 24 && lrd) {
165 rld = 1;
166 rlu = 0;
167 }
168 if (x == 75 && lrd) {
169 rld = 1;
170 rlu = 0;
171 }
172 if (x == 75 && lru) {
173 rld = 1;
174 rlu = 0;
175 }
176
177 if (x == 75 || x == 6) {
178 Sleep(50);
179 }
180 if (y == 5 || x == 24) {
181 Sleep(50);
182 }
183
184 if (lru || lrd) {
185 if (y >= 6 && y <= 22) {
186 if (y > k + strlen(l) - 3) {
187 gotoxy(76, k + strlen(l));
188 cout << "º";
189 gotoxy(76, k);
190 if (k != 4) cout << ' ';
191 k++;
192 }
193 if (y < k + strlen(l) - 3) {
194 gotoxy(76, k);
195 cout << "º";
196 gotoxy(76, k + strlen(l));
197 if (k + strlen(l) != 25) cout << ' ';
198 k--;
199 }
200 }
201
202
203 }
204
205
206 if (x == 6 && (y<x || y >c + strlen(l) - 1)) {
207 gotoxy(x, y);
208 cout << "PERDESTE !Pressiona 'r' ou enter para jogar outra vez!";
209 op = 0;
210 break;
211 }
212 if (x == 6 && op == 1) {
213
214 gotoxy(4, 3);
215 cout << "Pontuação:" << ++sc;
216 }
217
218 }
219 }
220
221 char ch = getch();
222
223 if (ch == ' ' && op == 1) {
224 pp = 1;
225 go = 0;
226 gotoxy(22, 12);
227 cout << "JOGO PAUSADO ! PRESSIONE ENTER PARA CONTINUAR !";
228
229 }
230
231 if (ch == 13 && pp && pp == 1) {
232 pp = 0;
233 go = 1;
234 gotoxy(22, 12);
235 }
236 if ((ch == 'r' || ch == 'R' || ch == 13) && op == 0) {
237 {
238 op = 1;
239 gameplay();
240 break;
241 }
242
243 if ((ch == 's' || ch == 'S' || ch == 80) && c <= 19 && op) {
244 gotoxy(5, c + strlen(l));
245 cout << "º";
246 gotoxy(5, c);
247 cout << ' ';
248 c++;
249 }
250
251 if ((ch == 'w' || ch == 'W' || ch == 72) && c >= 6 && op) {
252 gotoxy(5, c - 1);
253 cout << "º";
254 gotoxy(5, c + 4);
255 cout << ' ';
256 c--;
257 }
258 if (ch == 27) {
259 displayMenu();
260 break;
261 }
262 }
263 };
264
265
266
267 }
268 void displayMenu() {
269 system("cls");
270 void htwindow();
271 int cp = 1;
272 gotoxy(34, 4);
273 cout << "PING PONG";
274 for (i = 8; i <= 73; i++) {
275 gotoxy(i, 6);
276 cout << '-';
277 }
278 gotoxy(34, 10);
279 cout << "1. JOGAR";
280 gotoxy(34, 12);
281 cout << "2. COMO JOGAR";
282 gotoxy(34, 14);
283 cout << "3. SAIR";
284 gotoxy(14, 16);
285 cout << "OPÇÕES DO MENU";
286
287 char op = getche();
288 if (op == '1')gameplay();
289 if (op == '2')htwindow();
290 if (op == '3')exit(0);
291
292
293 }
294
295 void htpwindow() {
296 system("cls");
297 printBorder();
298 gotoxy(4, 3);
299 cout << "INSTRUÇÕES";
300 gotoxy(4, 4);
301 cout << "------------";
302 gotoxy(4, 5);
303 cout << "- Pressione W ou a seta para cima para subir";
304 gotoxy(4, 7);
305 cout << "- Pressione S ou a seta para baixo para descer";
306 gotoxy(4, 9);
307 cout << "- Pressioneo espaço para pausar o jogo";
308 gotoxy(4, 11);
309 cout << "- Pressione esc para sair do jogo";
310 gotoxy(4, 15);
311 cout << "- Pressione qualquer tecla para ir para o menu";
312 getch();
313 displayMenu();
314
315 }
316
317 int main() {
318 setcursor(0, 0);
319 srand((unsigned)time(NULL));
320 system("cls");
321
322 }
What I have tried:
i tried to click in the error but i didnt see nothing...
I'm desperate because I can't solve this huge problem.
If anyone wants to help I would be very grateful.