Dev - C++ - problemas de copilacion

 
Vista:

problemas de copilacion

Publicado por Nelvis (1 intervención) el 13/09/2020 01:06:44
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
105
106
107
#include<windows.h>
#include<conio.h>
 
#define ARRIBA 72
#define ISQUIERDA 75
#define DERECHA 77
#define ABAJO 80
 
void gotoxy(int x, int y){
	HANDLE hCon;
	hCon = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD dwPos;
	dwPos.X = x;
	dwPos.Y = y;
 
	SetConsoleCursorPosition(hCon, dwPos);
 
}
void OcultarCursor(){
	HANDLE hCon;
	hCon = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO cci;
	cci.dwSize = 20;
	cci.bVisible = FALSE;
 
	SetConsoleCursorInfo(hCon,&cci);
 
}
 
void pintar_limites(){
	for(int i= 2 ; i<78 ; i++ ){
 
	 gotoxy(i,2);  printf("%c",205);
	 gotoxy(i,33); printf("%c", 205);
}
    for(int i =4 ; i < 33 ; i++){
    	gotoxy(2,i); printf("%c", 186);
    	gotoxy(77,i); printf("%c", 186);
	}
	 gotoxy(2,3); printf("%c",201);
	 gotoxy(2,33); printf("%c",200);
	 gotoxy(77,3); printf("%c",187);
	 gotoxy(77,33); printf("%c",188);
}
 
class NAVE{
 
    int x,y;
 
public:
    NAVE(int _x, int _y, int_corazones): x(_x), y(_y), corazones(_corazones){}
     void pintar();
     void borrar();
     void mover();
     void pintar_corazones();
};
 
 
void NAVE::pintar(){
	gotoxy(x,y); printf("   %c",30);
	gotoxy(x,y+1);printf("  %c%c%c",40,207,41);
	gotoxy(x,y+2);printf(" %c%c%c%c%c",30,190,207,190,30);
	gotoxy(x,y+3);printf("%c%c%c %c%c%c",30,40,190,190,40,30);
 
}
void NAVE::borrar(){
    gotoxy(x,y);   printf("      ");
    gotoxy(x,y+1); printf("      ");
    gotoxy(x,y+2); printf("      ");
    gotoxy(x,y+3); printf("       ");
}
void NAVE::mover(){
	if(kbhit())
	{
			char tecla = getch();
		    borrar();
			if(tecla ==ISQUIERDA && x>3) x--;
			if(tecla ==DERECHA && x+6 < 76) x++;
			if(tecla ==ARRIBA && y > 4) y--;
			if(tecla ==ABAJO && y+3 < 32) y++;
		    pintar();
		    pintar_corazones();
		}
 
 
}
void NAVE::pintar_corazones(){
	gotoxy(64,2); printf("salud")
	gotoxy(70,2;) printf("     ")
	for(int i=0 ; i < corazones ; i++){
 
	      gotoxy(70+i,2); printf("%c",3);
}
int main(){
    pintar_limites();
	NAVE N(7,7);
	N.pintar();
 
	bool game_over = false;
	while(!game_over){
 
 
		N.mover();
		Sleep(10);
	}
	return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
-1
Responder

problemas de copilacion

Publicado por Nacho (181 intervenciones) el 13/09/2020 12:46:15
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
#include<windows.h>
#include<conio.h>
 
#define ARRIBA 72
#define ISQUIERDA 75
#define DERECHA 77
#define ABAJO 80
 
void gotoxy(int x, int y) {
    HANDLE hCon;
    hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X = x;
    dwPos.Y = y;
    SetConsoleCursorPosition(hCon, dwPos);
}
 
void OcultarCursor() {
    HANDLE hCon;
    hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO cci;
    cci.dwSize = 20;
    cci.bVisible = FALSE;
    SetConsoleCursorInfo(hCon, &cci);
}
 
void pintar_limites() {
    for (int i = 2; i < 78; i++) {
        gotoxy(i, 2);  printf("%c", 205);
        gotoxy(i, 33); printf("%c", 205);
    }
    for (int i = 4; i < 33; i++) {
        gotoxy(2, i); printf("%c", 186);
        gotoxy(77, i); printf("%c", 186);
    }
    gotoxy(2, 3); printf("%c", 201);
    gotoxy(2, 33); printf("%c", 200);
    gotoxy(77, 3); printf("%c", 187);
    gotoxy(77, 33); printf("%c", 188);
}
 
 
class NAVE
{
    int x, y, corazones;
public:
    NAVE(int _x, int _y, int _corazones) : x(_x), y(_y), corazones(_corazones) {}
 
    void NAVE::pintar() {
        gotoxy(x, y); printf("   %c", 30);
        gotoxy(x, y + 1); printf("  %c%c%c", 40, 207, 41);
        gotoxy(x, y + 2); printf(" %c%c%c%c%c", 30, 190, 207, 190, 30);
        gotoxy(x, y + 3); printf("%c%c%c %c%c%c", 30, 40, 190, 190, 40, 30);
    }
 
    void NAVE::borrar() {
        gotoxy(x, y);   printf("      ");
        gotoxy(x, y + 1); printf("      ");
        gotoxy(x, y + 2); printf("      ");
        gotoxy(x, y + 3); printf("       ");
    }
 
    void NAVE::pintar_corazones()
    {
        gotoxy(64, 2); printf("salud");
        gotoxy(70, 2); printf("     ");
        for (int i = 0; i < corazones; i++) {
            gotoxy(70 + i, 2); printf("%c", 3);
        }
    }
 
    void NAVE::mover() {
        if (kbhit())
        {
            char tecla = getch();
            borrar();
            if (tecla == ISQUIERDA && x > 3) x--;
            if (tecla == DERECHA && x + 6 < 76) x++;
            if (tecla == ARRIBA && y > 4) y--;
            if (tecla == ABAJO && y + 3 < 32) y++;
            pintar();
            pintar_corazones();
        }
    }
};
 
 
int main()
{
    pintar_limites();
    NAVE N(7, 7, 8);
    N.pintar();
    bool game_over = false;
    while (!game_over) {
        N.mover();
        Sleep(10);
    }
    return 0;
}

Es lo que tiene eso de copiar y pegar.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Rodrigo
Val: 1.755
Plata
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

problemas de copilacion

Publicado por Rodrigo (539 intervenciones) el 13/09/2020 15:44:21
En la propuesta de mejora, parece que hay que quitar "NAVE::" de cada definicion
(lineas 46. 56 y 63)

Podria aprovechar de corregir ISQUIERDA por IZQUIERDA tambien, aunque no creo que esto haya sido indicado por el compilador.
Tal vez el IDE podria detectar algo asi.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar