Pascal/Turbo Pascal - Dudas varias Batalla Naval Pascal

 
Vista:
sin imagen de perfil

Dudas varias Batalla Naval Pascal

Publicado por Laira (2 intervenciones) el 26/12/2014 20:37:16
Hola

Estoy intentando terminar el juego de Batalla naval en tablero de 8x8, 2 jugadores.
Creo que algo tengo mal porque sigo y sigo jugando y nunca termina el juego...Además tengo que acabar el juego con la posibilidad de guardar el avance y seguir jugando mas tarde.

El código que llevo hasta ahora es:
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
program Hundir_la_flota;
uses crt;
type
tbarco = array [1..8, 1..8] of string;
tcontrol = array [1..8, 1..8] of string;
ttamano = array [1..8, 1..8] of string;
var
i,j: integer;
tablero_T1, tablero_T2: tbarco;
tablero_D1, tablero_D2: tcontrol;
tablero_B1, tablero_B2: ttamano;
conta1,conta2: integer;
fin, fin1, fin2: real;
direccion:string;
tb:tbarco;
tt,tp,tbom:tcontrol;
d1,d2 : tcontrol;
t1,t2 : tbarco;
b1,b2 : ttamano;
 
procedure Inicia_Tablero_Control (var td:tcontrol); {Se carga el tablero
donde colocar los barcos con todas las posiciones vacias.}
var
i,j:integer;
begin
	for i:=1 to 8 do
	for j:=1 to 8 do
		td[i,j] := 'X';
end;
procedure Inicia_Tablero_Barcos (var tb: tbarco); {Se carga el tablero
donde colocar los barcos con todas las posiciones en Agua}
var
i,j:integer;
begin
	for i:= 1 to 8 do
	for j:= 1 to 8 do
		tb[i,j]:= 'A';
end;
procedure Inicia_Tablero_Tamano (var tt:ttamano); {Se carga el tablero con las dimensiones de cada barco}
var
i,j: integer;
begin
	for i:= 1 to 8 do
	for j:= 1 to 8 do
		tt[i,j]:= '';
end;
procedure Introducir_Barcos (var tb: tbarco; tp: tcontrol); {Se carga el tablero
donde el jugador inserta los barcos}var
i,j:integer;
direccion: string;
begin
	repeat
		writeln('Introduce la coordenada FILA del barco 1: ');
		readln(i);
		writeln('Introduce la coordenada COLUMNA del barco 1: ');
		readln(j);
		if (i>8) and (j>8) then
			writeln('Coordenadas fuera de rango, utilice valores de 1 a 8.');
	until i<=8;
		begin
			tp[i,j]:='B';
			tb[i,j]:='UNO';
		end;
 
	writeln('¿En que direccion quiere colocar el barco 2: arriba/abajo/derecha/izquierda?:');
	readln(direccion);
	repeat
		writeln('Introduce la coordenada FILA del barco 2:');
		read(i);
		writeln('Introduce la coordenada COLUMNA del barco 2: ');
		readln(j);
		if (i>8) and (j>8) then
			writeln('Coordenadas fuera de rango, utilice valores de 1 a 8. ');
	until i<=8;
		if direccion = 'izquierda' then
			for j:= j downto 2 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='DOS';
				end
	else
		if direccion = 'derecha' then
			for j:= j to 2 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='DOS';
				end
	else
		if direccion = 'arriba' then
			for i := i downto 2 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='DOS';
				end
	else
		if direccion = 'abajo' then
			for i := i  to 2 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='DOS';
				end;
	writeln('¿En que direccion quiere colocar el barco 3: arriba/abajo/derecha/izquierda?:');
	readln(direccion);
	repeat
		writeln('Introduce la coordenada FILA del barco 3:');
		read(i);
		writeln('Introduce la coordenada COLUMNA del barco 3: ');
		readln(j);
		if (i>8) and (j>8) then
			writeln('Coordenadas fuera de rango, utilice valores de 1 a 8. ');
	until i<=8;
		if direccion = 'izquierda' then
			for j:= j downto 3 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='TRES';
				end
	else
		if direccion = 'derecha' then
			for j:= j to 3 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='TRES';
				end
	else
		if direccion = 'arriba' then
			for i := i downto 3 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='TRES';
						end
	else
		if direccion = 'abajo' then
			for i := i  to 3 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='TRES';
 				end;
 
	writeln('¿En que direccion quiere colocar el barco 4: arriba/abajo/derecha/izquierda?:');
	readln(direccion);
	repeat
		writeln('Introduce la coordenada FILA del barco 4:');
		read(i);
		writeln('Introduce la coordenada COLUMNA del barco 4: ');
		readln(j);
		if (i>8) and (j>8) then
			writeln('Coordenadas fuera de rango, utilice valores de 1 a 8. ');
	until i<=8;
		if direccion = 'izquierda' then
			for j:= j downto 4 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='CUATRO';
				end
	else
		if direccion = 'derecha' then
			for j:= j to 4 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='CUATRO';
				end
	else
		if direccion = 'arriba' then
			for i := i downto 4 do
                                  begin
					tp[i,j]:= 'B';
					tb[i,j]:='CUATRO';
				end
	else
		if direccion = 'abajo' then
			for i := i  to 4 do
				begin
					tp[i,j]:= 'B';
					tb[i,j]:='CUATRO';
                end;
      end;
