Me saltan 2 errores al compilar en el int main, es un juego de serpiente en c++
Publicado por Rockama (4 intervenciones) el 07/10/2020 23:55:22
Soy nuevo y empece a programar un juego de serpiente pero me salta un error que no entiendo en el int main().
Hola soy nuevo y estoy aprendiendo a programar por mi parte en c++ pero me sale un error en el int main(), si pueden ayudarme el codigo es de un juego de serpiente.
Los errores que me aparecen son los siguientes:
73 11 C:\Users\Usuario\Documents\Juego de serpiente\main.cpp [Error] a function-definition is not allowed here before '{' token
104 1 C:\Users\Usuario\Documents\Juego de serpiente\main.cpp [Error] expected '}' at end of input
Les agradezco la ayuda.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#define ARRIBA 72
#define IZQUIERDA 75
#define DERECHA 77
#define ABAJO 80
#define ESC 27
int cuerpo[200][2];
int n = 1;
int tan = 3;
int x = 10 , y = 12;
char tecla;
void gotoxy(int x, int y)
{
HANDLE hCon;
COORD dwPos;
dwPos.X = x;
dwPos.Y = y;
hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hCon,dwPos);
}
void pintar(){
//lineas horizontales
for(int i = 2 ; i < 78 ; i++){
gotoxy(i,3); printf("%c",205);
gotoxy(i,23); printf("%c",205);
}
//lineas verticales
for(int i = 4 ; i < 23 ; i++){
gotoxy(2,i); printf("%c",186);
gotoxy(77,i); printf("%c",186);
}
// esquina
gotoxy(2,3); printf("%c",201);
gotoxy(2,23); printf("%c",200);
gotoxy(77,3); printf("%c",187);
gotoxy(77,23); printf("%c",188);
}
void guardar_posicion(){
cuerpo[n][0] = x;
cuerpo[n][1] = y;
n ++;
if(n== tan) n = 1;
}
void dibujar_cuerpo(){
for(int i = 1 ; i < tan ; i++){
gotoxy(cuerpo[i][0] , cuerpo[i][1]); printf("*");
}
}
void borrar_cuerpo(){
for(int i = 1 ; i < tan ; i++){
gotoxy(cuerpo[i][0] , cuerpo[i][1]); printf(" ");
}
int main(){
cuerpo[0][0] = 3;
cuerpo[0][1] = 5;
cuerpo[1][0] = 4;
cuerpo[1][1] = 5;
cuerpo[2][0] = 5;
cuerpo[2][1] = 5;
for(int j = 0 ; j <3 ;j++){
gotoxy(cuerpo[j][0],cuerpo[j][1]);
printf("*");
}
while(tecla != ESC){
borrar_cuerpo();
guardar_posicion();
dibujar_cuerpo();
x ++;
Sleep(20);
}
pintar();
system("pause>null");
return 0;
}
Valora esta pregunta


0