Dev - C++ - PROBLEMA CON JUEGO AHORCADO C++

 
Vista:
sin imagen de perfil
Val: 2
Ha aumentado su posición en 804 puestos en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

PROBLEMA CON JUEGO AHORCADO C++

Publicado por Jorge (1 intervención) el 10/06/2021 14:34:51
He creado un juego parecido al ahorcado de toda la vida pero cuando ejecuto el juego tengo problemas (no errores) que impiden el buen funcionamiento del juego.
Se agradecería 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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*Este juego es una versión del ahorcado con pequeñas modificaciones, por ejemplo,
en vez de ir poniendo letras una a una e ir probando hasta formar una palabra,
tendrás que adivinar la palabra a la primera*/
 
 
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
//Declaración de variables
    string jugador1,palabra,espacio,adivina;
    int falso=0;
    int juego,partidas,victoria,derrota,rondasfinal;
	int rondas;
 
 
int main (){
//Empezamos a contar el numero de rondas o partidas
	partidas=1;
 
//Elección de palabras aleatoriamente
srand(time(0));
	const string wordList[9] = { "COCHE", "CASA", "DICCIONARIO", "TONTO", "GRACIOSO", "ORDENADOR", "CONTENEDOR", "AGUJERO", "MADRID" };
    string palabra = wordList[rand() % 9];
 
 
//Entrada de datos
    cout << "----------------------BIENVENIDO AL AHORCADO :)----------------------" << endl;
    cout << "                    NORMA: Todo va en mayusculas" << endl;
    cout << "               RECUERDA: Las palabras se pueden repetir" << endl;
    //cout << "Introduzca el NUMERO de rondas que quiera jugar (Como max 9): " << endl;
    //cin >> rondas;
 
//Para ver si es un letra se hace mediante la función isalpha
/*if(isalpha(rondas))
	{
			cout << "DIJE QUE INTRODUJESES UN NUMERO NO UNA LETRA!!!Saliendo.......Pulse cualquier tecla" << endl;
		exit(-1);
	}
//Si introduce un numero se continuaría con el juego
else
	{
		rondasfinal=rondas-48;
		juego=rondasfinal/2;
		cout << "   ENTONCES SI CONSIGUES LLEGAR A " << ++juego << " PUNTOS GANAS!!!... MUCHA SUERTE!!!" << endl;
}	*/
 
    rondasfinal=3;
    juego=2;
    victoria = 0;
    derrota = 0;
 
	cout << "Introduzca su nombre porfavor, Jugador 1" << endl;
    cin >> jugador1;
while(partidas<=rondasfinal)
	{
 
		partidas=partidas+1;
		while((victoria!=juego)&&(derrota!=juego))
 
		{
		/*	while(derrota==juego/2)
        {
            cout << "GAME OVER :(" << endl;
            exit (-1);
        }*/
			srand(time(0));
	const string wordList[10] = { "COCHE", "CASA", "DICCIONARIO", "TONTO", "GRACIOSO", "ORDENADOR", "CONTENEDOR", "AGUJERO", "MADRID" };
    string palabra = wordList[rand() % 11];
cout << "Estas son las opciones que tendras mientras juegas:"<< endl;
cout << "-->COCHE" << endl;
cout << "-->CASA" << endl;
cout << "-->DICCIONARIO" << endl;
cout << "-->TONTO" << endl;
cout << "-->GRACIOSO" << endl;
cout << "-->ORDENADOR" << endl;
cout << "-->CONTENEDOR" << endl;
cout << "-->AGUJERO" << endl;
cout << "-->MADRID" << endl;
cout << "-->" << jugador1 << endl;
cout << "OK " << jugador1 << ". Empieza el juego!!" << endl;
cout << "palabra escogida " << palabra << endl;
 
 
//espacio
for (int x=30; x<40; x++){
cout << endl;
}
 
//Letras de la palabra
while (espacio.size() != palabra.size())
{
	espacio.push_back('_');
}
 
cout << espacio << endl;
 
//Numero de oportunidades
while(falso<13){
cin >> adivina;
 
//Si no coinciden las respuestas o si sí coinciden
if(adivina.size() > 1){
if(adivina==palabra){
	    cout << "________$$$$.." << endl;
        cout << "______$$$$$$$$$" << endl;
        cout << "______$$$$$$$_$" << endl;
        cout << "_____$$$$$$$$$$" << endl;
        cout << "______$$$$$$$$$$" << endl;
        cout << "_____$$$$$$_$$$$$" << endl;
        cout << "____$$$$$$$_____$$$" << endl;
        cout << "____$$$$$$$$_____$" << endl;
        cout << "____$$$$$$$$$$" << endl;
        cout << "_____$$$$$$$$$$" << endl;
        cout << "_____$$$$$$$$$$$" << endl;
        cout << "______$$$$$$$$$$$" << endl;
        cout << "_$$$$___$$$$$$$$$" << endl;
        cout << "__$$$$$$$$$$$$$$$" << endl;
        cout << "_$$$$$$$$$$$$$$$" << endl;
        cout << "__$$$$$$$$$$$$$" << endl;
        cout << "$$$$$$$$$$$$$" << endl;
        cout << "__$__$$$$$$" << endl;
        cout << "____$$$$$$" << endl;
        cout << "____$$$$$" << endl;
        cout << "___$$$$$$_____$" << endl;
        cout << "___$$$$$$___$$_$$" << endl;
        cout << "____$$$$$___$__$$" << endl;
        cout << "____$$$$$______$$" << endl;
        cout << "_____$$$$$____$$$" << endl;
        cout << "_______$$$$$$$$$" << endl;
        cout << "__________$$$$" << endl;
cout << "Enhorabuena te mantienes con vida!!" << endl;
victoria = victoria +1;
cout << "Vamos tu " << victoria << " y yo " << derrota << endl;
break;
}
else{
    cout << espacio << endl;
    cout << "No has tenido suerte :(" << endl;
    cout << "Utilizado " << adivina << endl;
falso ++;
 
}
}
 
 
 
 
 
if(espacio == palabra){
  cout << "Has ganado" << endl;
  break;
}
 
 
 
if(falso==1){
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==2){
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==3){
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==4){
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==5){
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==6){
    cout << "II===" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==7){
    cout << "II======" << endl;
    cout << "II     " << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==8){
    cout << "II======" << endl;
    cout << "II     O" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==9){
    cout << "Ii======" << endl;
    cout << "II     O" << endl;
    cout << "II     |" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==10){
    cout << "II======" << endl;
    cout << "II     O" << endl;
    cout << "II   --|" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==11){
    cout << "II======" << endl;
    cout << "II     O" << endl;
    cout << "II   --|--" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==12){
    cout << "II======" << endl;
    cout << "II     O" << endl;
    cout << "II   --|--" << endl;
    cout << "II    /"  << endl;
    cout << "II" << endl;
    cout << "II" << endl;
    cout << espacio << endl;
}
else if(falso==13){
   cout << "8888888888 888" << endl;
    cout << "888        888                     __________" << endl;
    cout << "888        888                    II         |" << endl;
    cout << "8888888    888                    II         0"<< endl;
    cout << "888        888                    II       --|-- "<< endl;
	cout << "888        888                    II        / / " << endl;
	cout << "888        888                    II" << endl;
	cout << "8888888888 888                    II" << endl;
 
	cout << "        888                                             888 " << endl;
	cout << "        888                                             888 " <<endl;
	cout << "        888                                             888 " <<endl;
	cout << "8888b.  88888b.   .d88b.  888d888 .d8888b  8888b.   .d88888  .d88b. " <<endl;
	cout << "    88b 888  88b d88  88b 888P   d88P          88b d88  888 d88  88b "  << endl;
	cout <<".d888888 888  888 888  888 888    888      .d888888 888  888 888  888 " << endl;
	cout <<"888  888 888  888 Y88..88P 888    Y88b.    888  888 Y88b 888 Y88..88P " <<endl;
	cout <<" Y888888 888  888 \\Y88P//  888     Y8888P   Y888888 Y88888// \\Y88P//  " << endl;
 
    cout << "Krak! Algo se rompio y no fue la cuerda :(" << endl;
 
    cout << "Has perdido, la palabra era: " << palabra <<endl;
 
//Indicar que has perdido una ronda completa
	derrota = derrota +1;
    cout << "Vamos tu " << victoria << " y yo " << derrota << endl;
break;
}
}
//FIN DE LAS RONDAS Y DEL JUEGO COMPLETO
while(victoria==juego)
{
cout << "EL JUEGO HA FINALIZADO!!!!" << endl;
exit (-1);
}
while(derrota==juego)
{
cout << "GAME OVER :(" << endl;
exit (-1);
 
}
}
}
}
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