procedure MuestraBombardeados (tbom:tcontrol);
var
i,j:integer;
begin
	for i:= 1 to 8 do
	begin
		for j:= 1 to 8 do
		begin
		write(tbom[i,j],' ');
		end;
	writeln;
	end;
end;
procedure Disparos (var t1,t2: tbarco; d1,d2: tcontrol; b1,b2: ttamano); {Se inicia el proceso de juego}
var
i,j: integer;
conta1,conta2 :integer;
fin, fin1, fin2 : real;
	begin
	conta1 :=0;
	conta2 :=0;
		begin
			while fin <>1 do
 
			begin
			fin1 :=4;
			fin2 :=4;
			repeat
				begin
				writeln;
				writeln('Es el turno del jugador 1');
				writeln;
				writeln('El estado del tablero de disparos es: ');
					begin
					MuestraBombardeados(d1)
					end;
				repeat
				writeln;
				writeln('Introduzca la coordenada FILA de barco a atacar: ');
				readln(i);
					if i>8 then
					begin
						writeln;
						writeln('La coordenada indicada esta fuera de rango, intentelo de nuevo con valores entre 1 y 8.');
					end;
				until i<=8;
				repeat
				writeln;
				writeln('Introduzca la coordenada COLUMNA de barco a atacar: ');
				readln(j);
					if j>8 then
					begin
						writeln;
						writeln('La coordenada indicada esta fuera de rango, intentelo de nuevo con valores entre 1 y 8.');
					end;
				until j<=8;
			if t2[i,j]='B' then
				begin writeln;
					writeln('TOCADO, ha alcanzado un barco de dimensión ',b2[i,j]);
					d1[i,j]:='B';
					conta1 := conta1 + 1;
				end
			else
				begin
					writeln;
					writeln('AGUA');
					writeln;
					writeln('Ha perdido el turno.');
					d1[i,j]:='A';
				end;
			if t2[i,j]<> 'B' then
				begin
					fin1 := 2;
				end;
			if conta1 >=10 then
				begin
					fin1 := 2;
					writeln;
					writeln('FELICIDADES!!, ha GANADO el jugador 1');
				end;
			end;
		until fin1 = 2;
			if conta1 >= 10 then
				begin
					fin := 1
				end;
			if conta1 <10 then
				begin
					repeat
						begin
							writeln;
							writeln('Es el turno del jugador 2');
							writeln;
							writeln('El estado del tablero de disparos es: ');
								begin
									MuestraBombardeados(d1)
								end;
					end;
					repeat
						writeln;
						writeln('Introduzca la coordenada FILA de barco a atacar: ');
						readln(i);
							if i>8 then
							begin
								writeln;
								writeln('La coordenada indicada esta fuera de rango, intentelo de nuevo con valores entre 1 y 8.');
							end;
						until i<=8;
							repeat
							writeln;
							writeln('Introduzca la coordenada COLUMNA de barco a atacar: ');
							readln(j);
								if j>8 then
								begin
									writeln;
									writeln('La coordenada indicada esta fuera de rango, intentelo de nuevo con valores entre 1 y 8.');
								end;
						until j<=8;
						if t1[i,j]='B' then
							begin writeln;
								writeln('TOCADO, ha alcanzado un barco de dimensión ',t2[i,j]);
								d2[i,j]:='B';
								conta2 := conta2 +1;
							end
						else
							begin
								writeln;
								writeln('AGUA');
								writeln;
								writeln('Ha perdido el turno.');
								d2[i,j]:='A';
							end;
						if t1[i,j]<>'B' then
							begin
								fin2:=2;
							end;
						if conta2>=10 then
							begin
								fin2 := 2;
								writeln;
								writeln('FELICIDADES!!, ha GANADO el jugador 1');
								writeln;
							end;
						end;
					until fin2 = 2;
				end;
						if conta2>=10 then
							begin
								fin := 1;
							end;
						end;
					end;
			end;
 
begin (*del programa principal*);
        writeln ('Bienvenido al juego Hundir la Flota');
	Inicia_Tablero_Barcos(tablero_T1);
	Inicia_Tablero_Barcos(tablero_T2);
	Inicia_Tablero_Control(tablero_D1);
	Inicia_Tablero_Control(tablero_D1);
	Inicia_Tablero_Tamano(tablero_B1);
	Inicia_Tablero_Tamano(tablero_B2);
	writeln;
	writeln('JUGADOR 1 introduzca sus barcos');
	writeln;
	introducir_barcos(tablero_T1,tablero_D1);
	writeln;
	writeln('JUGADOR 2 introduzca sus barcos');
	writeln;
	introducir_barcos(tablero_T2,tablero_D2);
	Disparos(tablero_T1,tablero_T2,tablero_D1,tablero_D2,tablero_B1,tablero_B2);
end.

Alguien me puede echar una mano? Sobre todo con el guardado/carga de partida porque no tengo ni idea. Gracias
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

Dudas varias Batalla Naval Pascal

Publicado por ramon (2158 intervenciones) el 28/12/2014 01:02:02
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
{Mira tu programa retocado el resto para ti}
 
program Hundir_la_flota;
uses
   crt;
type
   tbarco = array[1..8,1..8] of string[20];
 
   jugada = record
      eljuga1 : array[1..3] of tbarco;
      eljuga2 : array[1..3] of tbarco;
      jug1, jug2 : integer;
     end;
 
  var
     f : file of jugada;
     jug : jugada;
     i,j : integer;
     tablero_T1, tablero_T2 : tbarco;
     tablero_D1, tablero_D2 : tbarco;
     tablero_B1, tablero_B2 : tbarco;
     conta1, conta2 : integer;
     fin, fin1, fin2 : real;
     direccion : string[50];
     tb : tbarco;
     tt, tp, tbom : tbarco;
     d1, d2 : tbarco;
     t1, t2 : tbarco;
     b1, b2 : tbarco;
 
  procedure guarda_juego(t1 : tbarco;t2 : tbarco;t3 : tbarco; ton : integer;
                         d1 : tbarco;d2 : tbarco;d3 : tbarco; cod : integer);
  begin
     assign(f,'eljuego.dat');
   {$I-} reset(f); {$I+}
    if ioresult = 0 then
    begin
       close(f);
       erase(f);
    end;
    assign(f,'eljuego.dat');
    rewrite(f);
    jug.eljuga1[1] := t1;
    jug.eljuga1[2] := t2;
    jug.eljuga1[3] := t3;
    jug.jug1 := ton;
    jug.eljuga2[1] := d1;
    jug.eljuga2[2] := d2;
    jug.eljuga2[3] := d3;
    jug.jug2 := cod;
    seek(f,0);
    write(f,jug);
    close(f);
  end;
 
  procedure carga_juego(var t1 : tbarco;var t2 : tbarco;
                        var t3 : tbarco; var ton : integer;
                        var d1 : tbarco;var d2 : tbarco;
                        var d3 : tbarco; var cod : integer);
  begin
     assign(f,'eljuego.dat');
   {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
        writeln('   Error Archivo Da¤ado O No Existe Pulse Una Tecla');
        readkey;
    end
  else
     begin
        seek(f,0);
        read(f,jug);
      t1 := jug.eljuga1[1];
      t2 := jug.eljuga1[2];
      t3 := jug.eljuga1[3];
      ton := jug.jug1;
     d1 := jug.eljuga2[1];
     d2 := jug.eljuga2[2];
     d3 := jug.eljuga2[3];
     cod := jug.jug2;
        close(f);
     end;
  end;
 
  function entrada_cordenadas : integer;
   var
     cor : integer;
   begin
      entrada_cordenadas := 0;
     repeat
        cor := ord(readkey) - 48;
     until (cor > 0) and (cor < 9);
     entrada_cordenadas := cor;
   end;
 
  procedure Inicia_Tablero_Control (var td : tbarco); {Se carga el tablero
             donde colocar los barcos con todas las posiciones vacias.}
  var
    i, j : integer;
    begin
	for i := 1 to 8 do
	 for j := 1 to 8 do
	 td[i,j] := 'X';
    end;
 
   procedure Inicia_Tablero_Barcos (var tb: tbarco); {Se carga el tablero
            donde colocar los barcos con todas las posiciones en Agua}
    var
      i, j : integer;
    begin
	for i:= 1 to 8 do
	 for j:= 1 to 8 do
	 tb[i,j]:= 'A';
   end;
 
   procedure Inicia_Tablero_Tamano (var tt : tbarco);
               {Se carga el tablero con las dimensiones de cada barco}
   var
    i, j : integer;
    begin
	for i:= 1 to 8 do
	  for j:= 1 to 8 do
	  tt[i,j] := '';
    end;
 
   procedure Introducir_Barcos (var tb: tbarco; tp: tbarco);
   {Se carga el tablero donde el jugador inserta los barcos}
   var
    i,j : integer;
    direccion : string;
    begin
	repeat
	  write('Introduce la coordenada FILA del barco 1 : ');
	  readln(i);
          write('Introduce la coordenada COLUMNA del barco 1 : ');
	  readln(j);
	  if (i > 8) and (j > 8) then
	  writeln('Coordenadas fuera de rango, utilice valores de 1 a 8.');
	until i <= 8;
	begin
	   tp[i,j] := 'B';
	   tb[i,j] := 'UNO';
	end;
	write('¿En que direccion quiere colocar el barco 2 : arriba/abajo/derecha/izquierda? : ');
	readln(direccion);
    repeat
       write('Introduce la coordenada FILA del barco 2 : ');
       readln(i);
       write('Introduce la coordenada COLUMNA del barco 2 : ');
       readln(j);
       if (i > 8) and (j > 8) then
       writeln('Coordenadas fuera de rango, utilice valores de 1 a 8. ');
    until i <= 8;
    if direccion = 'izquierda' then
    for j := j downto 2 do
    begin
      tp[i,j] := 'B';
      tb[i,j] := 'DOS';
    end
  else
     if direccion = 'derecha' then
     for j := j to 2 do
     begin
        tp[i,j] := 'B';
	tb[i,j] := 'DOS';
     end
  else
      if direccion = 'arriba' then
      for i := i downto 2 do
      begin
         tp[i,j] := 'B';
	 tb[i,j] := 'DOS';
      end
  else
      if direccion = 'abajo' then
      for i := i  to 2 do
      begin
         tp[i,j] := 'B';
	 tb[i,j] := 'DOS';
      end;
	write('¿En que direccion quiere colocar el barco 3: arriba/abajo/derecha/izquierda? : ');
	readln(direccion);
	repeat
	   write('Introduce la coordenada FILA del barco 3 : ');
	   readln(i);
	   write('Introduce la coordenada COLUMNA del barco 3 : ');
	   readln(j);
	   if (i > 8) and (j > 8) then
	   writeln('Coordenadas fuera de rango, utilice valores de 1 a 8. ');
	until i<=8;
	if direccion = 'izquierda' then
	 for j:= j downto 3 do
	 begin
	    tp[i,j] := 'B';
	    tb[i,j] := 'TRES';
	 end
    else
	if direccion = 'derecha' then
	for j := j to 3 do
	begin
	  tp[i,j]:= 'B';
	  tb[i,j]:='TRES';
	end
     else
        if direccion = 'arriba' then
	for i := i downto 3 do
	begin
	  tp[i,j] := 'B';
	  tb[i,j]:='TRES';
	end
    else
      if direccion = 'abajo' then
       for i := i  to 3 do
       begin
	  tp[i,j]:= 'B';
	  tb[i,j]:='TRES';
 	end;
	write('¿En que direccion quiere colocar el barco 4 : arriba/abajo/derecha/izquierda?:');
	readln(direccion);
	repeat
	   write('Introduce la coordenada FILA del barco 4 :');
	   readln(i);
	   write('Introduce la coordenada COLUMNA del barco 4 : ');
	   readln(j);
	   if (i > 8) and (j > 8) then
	   writeln('Coordenadas fuera de rango, utilice valores de 1 a 8. ');
	until i <= 8;
	if direccion = 'izquierda' then
	for j := j downto 4 do
	begin
	   tp[i,j] := 'B';
	   tb[i,j] := 'CUATRO';
	end
    else
       if direccion = 'derecha' then
        for j := j to 4 do
	begin
	   tp[i,j] := 'B';
	   tb[i,j] := 'CUATRO';
	end
    else
       if direccion = 'arriba' then
       for i := i downto 4 do
       begin
          tp[i,j] := 'B';
	  tb[i,j] := 'CUATRO';
       end
   else
      if direccion = 'abajo' then
       for i := i  to 4 do
       begin
	  tp[i,j]:= 'B';
	  tb[i,j]:='CUATRO';
       end;
   end;
 
 
   procedure MuestraBombardeados (tbom : tbarco);
   var
     i, j : integer;
      begin
	for i := 1 to 8 do
	begin
	  for j := 1 to 8 do
	  begin
	     write(tbom[i,j],' ');
	  end;
	  writeln;
	end;
   end;
 
   procedure Disparos (var t1,t2: tbarco; d1,d2: tbarco; b1,b2: tbarco);
   {Se inicia el proceso de juego}
   var
     i, j : integer;
      conta1, conta2 :integer;
      fin, fin1, fin2 : real;
      begin
	conta1 := 0;
	conta2 := 0;
	  while fin <> 1 do
	  begin
	     fin1 := 4;
	     fin2 := 4;
        repeat
	   writeln;
	   writeln('Es el turno del jugador 1');
	   writeln;
	   writeln('El estado del tablero de disparos es : ');
	   MuestraBombardeados(d1);
	   writeln;
	   writeln('Introduzca la coordenada FILA de barco a atacar : ');
	   i := entrada_cordenadas;
	   writeln;
	   writeln('Introduzca la coordenada COLUMNA de barco a atacar: ');
	   j := entrada_cordenadas;
	   if t2[i,j] = 'B' then
	   begin
              writeln;
	      writeln('TOCADO, ha alcanzado un barco de dimensión ',b2[i,j]);
	      d1[i,j] := 'B';
	      conta1 := conta1 + 1;
	   end
	else
	    begin
	       writeln;
	       writeln('AGUA');
	       writeln;
	       writeln('Ha perdido el turno.');
	       d1[i,j] := 'A';
	    end;
	    if t2[i,j] <> 'B' then
	    begin
	      fin1 := 2;
	    end;
	     if conta1 >= 10 then
	     begin
	       fin1 := 2;
	       writeln;
	       writeln('FELICIDADES!!, ha GANADO el jugador 1');
	     end;
	until fin1 = 2;
	if conta1 >= 10 then
      begin
        fin := 1
      end;
      if conta1 < 10 then
      begin
         repeat
	    writeln;
	    writeln('Es el turno del jugador 2');
	    writeln;
	    writeln('El estado del tablero de disparos es: ');
            MuestraBombardeados(d1);
	    writeln;
	    writeln('Introduzca la coordenada FILA de barco a atacar: ');
	    i := entrada_cordenadas;
	    writeln;
	    writeln('Introduzca la coordenada COLUMNA de barco a atacar: ');
	   j := entrada_cordenadas;
	   if t1[i,j] = 'B' then
	   begin
             writeln;
	     writeln('TOCADO, ha alcanzado un barco de dimensión ',t2[i,j]);
	     d2[i,j] := 'B';
	     conta2 := conta2 + 1;
	   end
      else
         begin
	   writeln;
	   writeln('AGUA');
	   writeln;
	   writeln('Ha perdido el turno.');
	   d2[i,j] := 'A';
	 end;
	 if t1[i,j] <> 'B' then
	 begin
	   fin2 := 2;
	 end;
	 if conta2 >= 10 then
	 begin
	    fin2 := 2;
	    writeln;
	    writeln('FELICIDADES!!, ha GANADO el jugador 1');
	    writeln;
	 end;
	 until fin2 = 2;
      end;
        if conta2 >= 10 then
	begin
	  fin := 1;
	end;
      end;
    end;
 
    procedure menujuego;
    var
      tecla : char;
      sal : boolean;
    begin
       sal := false;
     repeat
       clrscr;
       writeln('     ***** Menu Juego *****');
       writeln;
       writeln('  1 = Juego Nuevo');
       writeln('  2 = Cargar Guardado');
       writeln('  3 = Guerdar Jugada');
       writeln('  4 = Salir');
       writeln;
       writeln('   <<< Elija Opcion >>>');
       repeat
           tecla := readkey;
       until tecla in['1','2','3','4'];
       clrscr;
    case tecla of
  '1' : begin
        writeln ('Bienvenido al juego Hundir la Flota');
	Inicia_Tablero_Barcos(tablero_T1);
	Inicia_Tablero_Barcos(tablero_T2);
	Inicia_Tablero_Control(tablero_D1);
	Inicia_Tablero_Control(tablero_D1);
	Inicia_Tablero_Tamano(tablero_B1);
	Inicia_Tablero_Tamano(tablero_B2);
	writeln;
        writeln('JUGADOR 1 introduzca sus barcos');
	writeln;
	introducir_barcos(tablero_T1,tablero_D1);
	writeln;
	writeln('JUGADOR 2 introduzca sus barcos');
	writeln;
	introducir_barcos(tablero_T2,tablero_D2);
	Disparos(tablero_T1,tablero_T2,tablero_D1,tablero_D2,tablero_B1,tablero_B2);
       end;
  '2' : begin
        writeln ('Bienvenido al juego Hundir la Flota');
	Inicia_Tablero_Barcos(tablero_T1);
	Inicia_Tablero_Barcos(tablero_T2);
	Inicia_Tablero_Control(tablero_D1);
	Inicia_Tablero_Control(tablero_D1);
	Inicia_Tablero_Tamano(tablero_B1);
	Inicia_Tablero_Tamano(tablero_B2);
	writeln;
        carga_juego(tablero_T1,tablero_D1,tablero_B1,conta1,
        tablero_T2,tablero_D2,tablero_B2,conta2);
        Disparos(tablero_T1,tablero_T2,tablero_D1,tablero_D2,tablero_B1,tablero_B2);
       end;
  '3' : begin
          writeln('>>>>> Guardando Partida <<<<<<');
          guarda_juego(tablero_T1,tablero_D1,tablero_B1,conta1,
                     tablero_T2,tablero_D2,tablero_B2,conta2);
          writeln('---- Pulse Una Tecla ----');
          readkey;
       end;
  '4' : sal := true;
    end;
   until sal = true;
  end;
 
 
     begin (*del programa principal*);
        menujuego;
    end.
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
sin imagen de perfil

Dudas varias Batalla Naval Pascal

Publicado por Laira (2 intervenciones) el 28/12/2014 20:07:54
Muchisimas gracias Ramón, le echaré un ojo!
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